supervised unsupervised - university of british columbiawilliam/eosc510/ch5/ch5b.pdfsrb7 srb6 srb5...

15
Ch.5 Classification and Clustering In machine learning, there are two main types of learning problems, supervised and unsupervised learning. An analogy for the former is a French class where the teacher demonstrates the correct French pronunciation. An analogy for the latter is students working on a team project without supervision – i.e., the students are provided with learning rules, but must rely on self-organization to arrive at a solution, without a teacher. In supervised learning , one is provided with the predictor data, x 1 ,..., x n , and the response data, y 1 ,..., y n . Given the predictor data as input, the model produces outputs, y 0 1 ,..., y 0 n . 1 / 15

Upload: others

Post on 23-Jan-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

Ch5 Classification and Clustering

In machine learning there are two main types of learning problemssupervised and unsupervised learning

An analogy for the former is a French class where the teacherdemonstrates the correct French pronunciationAn analogy for the latter is students working on a team projectwithout supervision ndash ie the students are provided with learningrules but must rely on self-organization to arrive at a solutionwithout a teacher

In supervised learning one is provided with the predictor datax1 xn and the response data y1 yn Given the predictordata as input the model produces outputs yprime

1 yprimen

1 15

The model learning is ldquosupervisedrdquo in that the model output(yprime

1 yprimen) is guided towards the given response data (y1 yn)

usually by minimizing an objective function (also called a costfunction or error function or loss function)

Regression and classification involve supervised learning

In contrast for unsupervised learning only input data are providedand the model discovers the natural patterns or structure in theinput data Principal component analysis and clustering involveunsupervised learning

With discrete variables classification is supervised while clusteringis unsupervised

54 K-means clustering [Book Sec17]

2 15

Clustering or cluster analysis is the unsupervised version ofclassification The goal of clustering is to group the data into anumber of subsets or lsquoclustersrsquo such that the data within a clusterare more closely related to each other than data from other clusters

A simple and widely used clustering method is K-means clusteringStart with initial guesses for the mean positions of the K clusters indata space (to be referred to as the cluster centres) then iteratesthe following two steps till convergence

(i) For each data point find the closest cluster centre (based onEuclidean distance)

(ii) For each cluster reassign the cluster centre to be the meanposition of all the data belonging to that cluster

3 15

0 05 1minus02

0

02

04

06(a) Iteration = 0

x1

x 20 05 1

minus02

minus01

0

01

02

03

04

05(b) Iteration = 1

x1

x 20 05 1

minus02

minus01

0

01

02

03

04

05(c) Iteration = 2

x1

x 2

0 05 1minus02

minus01

0

01

02

03

04

05(d) Iteration = 3

x1

x 2

Figure (a) The initial guesses for the two cluster centres are marked bythe asterisk and the circled asterisk The data points closest to the

4 15

asterisk are plotted as dots while those closest to the circled asterisk areshown as circles The location of the cluster centres and their associatedclusters are shown after (b) one (c) two (d) three iterations

As K the number of clusters is specified by the user choosing adifferent K will lead to very different clusters Trouble is we donrsquotknow what the optimal K value to use

55 Hierarchical clustering

Hierarchical clustering allows clusters to be nested inside each otherie one cluster branching into two smaller clusters leading to antree structureTwo approaches to constructing the tree bottom-up (agglomerativeclustering) or top-down (divisive clustering) In the more common

5 15

bottom-up approach the most similar clusters are merged at eachstep while in the top-down approach clusters are split up

Given N data points agglomerative clustering starts with Nclusters each containing one data point At each step it merges thetwo most ldquosimilarrdquo clusters into one cluster Many ways to defineldquosimilarrdquo so many variants of this method

Merging process can be plotted as an inverted tree a dendrogramInitial clusters are the leaves at the bottom and the binary branchingnode in the tree indicates where two clusters are merged togetherFor a branching node the vertical scale gives the distance ordissimilarity between the two clusters which are being merged [Thereason we can plot an inverted tree is because the distance betweentwo merged clusters increases monotonically as the merging processcontinues]

6 15

