-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial.Rmd
More file actions
97 lines (79 loc) · 1.94 KB
/
tutorial.Rmd
File metadata and controls
97 lines (79 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
title: "Tutorial"
author: "Rémi Decoster, Pauline Laine, Romain Pic"
date: "08/12/2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Réalisation d'un clustering k-means
```{r}
library(ClusterCharPlot)
library(readxl)
library(stats)
```
```{r}
df<- read_excel('Autos.xlsx')
X<-df[,c('length','width','height','engine-size','compression-ratio','horsepower','city-mpg','highway-mpg')]
clus<- kmeans(X,3)
y <-clus$cluster
```
## Caractérisation univarié
```{r}
#Création de l'objet de la classe UniChar à partir de notre jeu de données complet
obj <- Perform_UniChar(df,y)
plot(obj)
```
```{r}
#Analyse pour les données qualitative
vCramer <- vcramer.UniChar(obj,y)
print(vCramer)
vCramer["label"] <- obj$catnames
colnames(vCramer[1])
barplt.UniChar(obj, vCramer, TRUE)
vtest.UniChar(obj,y, 'make')
#unable to plot yet
```
```{r}
#Analyse pour les données
#Correlation, caracterisation des partitions
cor <- correlation(obj,y)
print(cor)
#Barplot de la correlation
tmp <- as.data.frame(cor)
(correlations <- t(tmp[4,]))
ClusterCharPlot::barplt.UniChar(obj, correlations)
```
```{r}
#Valeur test, caracterisation des groupes
vt <- valuetest(obj,y)
print(vt)
radar(vt)
```
```{r}
#Effect size, caracterisation des groupes
es <- effectsize(obj,y)
print(es)
radar(es)
```
## Carastérisation multivarié
```{r}
#Création de l'objet multivarié
multivariate=multivariate_charac(X,y)
#Printing and plotting the results of multivariate_charac
print(multivariate$distance_matrix)
print(multivariate$confusion_matrix)
print(multivariate$correlation)
print(multivariate$squared_correlation)
plot(multivariate$correlation)
```
## Calcul des mesures
```{r}
#Création de l'objet
measures=indexes(X,y)
#Printing and plotting the results of indexes
print(measures$internal)
print(measures$external)
plot(measures)
```