HCPC Exemple

Statistical Analysis, Clustering, Data Visualization · lab

Voir tous les documents en intelligence artificielle et données

HCPC Exemple

T.Mellah

5/12/2018

Contents

1 Présentation de la Base de données

1.1 Résumé statistique des données . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2 Classification hierarchique sur composantes principales (HCPC)

2.1 Preprocessing: analyse en composantes principales . . . . . . . . . . . . . . . . . . . . . . . .

2.2 Clustering sur les outputs de l’ACP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.3 Représentation graphique des résultats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Indicateurs numériques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.4

1

2

2

2

4

5

6

Dans cet exemple, nous étudions le climat de diérents pays européens. Pour ce faire, les températures (en

degrés Celsius) ont été collectées mensuellement pour les principales capitales européennes et autres grandes

villes. En plus des températures mensuelles, la température annuelle moyenne et l’amplitude thermique

(diérence entre la moyenne mensuelle maximale et la moyenne mensuelle minimale d’une ville) ont été

enregistrées pour chaque ville. Nous incluons également deux variables quantitatives de positionnement

(latitude et longitude) ainsi qu’une variable catégorique: Zone (variable catégorique avec les quatre catégories

nord, sud, est et ouest de l’Europe).

L’objectif de cette analyse est de regrouper les capitales dans des classes afin que les villes d’une classe donnée

présentent toutes des températures similaires toute l’année.

On décrit les classes ainsi définies à l’aide de variables ou d’individus spécifiques. Pour déterminer le nombre

de clusters, on construit un arbre, selon une classification hiérarchique ascendante.

Une présentation détaillée de l’analyse de cette base par la méthode de HCPC est donnée par Husson, F.,

Josse, J., & Pages, J. (2010). Principal component methods-hierarchical clustering-partitional clustering: why

would we need to choose for visualizing data. Applied Mathematics Department.

1 Présentation de la Base de données

data.frame:

$ January

: num

$ February : num

: num

$ March

: num

$ April

: num

$ May

: num

$ June

: num

$ July

: num

$ August

$ September: num

$ October

: num

$ November : num

$ December : num

: num

$ Annual

$ Amplitude: num

$ Latitude : num

35 obs. of 17 variables:

2.9 9.1 -0.2 3.3 -1.1 -0.4 4.8 -5.8 -5.9 -3.7 ...

2.5 9.7 0.1 3.3 0.8 -0.4 5 -6.2 -5 -2 ...

5.7 11.7 4.4 6.7 5.5 1.3 5.9 -2.7 -0.3 1.9 ...

8.2 15.4 8.2 8.9 11.6 5.8 7.8 3.1 7.4 7.9 ...

12.5 20.1 13.8 12.8 17 11.1 10.4 10.2 14.3 13.2 ...

14.8 24.5 16 15.6 20.2 15.4 13.3 14 17.8 16.9 ...

17.1 27.4 18.3 17.8 22 17.1 15 17.2 19.4 18.4 ...

17.1 27.2 18 17.8 21.3 16.6 14.6 14.9 18.5 17.6 ...

14.5 23.8 14.4 15 16.9 13.3 12.7 9.7 13.7 13.7 ...

11.4 19.2 10 11.1 11.3 8.8 9.7 5.2 7.5 8.6 ...

7 14.6 4.2 6.7 5.1 4.1 6.7 0.1 1.2 2.6 ...

4.4 11 1.2 4.4 0.7 1.3 5.4 -2.3 -3.6 -1.7 ...

9.9 17.8 9.1 10.3 10.9 7.8 9.3 4.8 7.1 7.7 ...

14.6 18.3 18.5 14.4 23.1 17.5 10.2 23.4 25.3 22.1 ...

52.2 37.6 52.3 50.5 47.3 55.4 53.2 60.1 50.3 50 ...

1

$ Longitude: num

$ Area

4.5 23.5 13.2 4.2 19 12.3 6.1 25 30.3 19.6 ...

: Factor w/ 4 levels "East","North",..: 4 3 4 4 1 2 2 2 1 1 ...

1.1 Résumé statistique des données

February

Min.

:-7.900

1st Qu.:-0.150

Median : 1.900

Mean

: 2.217

3rd Qu.: 5.800

:11.800

Max.

March

Min.

:-3.700

1st Qu.: 1.600

Median : 5.400

Mean