Example Use satellite data to forecast Canadian Prairie crop yieldwith yield data available at 40 Census Agricultural Regions (CAR)(Johnson 2013)Since data record is short (2000ndash2011) and there are 40 CARscluster the yield data from the 40 CARs so build fewer models butwith more training data for each model

Since there are 12 annual values at each CAR clustering is done for40 data points in 12-dimensional space

We can cut the tree at a selected height to choose the number ofclusters ndash somewhat subjectiveCan probably cut when vertical link distances become relativelysmall further down in the inverted tree

7 15

Figure Dendrogram for Canadian prairie (a) barley (b) canola and (c)spring wheat from various regions (with Wardrsquos method used)

8 15

(a) Barley vertical link distances becomes much smaller after 2clusters and again after 4 clusters so choose 2-4 clusters(b) Canola link distances become small after 5 clusters so choose 5clusters(c) Spring wheat smaller distances after 3 clusters and again after 5clusters so choose 3-5 clusters

9 15

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 2: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

The model learning is ldquosupervisedrdquo in that the model output(yprime

1 yprimen) is guided towards the given response data (y1 yn)

usually by minimizing an objective function (also called a costfunction or error function or loss function)

Regression and classification involve supervised learning

In contrast for unsupervised learning only input data are providedand the model discovers the natural patterns or structure in theinput data Principal component analysis and clustering involveunsupervised learning

With discrete variables classification is supervised while clusteringis unsupervised

54 K-means clustering [Book Sec17]

2 15

Clustering or cluster analysis is the unsupervised version ofclassification The goal of clustering is to group the data into anumber of subsets or lsquoclustersrsquo such that the data within a clusterare more closely related to each other than data from other clusters

A simple and widely used clustering method is K-means clusteringStart with initial guesses for the mean positions of the K clusters indata space (to be referred to as the cluster centres) then iteratesthe following two steps till convergence

(i) For each data point find the closest cluster centre (based onEuclidean distance)

(ii) For each cluster reassign the cluster centre to be the meanposition of all the data belonging to that cluster

3 15

0 05 1minus02

0

02

04

06(a) Iteration = 0

x1

x 20 05 1

minus02

minus01

0

01

02

03

04

05(b) Iteration = 1

x1

x 20 05 1

minus02

minus01

0

01

02

03

04

05(c) Iteration = 2

x1

x 2

0 05 1minus02

minus01

0

01

02

03

04

05(d) Iteration = 3

x1

x 2

Figure (a) The initial guesses for the two cluster centres are marked bythe asterisk and the circled asterisk The data points closest to the

4 15

asterisk are plotted as dots while those closest to the circled asterisk areshown as circles The location of the cluster centres and their associatedclusters are shown after (b) one (c) two (d) three iterations

As K the number of clusters is specified by the user choosing adifferent K will lead to very different clusters Trouble is we donrsquotknow what the optimal K value to use

55 Hierarchical clustering

Hierarchical clustering allows clusters to be nested inside each otherie one cluster branching into two smaller clusters leading to antree structureTwo approaches to constructing the tree bottom-up (agglomerativeclustering) or top-down (divisive clustering) In the more common

5 15

bottom-up approach the most similar clusters are merged at eachstep while in the top-down approach clusters are split up

Given N data points agglomerative clustering starts with Nclusters each containing one data point At each step it merges thetwo most ldquosimilarrdquo clusters into one cluster Many ways to defineldquosimilarrdquo so many variants of this method

Merging process can be plotted as an inverted tree a dendrogramInitial clusters are the leaves at the bottom and the binary branchingnode in the tree indicates where two clusters are merged togetherFor a branching node the vertical scale gives the distance ordissimilarity between the two clusters which are being merged [Thereason we can plot an inverted tree is because the distance betweentwo merged clusters increases monotonically as the merging processcontinues]

6 15

Example Use satellite data to forecast Canadian Prairie crop yieldwith yield data available at 40 Census Agricultural Regions (CAR)(Johnson 2013)Since data record is short (2000ndash2011) and there are 40 CARscluster the yield data from the 40 CARs so build fewer models butwith more training data for each model

Since there are 12 annual values at each CAR clustering is done for40 data points in 12-dimensional space

We can cut the tree at a selected height to choose the number ofclusters ndash somewhat subjectiveCan probably cut when vertical link distances become relativelysmall further down in the inverted tree

