# UndefVarError: HierarchicalClustering not defined

**URL:** <https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767>\
**Category:** General Usage\
**Created:** [April 22, 2023, 12:34am UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767 "2023-04-22T00:34:02Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Selly\_Shivute](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/selly_shivute/32/49200_2.png) [@Selly\_Shivute](https://discourse.julialang.org/u/Selly_Shivute)\
**Post date:** [April 22, 2023, 12:34am UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/1 "2023-04-22T00:34:02Z")

</div>

i m trying create a HierarchicalClustering using linkage but i m getting UndefVarError: HierarchicalClustering not defined… the package is installed

---

<div class="post-metadata">

**Author:** ![Selly\_Shivute](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/selly_shivute/32/49200_2.png) [@Selly\_Shivute](https://discourse.julialang.org/u/Selly_Shivute)\
**Post date:** [April 22, 2023, 12:36am UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/2 "2023-04-22T00:36:46Z")

</div>

This are my code

using Clustering.HierarchicalClustering

# Create a matrix from the dataframe

#X = convert(Matrix, wine\_df)

# Normalize the matrix along its rows

X\_norma = transpose(normalize(transpose(wine)))

# Define the distance metric to use

dist\_metric = Euclidean()

# Perform hierarchical clustering

model = linkage(X\_norma, dist\_metric, “complete”)

# Choose the number of clusters

num\_clusters = 3

# Extract the cluster IDs

clusters = cutree(model, num\_clusters)

---

<div class="post-metadata">

**Author:** ![OmarElrefaei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/omarelrefaei/32/43002_2.png) [@OmarElrefaei](https://discourse.julialang.org/u/OmarElrefaei)\
**Post date:** [April 22, 2023, 3:35am UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/3 "2023-04-22T03:35:43Z")

</div>

Hi @Selly_Shivute, welcome to our discourse.

from a cursory look it seems that there is no module called `HierarchicalClustering`.  
The documentation for `Clustering.jl` only mentions an [`hclust` function](https://juliastats.org/Clustering.jl/stable/hclust.html), but I can’t find anything named `HierarchicalClustering`.  
So try just `using Clustering` in the first line, that might be all you need.

* * *

Note: check out the pinned post: [(make it easier to help you)](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)  
Particularly numbers 2 and 4. It would be much easier to offer help if your code is a _self-contained_ example that looks like this:

```julia
# Normalize the matrix along its rows
X_norma = transpose(normalize(transpose(wine)))
# Define the distance metric to use
dist_metric = Euclidean()

```

_self-contained_ meaning that all everything is previously defined: for example here I’m not sure what kind of variable `wine` is supposed to be, and I get `Euclidean is not defined` because I don’t know which package it comes from.

---

<div class="post-metadata">

**Author:** ![Selly\_Shivute](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/selly_shivute/32/49200_2.png) [@Selly\_Shivute](https://discourse.julialang.org/u/Selly_Shivute)\
**Post date:** [April 22, 2023, 8:01pm UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/4 "2023-04-22T20:01:04Z")

</div>

thank you Omar, linkage is the one that suppose to do hierarchical clustering and it just giving me an error that linkage is not defined, suppose to be included in clustering package, pls email me at [sll.shivute@gmail.com](mailto:sll.shivute@gmail.com) so you can try to assist…

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [April 22, 2023, 8:43pm UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/5 "2023-04-22T20:43:12Z")

</div>

> [@Selly\_Shivute](#):
>
> linkage is the one that suppose to do hierarchical clustering and it just giving me an error that linkage is not defined, suppose to be included in clustering package

Where did you get the information that this should be included in the clustering package? Did you generate this code example using a chatbot or other automated code generation service? If so, I would highly advise against doing that because they often completely make up libraries and lie about what functions are available.

---

<div class="post-metadata">

**Author:** ![Selly\_Shivute](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/selly_shivute/32/49200_2.png) [@Selly\_Shivute](https://discourse.julialang.org/u/Selly_Shivute)\
**Post date:** [April 23, 2023, 5:07am UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/6 "2023-04-23T05:07:45Z")

</div>

Yes, i have used a chatboat, i m learning Julia and is quite  
difficult. I m doing clustering using agglomerative hierarchic to  
determine the types of wine.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [April 23, 2023, 8:10am UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/7 "2023-04-23T08:10:05Z")

</div>

A ChatBot will prove to be an unreliable navigator to take with you on your Julia journey.

It doesn’t have reliable, up-to-date, maps, it doesn’t have great map-reading skills, and will happily make stuff up if it gets lost, and be convinced that it knows the route when it doesn’t. And, if you can’t tell when it’s lost or lying to you, your journey might take longer than it otherwise would.

That said, they can sometimes carry out simple tasks successfully. But don’t rely on them too much.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [April 23, 2023, 8:42am UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/8 "2023-04-23T08:42:01Z")

</div>

HI and welcome to the Julia forum.

A package like `HierarchicalClustering` never existed. Your code seems to even try to load a submodule of clustering as  
`using Clustering.HierarchicalClustering` indicates it should exist as a submodule in `Closeting.jl`. That never existed.

Maybe the best analogy to why not to use Chatbots for learning coding is that they “halucinate” code. Ok, maybe even aluciantion in a well-educated sense (imagine them peeking into StackExchange and other forums before hallucination).

For very default things this guessing works okayish, but it should always be taken with the carer that you are already knowing what to do you just miss the details.

This is not the case while you are learning that yourself. So I would only use Chatbots if you _have learned_ what you want to do – and even then with much carefulness only.

Concerning your actual problem you want to solve, I am not sure what you were aiming at, so maybe we can help you when you have explained that more (and taken a look at the `Clustering.jl` documentation linked above.

---

<div class="post-metadata">

**Author:** ![Selly\_Shivute](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/selly_shivute/32/49200_2.png) [@Selly\_Shivute](https://discourse.julialang.org/u/Selly_Shivute)\
**Post date:** [April 25, 2023, 1:48pm UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/9 "2023-04-25T13:48:28Z")

</div>

Dear Ronny

import Pkg; Pkg.add(“AdaBoost”) but i m getting an error. The following package names could not be resolved:

```julia
 * AdaBoost (not found in project, manifest or registry) 

```

Suggestions: RadialBasisFunctionModels

i want to implement a classifier using a **boosting** ensemble technique.

Which package can i use to adaboost? i install RadialBasisFunctionModels but still getting same error

Regards  
Selma

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [April 25, 2023, 1:58pm UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/10 "2023-04-25T13:58:06Z")

</div>

Where do you have the idea from to use some `AdaBoost.jl` package? As the message indicates such a package does not exist. And you can not install something that does not exist.

So if you have that from ChatGPT, that is the same as I wrote above, often ChatGPT makes something up.

I have no clue about the application / topic you have in mind so I can not recommend anything, besides not using ChatGPT to generate code.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [April 25, 2023, 2:21pm UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/11 "2023-04-25T14:21:11Z")

</div>

Maybe look at MLJ, here’s a docs section about ensemble models:

[https://alan-turing-institute.github.io/MLJ.jl/dev/homogeneous\_ensembles/#Homogeneous-Ensembles](https://alan-turing-institute.github.io/MLJ.jl/dev/homogeneous_ensembles/#Homogeneous-Ensembles)

---

<div class="post-metadata">

**Author:** ![Selly\_Shivute](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/selly_shivute/32/49200_2.png) [@Selly\_Shivute](https://discourse.julialang.org/u/Selly_Shivute)\
**Post date:** [April 25, 2023, 5:49pm UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/12 "2023-04-25T17:49:29Z")

</div>

i got this from normal google, i just typed how to build boosting ensemble,

is there a website i can learn Julia? may you please share??

---

<div class="post-metadata">

**Author:** ![Selly\_Shivute](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/selly_shivute/32/49200_2.png) [@Selly\_Shivute](https://discourse.julialang.org/u/Selly_Shivute)\
**Post date:** [April 25, 2023, 7:38pm UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/13 "2023-04-25T19:38:48Z")

</div>

I have the following task to complete and i need to implement a boosting ensemble…i dont get code to understand an ensemble … Julia is so complicated with alot of error… may you assist ?

Consider the dataset available at this [link](https://www.kaggle.com/datasets/harrywang/wine-dataset-for-clustering). It contains various attributes of wine, including alcohol, magnesium, hue, etc. Your task is twofold:

- Implement an **agglomerative hierarchical clustering** algorithm to determine the types of wine;
- Building on the classes identified earlier, implement a classifier using a **boosting** ensemble technique.

Note that all your models must be implemented in the **Julia** programming language.

## Assessment Criteria

We will follow the criteria below to assess the problem:

- Data preparation and preprocessing. (10%)
- Implementation of the clustering algorithm. (25%)
- Implementation of the classifier. (30%)
- Evaluation Metrics (for the classifier). (15%)
- Overall solution in **Julia**. (20%)

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [April 25, 2023, 8:00pm UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/14 "2023-04-25T20:00:23Z")

</div>

This looks like a homework problem or course assignment, so please make sure you check any academic integrity rules in completing it.

It’s also not clear to me from the wording of the assignment whether you can use any package for this task, the question might imply implementing the algorithm yourself.

In any case I recommend reading the manual to work out the basics of Julia, and maybe docs for CSV and DataFrames for the data wrangling part. If you encounter errors people here will be generally happy to help if you start a new thread with a reproducible example.

---

<div class="post-metadata">

**Author:** ![Realyyc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/realyyc/32/206582_2.png) [@Realyyc](https://discourse.julialang.org/u/Realyyc)\
**Post date:** [March 12, 2024, 11:36am UTC](https://discourse.julialang.org/t/undefvarerror-hierarchicalclustering-not-defined/97767/15 "2024-03-12T11:36:24Z")

</div>

maybe come from this document [[HierarchicalClustering · MLJ](https://alan-turing-institute.github.io/MLJ.jl/dev/models/HierarchicalClustering_Clustering/)]