: 5.229

3rd Qu.: 8.500

:14.100

Max.

April

Min.

: 2.900

1st Qu.: 7.250

Median : 8.900

Mean

: 9.283

3rd Qu.:12.050

:16.900

Max.

June

Min.

: 9.30

1st Qu.:15.40

Median :16.90

:17.41

Mean

3rd Qu.:19.80

:24.50

Max.

October

: 4.50

Min.

1st Qu.: 8.65

Median :10.20

Mean

:11.00

3rd Qu.:13.30

:19.40

Max.

Amplitude

Min.

:10.20

1st Qu.:14.90

Median :18.50

Mean

:18.32

3rd Qu.:21.45

:27.60

Max.

July

Min.

:11.10

1st Qu.:17.30

Median :18.90

:19.62

Mean

3rd Qu.:21.75

:27.40

Max.

November

:-1.100

Min.

1st Qu.: 3.200

Median : 5.100

Mean

: 6.066

3rd Qu.: 7.900

:14.900

Max.

Latitude

Min.

:37.20

1st Qu.:43.90

Median :50.00

Mean

:49.04

3rd Qu.:53.35

:64.10

Max.

August

Min.

:10.60

1st Qu.:16.65

Median :18.30

:18.98

Mean

3rd Qu.:21.60

:27.20

Max.

December

:-6.00

Min.

1st Qu.: 0.25

Median : 1.70

Mean

: 2.88

3rd Qu.: 5.40

:12.00

Max.

Longitude

Min.

: 0.00

1st Qu.: 5.05

Median :10.50

Mean

:13.01

3rd Qu.:19.30

:37.60

Max.

May

January

September

##

Min.

:-9.300

1st Qu.:-1.550

Median : 0.200

Mean

: 1.346

3rd Qu.: 4.900

Max.

:10.700

##

Min.

: 6.50

1st Qu.:12.15

Median :13.80

:13.91

Mean

3rd Qu.:16.35

Max.

:20.90

##

: 7.90

Min.

1st Qu.:13.00

Median :14.80

Mean

:15.63

3rd Qu.:18.25

Max.

:24.30

##

Min.

: 4.50

1st Qu.: 7.75

Median : 9.70

Mean

:10.27

3rd Qu.:12.65

Max.

:18.20

##

East : 8

North: 8

South:10

West : 9

##

##

Annual

Publicité

Area

2 Classification hierarchique sur composantes principales (HCPC)

2.1 Preprocessing: analyse en composantes principales

##

Call:

PCA(X = temperature[1:23, ], scale.unit = TRUE, ncp = Inf, quanti.sup = 13:16,

##

##

##

quali.sup = 17, graph = FALSE)

2

Dim.1

9.948

Dim.2

1.848

82.898 15.397

82.898 98.295

Dim.8

0.002

0.017

99.961 99.978

Dim.7

0.006

0.049

Dim.3

0.126

1.052

Dim.4

0.038

0.319

99.347 99.666

Dim.9

0.001

0.009

0.001

0.008

99.986 99.994

Dim.5

0.017

0.139

Dim.6

0.013

0.107

99.805 99.912

Dim.10 Dim.11 Dim.12

0.000

0.001

0.001

0.004

99.999 100.000

ctr

cos2

cos2

Dim.2

Dim.1

ctr

0.025 | -1.371 4.426 0.904 |

0.227 0.023

0.930 2.037 0.015 |

7.601 25.249 0.978 |

0.328 |

0.001 0.001 |

0.016

0.216 | -1.177 3.261 0.753 |

0.463 |

6.903 0.489 |

0.806 | -0.492 0.570 0.091 |

0.034 | -2.673 16.819 0.955 |

0.502 0.013 |

0.957 |

9.484 0.574 |

0.417 |

1.802 0.312 |

0.645 |

| 1.443 |

| 7.684 |

| 0.503 | -0.288 0.036

0.631 0.174

| 1.357 |

| 2.450 |

1.668 1.216

| 1.629 | -1.462 0.935

| 2.736 | -0.505 0.112

| 4.127 | -4.036 7.121

| 2.650 | -1.712 1.281

| 1.567 | -1.259 0.692

ctr

-0.104 0.375

0.462

2.008

0.875

1.713

Dist

Dim.3

Eigenvalues

##

Variance

% of var.

Cumulative % of var.

##