7 15

Figure Dendrogram for Canadian prairie (a) barley (b) canola and (c)spring wheat from various regions (with Wardrsquos method used)

8 15

(a) Barley vertical link distances becomes much smaller after 2clusters and again after 4 clusters so choose 2-4 clusters(b) Canola link distances become small after 5 clusters so choose 5clusters(c) Spring wheat smaller distances after 3 clusters and again after 5clusters so choose 3-5 clusters

9 15

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 3: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

Clustering or cluster analysis is the unsupervised version ofclassification The goal of clustering is to group the data into anumber of subsets or lsquoclustersrsquo such that the data within a clusterare more closely related to each other than data from other clusters

A simple and widely used clustering method is K-means clusteringStart with initial guesses for the mean positions of the K clusters indata space (to be referred to as the cluster centres) then iteratesthe following two steps till convergence

(i) For each data point find the closest cluster centre (based onEuclidean distance)

(ii) For each cluster reassign the cluster centre to be the meanposition of all the data belonging to that cluster

3 15

0 05 1minus02

0

02

04

06(a) Iteration = 0

x1

x 20 05 1

minus02

minus01

0

01

02

03

04

05(b) Iteration = 1

x1

x 20 05 1

minus02

minus01

0

01

02

03

04

05(c) Iteration = 2

x1

x 2

0 05 1minus02

minus01

0

01

02

03

04

05(d) Iteration = 3

x1

x 2

Figure (a) The initial guesses for the two cluster centres are marked bythe asterisk and the circled asterisk The data points closest to the

4 15

asterisk are plotted as dots while those closest to the circled asterisk areshown as circles The location of the cluster centres and their associatedclusters are shown after (b) one (c) two (d) three iterations

As K the number of clusters is specified by the user choosing adifferent K will lead to very different clusters Trouble is we donrsquotknow what the optimal K value to use

55 Hierarchical clustering

Hierarchical clustering allows clusters to be nested inside each otherie one cluster branching into two smaller clusters leading to antree structureTwo approaches to constructing the tree bottom-up (agglomerativeclustering) or top-down (divisive clustering) In the more common

5 15

bottom-up approach the most similar clusters are merged at eachstep while in the top-down approach clusters are split up

Given N data points agglomerative clustering starts with Nclusters each containing one data point At each step it merges thetwo most ldquosimilarrdquo clusters into one cluster Many ways to defineldquosimilarrdquo so many variants of this method

Merging process can be plotted as an inverted tree a dendrogramInitial clusters are the leaves at the bottom and the binary branchingnode in the tree indicates where two clusters are merged togetherFor a branching node the vertical scale gives the distance ordissimilarity between the two clusters which are being merged [Thereason we can plot an inverted tree is because the distance betweentwo merged clusters increases monotonically as the merging processcontinues]

6 15

Example Use satellite data to forecast Canadian Prairie crop yieldwith yield data available at 40 Census Agricultural Regions (CAR)(Johnson 2013)Since data record is short (2000ndash2011) and there are 40 CARscluster the yield data from the 40 CARs so build fewer models butwith more training data for each model

Since there are 12 annual values at each CAR clustering is done for40 data points in 12-dimensional space

We can cut the tree at a selected height to choose the number ofclusters ndash somewhat subjectiveCan probably cut when vertical link distances become relativelysmall further down in the inverted tree

7 15

Figure Dendrogram for Canadian prairie (a) barley (b) canola and (c)spring wheat from various regions (with Wardrsquos method used)

8 15

(a) Barley vertical link distances becomes much smaller after 2clusters and again after 4 clusters so choose 2-4 clusters(b) Canola link distances become small after 5 clusters so choose 5clusters(c) Spring wheat smaller distances after 3 clusters and again after 5clusters so choose 3-5 clusters

9 15

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 4: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

0 05 1minus02

0

02

04

06(a) Iteration = 0

x1

x 20 05 1

minus02

minus01

0

01

02

03

04

05(b) Iteration = 1

x1

x 20 05 1

minus02

minus01

0

01

02

03

04

05(c) Iteration = 2

x1

x 2

0 05 1minus02

minus01

0

01

02

03

04

05(d) Iteration = 3

x1