Variance

% of var.

Cumulative % of var.

##

Individuals (the 10 first)

##

Amsterdam

Athens

Berlin

Brussels

Budapest

Copenhagen

Dublin

Elsinki

Kiev

Krakow

##

Amsterdam

Athens

Berlin

Brussels

Budapest

Copenhagen

Dublin

Elsinki

Kiev

Krakow

##

Variables (the 10 first)

##

January

February

March

April

May

June

July

August

September

October

##

January

February

March

April

May

June

July

Dim.1

| 0.842

| 0.884

| 0.945

| 0.974

| 0.870

| 0.833

| 0.844

| 0.909

| 0.986

| 0.992

cos2

0.005 |

0.000 |

0.015 |

0.039 |

0.024 |

0.002 |

0.024 |

-0.291

-0.152 0.796

-0.499 8.574

0.440 6.678

-0.171

-0.274

-0.179

cos2

0.005 |

0.561 10.855 0.005 |

2.908 0.334 |

0.013 |

0.041 |

0.073 |

1.097 0.004 |

0.593 12.117 0.021 |

1.003 0.004 |

2.585 0.031 |

ctr

cos2

cos2

Dim.3

Dim.2

ctr

ctr

0.282 | 0.068 3.637

7.135 0.710 | -0.531 15.281

0.782 | -0.456 11.246 0.208 | -0.003 0.010

7.861

4.468 0.083 | -0.121 11.557

8.978 0.893 | -0.287

9.534 0.948 | 0.100 0.537

0.010 | -0.198 31.132

7.606 0.757 | 0.458 11.344 0.210 | -0.156 19.296

6.981 0.694 | 0.545 16.095 0.297 | 0.050 1.944

7.164 0.713 | 0.509 14.004 0.259 | 0.154 18.708

0.162 | 0.088 6.064

8.311 0.827 | 0.402 8.743

1.259

9.766

0.023 | 0.023 0.405

0.153

0.971 |

0.389 0.007 | 0.000 0.000

9.885 0.983 | -0.085

3

cos2

0.008 |

0.001 |

0.000 |

Dim.1

| 0.998

| -0.314

| -0.910

| -0.364

August

September

October

##

Supplementary continuous variables

##

Annual

Amplitude

Latitude

Longitude

##

Supplementary categories

##

East

North

South

West

##

East

North

South

West

cos2 v.test

0.021 -2.246 |

0.010 2.346 |

0.001 0.804 |

0.025 -0.995 |

Dim.3

-0.257

0.269

Publicité

0.116

-0.164

Dim.1

Dist

cos2

Dim.2

0.995 | -0.068 0.005 |

0.099 | 0.944

0.892 |

0.828 | -0.215 0.046 |

0.133 | 0.645

Dim.3

0.005 0.000 |

0.039

0.002 |

0.182 0.033 |

0.416 | -0.036 0.001 |

cos2

cos2 v.test

| 1.784 | -1.099 0.380 -1.081 |

| 2.650 | -2.444 0.850 -2.404 | -0.988

| 4.566 |

0.137

| 1.032 |

Dim.2

1.380 0.599 3.150 |

0.139 -2.256 |

3.576 |

0.001 0.250 |

0.339 | -0.857 0.690 -1.358 |

4.562 0.998

0.497 0.232

cos2 v.test

2.2 Clustering sur les outputs de l’ACP

$tree

##

Call:

flashClust::hclust(d = dissi, method = method, members = weight)

##

Cluster method

Distance

Number of objects: 23

: ward

: euclidean

$nb.clust

[1] 3

$within

[1] 12.000000000

[6] 1.232214708

[11] 0.370631136

[16] 0.086935386

[21] 0.013934889

5.237349047 2.881145878 2.119286630 1.523668752

0.959979191 0.798661153 0.643435441 0.492720128

0.255438457 0.201557505 0.152512154 0.118340088

0.064962439 0.047549074 0.035692437 0.024106815

0.006904631

$inert.gain

[1] 6.762650953 2.356203170 0.761859247 0.595617878 0.291454044

[6] 0.272235517 0.161318038 0.155225712 0.150715314 0.122088991

[11] 0.115192679 0.053880952 0.049045351 0.034172066 0.031404701

[16] 0.021972947 0.017413366 0.011856636 0.011585622 0.010171927

[21] 0.007030258 0.006904631