x 2

Figure (a) The initial guesses for the two cluster centres are marked bythe asterisk and the circled asterisk The data points closest to the

4 15

asterisk are plotted as dots while those closest to the circled asterisk areshown as circles The location of the cluster centres and their associatedclusters are shown after (b) one (c) two (d) three iterations

As K the number of clusters is specified by the user choosing adifferent K will lead to very different clusters Trouble is we donrsquotknow what the optimal K value to use

55 Hierarchical clustering

Hierarchical clustering allows clusters to be nested inside each otherie one cluster branching into two smaller clusters leading to antree structureTwo approaches to constructing the tree bottom-up (agglomerativeclustering) or top-down (divisive clustering) In the more common

5 15

bottom-up approach the most similar clusters are merged at eachstep while in the top-down approach clusters are split up

Given N data points agglomerative clustering starts with Nclusters each containing one data point At each step it merges thetwo most ldquosimilarrdquo clusters into one cluster Many ways to defineldquosimilarrdquo so many variants of this method

Merging process can be plotted as an inverted tree a dendrogramInitial clusters are the leaves at the bottom and the binary branchingnode in the tree indicates where two clusters are merged togetherFor a branching node the vertical scale gives the distance ordissimilarity between the two clusters which are being merged [Thereason we can plot an inverted tree is because the distance betweentwo merged clusters increases monotonically as the merging processcontinues]

6 15

Example Use satellite data to forecast Canadian Prairie crop yieldwith yield data available at 40 Census Agricultural Regions (CAR)(Johnson 2013)Since data record is short (2000ndash2011) and there are 40 CARscluster the yield data from the 40 CARs so build fewer models butwith more training data for each model

Since there are 12 annual values at each CAR clustering is done for40 data points in 12-dimensional space

We can cut the tree at a selected height to choose the number ofclusters ndash somewhat subjectiveCan probably cut when vertical link distances become relativelysmall further down in the inverted tree

7 15

Figure Dendrogram for Canadian prairie (a) barley (b) canola and (c)spring wheat from various regions (with Wardrsquos method used)

8 15

(a) Barley vertical link distances becomes much smaller after 2clusters and again after 4 clusters so choose 2-4 clusters(b) Canola link distances become small after 5 clusters so choose 5clusters(c) Spring wheat smaller distances after 3 clusters and again after 5clusters so choose 3-5 clusters

9 15

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 5: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

asterisk are plotted as dots while those closest to the circled asterisk areshown as circles The location of the cluster centres and their associatedclusters are shown after (b) one (c) two (d) three iterations

As K the number of clusters is specified by the user choosing adifferent K will lead to very different clusters Trouble is we donrsquotknow what the optimal K value to use

55 Hierarchical clustering

Hierarchical clustering allows clusters to be nested inside each otherie one cluster branching into two smaller clusters leading to antree structureTwo approaches to constructing the tree bottom-up (agglomerativeclustering) or top-down (divisive clustering) In the more common

5 15

bottom-up approach the most similar clusters are merged at eachstep while in the top-down approach clusters are split up

Given N data points agglomerative clustering starts with Nclusters each containing one data point At each step it merges thetwo most ldquosimilarrdquo clusters into one cluster Many ways to defineldquosimilarrdquo so many variants of this method

Merging process can be plotted as an inverted tree a dendrogramInitial clusters are the leaves at the bottom and the binary branchingnode in the tree indicates where two clusters are merged togetherFor a branching node the vertical scale gives the distance ordissimilarity between the two clusters which are being merged [Thereason we can plot an inverted tree is because the distance betweentwo merged clusters increases monotonically as the merging processcontinues]

6 15

Example Use satellite data to forecast Canadian Prairie crop yieldwith yield data available at 40 Census Agricultural Regions (CAR)(Johnson 2013)Since data record is short (2000ndash2011) and there are 40 CARscluster the yield data from the 40 CARs so build fewer models butwith more training data for each model

Since there are 12 annual values at each CAR clustering is done for40 data points in 12-dimensional space

We can cut the tree at a selected height to choose the number ofclusters ndash somewhat subjectiveCan probably cut when vertical link distances become relativelysmall further down in the inverted tree

7 15