$quot

4

[1] 0.5501153 0.7355707 0.7189536 0.8087156 0.7790681 0.8319567 0.8056426

[8] 0.7657647

2.3 Représentation graphique des résultats

Cluster Dendrogram

5.0

t

i

h

g

e

H

2.5

0.0

s

n

e

h

t

A

n

o

b

s

L

i

d

i

r

d

a

M

e

m

o

R

w

o

c

s

o

M

k

s

n

M

i

i

j

k

v

a

k

y

e

R

i

i

k

n

s

E

l

l

o

s

O

l

m

o

h

k

c

o

t

S

n

i

l

b

u

D

s

i

r

a

P

n

o

d

n

o

L

l

s

e

s

s

u

r

B

m

a

d

r

e

t

s

m

A

n

e

g

a

h

n

e

p

o

C

v

e

K

i

w

o

k

a

r

K

t

s

e

p

a

d

u

B

n

i

l

r

e

B

e

u

g

a

r

P

a

i

f

o

S

j

o

v

e

a

r

a

S

5

Cluster plot

Moscow

Kiev

Minsk

Budapest

Krakow

Sofia

Prague

Elsinki

Oslo

Stockholm

Sarajevo

Berlin

Copenhagen

Paris

Brussels

Amsterdam

London

Dublin

2

1

0

−1

−2

Publicité

)

%

4

.

5

1

(

2

m

D

i

Athens

Madrid

Rome

cluster

a

a

a

1

2

3

Lisbon

Reykjavik

−3

−5.0

−2.5

0.0

2.5

Dim1 (82.9%)

5.0

7.5

Hierarchical clustering on the factor map

t

h

g

e

h

i

7

6

5

4

3

2

1

0

cluster 1

cluster 2

cluster 3

−6

−4

Reykjavik

Moscow

Minsk

Elsinki

Oslo

Stockholm

−2

Kiev

Krakow

Sofia

Berlin Prague

Sarajevo

Copenhagen

BrusselsParis

Amsterdam

London

2

0

Dublin

Budapest

4

Madrid Rome

Lisbon

6

8

Dim 1 (82.9%)

−3−2−1 0 1 2 3

Athens

)

%

4

.

5

1

(

2

m

D

i

2.4 Indicateurs numériques

##

6

80

Eta2

Global

p.value

Cla/Mod Mod/Cla

p.value df

6

v.test

100 21.73913 0.0005646527 3.448048

Link between the cluster variable and the categorical variables (chi-square test)

=================================================================================

##

Area 0.001195843

##

Description of each cluster by the categories

=============================================

$1

NULL

##

$2

NULL

##

$3

##

Area=South

##

##

Link between the cluster variable and the quantitative variables

================================================================

P-value

##

0.9177156 1.422898e-11

Annual

0.8989724 1.107640e-10

October

0.8864732 3.556182e-10

March

November

0.8707485 1.301232e-09

September 0.8559706 3.841596e-09

0.8353281 1.466202e-08

April

0.8246130 2.754070e-08

February

0.7730136 3.630759e-07

December

0.7476664 1.046528e-06

January

0.7378117 1.535089e-06

Latitude

0.7159888 3.414722e-06

August

0.6309204 4.690301e-05

July

May

0.5860137 1.478632e-04

0.5752594 1.910900e-04

June

Longitude 0.3720657 9.531078e-03

##

Description of each cluster by quantitative variables

=====================================================

$1

##

3.173406

Latitude

2.858559

Longitude

2.142021

Amplitude

-1.994799

July

-2.058250

June

-2.479950

August

May

-2.549115

September -3.137128

-3.255703

January

-3.269173

December

-3.359278

November

-3.373602

Annual

-3.387118

April

v.test Mean in category Overall mean sd in category

4.2809974

8.1046220

4.8430889

2.4549824

2.5172061

2.2585890

2.4289075

1.6685568

2.6250753

1.8302448

0.9396048

0.7671841

1.5489298

50.2956522

15.4521739

18.8000000

18.9260870

16.7652174

18.3043478

13.2739130

14.7086957

0.1739130

1.8434783

5.0782609

9.3739130

8.3782609

57.485714

24.328571

21.985714

16.785714

14.728571

15.485714

10.842857

10.985714

-5.142857

-2.914286

0.600000

5.500000

4.671429

7

-4.600000

5.757143

-1.142857

0.9565217

10.0652174

4.0608696

2.3366643

0.9194053

1.1043513

p.value

7.029223 0.0015066157

9.633631 0.0042557039

4.614062 0.0321917637

3.328822 0.0460648072

3.069855 0.0395661536

3.526111 0.0131400659

2.958733 0.0107996531

3.681790 0.0017061164

5.066447 0.0011311207

4.515079 0.0010786223

4.135841 0.0007814643

3.562512 0.0007419150

3.395260 0.0007063103

5.008152 0.0005771764

3.869795 0.0005527723

4.392854 0.0002377646

Overall sd

-3.442119

-3.453788

Publicité

-3.675091

Overall sd

February

October

March

##

Latitude

Longitude

Amplitude

July

June

August

May

September

January

December

November

Annual

April

February

October

March

##

$2

##

Longitude -2.060647

##

Longitude

##

$3

##

Annual

September

October

August

November

July

April

March

February

June

December

January

May

Latitude

##

Annual

September

October

August

November

July

April

March

February

June

3.851788

3.808964

3.717610

3.705134

3.692832

3.603579

3.531688

3.448552

3.434969

3.389407

3.387321

3.292484

3.183059

-3.328226

Overall sd

v.test Mean in category Overall mean sd in category

7.449161

15.45217

11.4

p.value

9.633631 0.03933669

v.test Mean in category Overall mean sd in category

1.393736

1.536839

1.911151

1.883315

2.264260

2.089258

1.175798

1.274755

1.744276

1.864135

2.337199

2.076505

1.553222

1.523770

9.3739130

14.7086957

10.0652174

18.3043478

5.0782609

18.9260870

8.3782609

4.0608696

0.9565217

16.7652174

1.8434783

0.1739130

13.2739130

50.2956522

15.750

21.225

16.750

24.375

12.175

24.500

13.950

11.100

8.950

21.600

8.950

7.925

17.650

39.425

p.value

3.562512 0.0001172584

3.681790 0.0001395501

3.869795 0.0002011160

3.526111 0.0002112792

4.135841 0.0002217705

3.328822 0.0003138648

3.395260 0.0004129164

4.392854 0.0005636006

5.008152 0.0005926217

3.069855 0.0007004406

8

December

January

May

Latitude

4.515079 0.0007057887

5.066447 0.0009930662

2.958733 0.0014572796

7.029223 0.0008740097

v.test Mean in category Overall mean sd in category Overall sd

3.154005

9.98899e-16

##

Link between the cluster variable and the quantitative variables

================================================================

##

P-value

Eta2

Dim.1 0.9086821 4.032342e-11

Dim.3 0.2691961 4.345188e-02

##

Description of each cluster by quantitative variables

=====================================================

$1

##

Dim.1 -3.317358

p.value

##

Dim.1 0.0009087321

##

$2

##

Dim.3 -2.414108

##

p.value

Dim.3 0.01577378

##

$3

##

Dim.1 3.863084

##

p.value

Dim.1 0.0001119644

-3.372519

0.8494564

1.264335

v.test Mean in category Overall mean sd in category Overall sd

3.154005

5.661507 9.98899e-16

v.test Mean in category Overall mean sd in category Overall sd

0.2178523 0.3553249

-0.1750962 -2.289835e-16

Rome

Oslo

Minsk

Berlin

Brussels

Amsterdam

0.8838369

Elsinki Stockholm

Sarajevo

0.7163471

Prague

1.0377318 1.0555319 1.1242019

Moscow

0.9222205 0.9652667 1.7664186

$para

Cluster: 1

##

0.3393856

--------------------------------------------------------

Cluster: 2

##

0.5764625

--------------------------------------------------------

Cluster: 3

##

0.3598845 1.7370025 1.8352756 2.1670401

##

$dist

Cluster: 1

Reykjavik

##

--------------------------------------------------------

Cluster: 2

##

##

--------------------------------------------------------

Cluster: 3

Paris

4.381195

Brussels

4.352044

Moscow

4.339979

Dublin

4.284426

Elsinki

4.280308

Minsk

3.738541

Amsterdam

Budapest

4.374324

5.474055

4.077437

3.484728

Madrid

Lisbon

Athens

Oslo

9

Athens

7.665256 5.660918 5.350595 4.216158

Lisbon

Madrid

Rome

10