Figure Dendrogram for Canadian prairie (a) barley (b) canola and (c)spring wheat from various regions (with Wardrsquos method used)

8 15

(a) Barley vertical link distances becomes much smaller after 2clusters and again after 4 clusters so choose 2-4 clusters(b) Canola link distances become small after 5 clusters so choose 5clusters(c) Spring wheat smaller distances after 3 clusters and again after 5clusters so choose 3-5 clusters

9 15

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 6: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

bottom-up approach the most similar clusters are merged at eachstep while in the top-down approach clusters are split up

Given N data points agglomerative clustering starts with Nclusters each containing one data point At each step it merges thetwo most ldquosimilarrdquo clusters into one cluster Many ways to defineldquosimilarrdquo so many variants of this method

Merging process can be plotted as an inverted tree a dendrogramInitial clusters are the leaves at the bottom and the binary branchingnode in the tree indicates where two clusters are merged togetherFor a branching node the vertical scale gives the distance ordissimilarity between the two clusters which are being merged [Thereason we can plot an inverted tree is because the distance betweentwo merged clusters increases monotonically as the merging processcontinues]

6 15

Example Use satellite data to forecast Canadian Prairie crop yieldwith yield data available at 40 Census Agricultural Regions (CAR)(Johnson 2013)Since data record is short (2000ndash2011) and there are 40 CARscluster the yield data from the 40 CARs so build fewer models butwith more training data for each model

Since there are 12 annual values at each CAR clustering is done for40 data points in 12-dimensional space

We can cut the tree at a selected height to choose the number ofclusters ndash somewhat subjectiveCan probably cut when vertical link distances become relativelysmall further down in the inverted tree

7 15

Figure Dendrogram for Canadian prairie (a) barley (b) canola and (c)spring wheat from various regions (with Wardrsquos method used)

8 15

(a) Barley vertical link distances becomes much smaller after 2clusters and again after 4 clusters so choose 2-4 clusters(b) Canola link distances become small after 5 clusters so choose 5clusters(c) Spring wheat smaller distances after 3 clusters and again after 5clusters so choose 3-5 clusters

9 15

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 7: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

Example Use satellite data to forecast Canadian Prairie crop yieldwith yield data available at 40 Census Agricultural Regions (CAR)(Johnson 2013)Since data record is short (2000ndash2011) and there are 40 CARscluster the yield data from the 40 CARs so build fewer models butwith more training data for each model

Since there are 12 annual values at each CAR clustering is done for40 data points in 12-dimensional space

We can cut the tree at a selected height to choose the number ofclusters ndash somewhat subjectiveCan probably cut when vertical link distances become relativelysmall further down in the inverted tree

7 15

Figure Dendrogram for Canadian prairie (a) barley (b) canola and (c)spring wheat from various regions (with Wardrsquos method used)

8 15

(a) Barley vertical link distances becomes much smaller after 2clusters and again after 4 clusters so choose 2-4 clusters(b) Canola link distances become small after 5 clusters so choose 5clusters(c) Spring wheat smaller distances after 3 clusters and again after 5clusters so choose 3-5 clusters

9 15

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 8: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

Figure Dendrogram for Canadian prairie (a) barley (b) canola and (c)spring wheat from various regions (with Wardrsquos method used)

8 15

(a) Barley vertical link distances becomes much smaller after 2clusters and again after 4 clusters so choose 2-4 clusters(b) Canola link distances become small after 5 clusters so choose 5clusters(c) Spring wheat smaller distances after 3 clusters and again after 5clusters so choose 3-5 clusters

9 15

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 9: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

(a) Barley vertical link distances becomes much smaller after 2clusters and again after 4 clusters so choose 2-4 clusters(b) Canola link distances become small after 5 clusters so choose 5clusters(c) Spring wheat smaller distances after 3 clusters and again after 5clusters so choose 3-5 clusters

9 15

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 10: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

43

Figure 51 Grouping of CARs from hierarchical clustering model based on barley and by agro-climatic zones

Figure Barley yield clustered in (a) 2 (b) 3 (c) 4 and (d) 5 clusters

10 15

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 11: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

Many ways to define ldquodistancerdquo or dissimilarity between two clustersThe average link clustering method measures the average distancebetween all pairs of data points in the two clusters A and B

dave(AB) =1

nAnB

sumiisinA

sumjisinB

dij (1)

where nA and nB are the number of data points in cluster A and B and dij is the distance between the data points i and j A variety of choices for dij eg Eucidean distance etc

Other link approaches eg single link complete link are generallynot as good as average link

11 15

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 12: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

Gong and Richman (1995) Best hierarchical clustering method isthe Wardrsquos method though some non-hierarchical methods can bebetter

Wardrsquos method At each step find the pair of clusters that leads tominimum increase in total within-cluster variance after merging

Q4 Hierarchical clustering analysis (using Wardrsquos method) wasapplied to a dataset containing the concentration of 11 ions in thehoney from 44 locations in Europe (Fermo et al 2013) How manyclusters for the locations appear optimal

12 15

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 13: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

levels of SO42 and PO4

3were significantly higher than in Italy SO42

903 603 ppm in Balkan honeys and 296 208 ppm in Italianhoneys (P lt 005) PO4

3 7726 5303 ppm in Balkan honeys and2220 742 ppm in Italian honeys (P lt 0005) The same trendthough not statistically significant was seen for floral nectar hon-eys (Table 3)

These differences might reflect (i) anthropogenic activities esuch as environmental pollution from power plants (SO4

2) (Uumlrenet al 1998) andor agricultural work (PO4

3) e or (ii) the differentgeology of the Balkan region or both factors

The presence of sulphate may be linked to i) its geologicalorigin (soil and rocks) ii) SO4

2 generation by atmospheric

Srb7

Srb6

Srb5

Srb4

Srb1

Srb2

Kos5

Alb4

Alb2

Alb1 It4

8Sr

b3 It2 It7Ko

s4Ko

s1 It11 It3

Alb7 It4

Mak

2Bo

s1Al

b5 It14

Mak

1Ko

s2 It5 It37 It1

Alb6

Kos7 It46 It6

Kos3

Cro2 It3

3Sl

o2Al

b8Al

b3Cr

o1 It45

Kos6

Srb9

Slo1

0

5

10

15

20

25

30

35

40

Dist

anza

Leg

ame

Fig 4 Dendrogram obtained from PCA (Wardrsquos method) of honey samples from Italy and from W Balkans

Fig 5 PCA scatter plot (PC2 vs PC3) obtained from the analysis of main ions contents for honeys from Italy and Western Balkans Sample Alb5 collected from a site near to the seaand characterized by a higher NaCl concentration (see the loading plot shown in the inset) is evidenced by an arrow

P Fermo et al Environmental Pollution 178 (2013) 173e181178

13 15

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 14: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

Matlab functions for clustering

K -means clusteringhttpwwwmathworkscomhelpstatskmeanshtml

Hierarchical clusteringhttpwwwmathworkscomhelpstats

hierarchical-clusteringhtmlbq_679x-10

httpwwwmathworkscomhelpstatslinkagehtml

For method choose rsquowardrsquo (best) or rsquoaveragersquo The default rsquosinglersquois poor IeY = pdist(X) calculates pairs of distances from data matrix XZ = linkage(Y rsquowardrsquo) cluster using Wardrsquos methoddendrogram(Z) plots dendrogram (up to 30 nodes)dendrogram(Z0) plots dendrogram (all nodes)

14 15

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15

Page 15: supervised unsupervised - University of British Columbiawilliam/EOSC510/Ch5/Ch5b.pdfSrb7 Srb6 Srb5 Srb4 Srb1 Srb2 Kos5 Alb4 Alb2 Alb1 It48 Srb3 It2 It7 Kos4 Kos1 It11 It3 Alb7 It4

References

Fermo P Beretta G Facino R M Gelmini F and PiazzalungaA (2013) Ionic profile of honey as a potential indicator ofbotanical origin and global environmental pollutionEnvironmental Pollution 178173ndash81

Gong X F and Richman M B (1995) On the application ofcluster-analysis to growing-season precipitation data inNorth-America east of the Rockies J Climate 8(4)897ndash931

Johnson M D (2013) Crop Yield Forecasting on the CanadianPrairies by Satellite Data and Machine Learning MSc thesisUniv of British Columbia

15 15