Vous êtes sur la page 1sur 6

Compte rendu mini projet ML

Amir Rezgui

Mohamed Farouk Hamadi

Partie theorique:

A1 A2 A3 A4 Classe

A X 0 faux bien

A X 0 vrai bien

B X 0 faux trés bien

C Y 0 faux trés bien

C X 1 faux trés bien

B X 1 vrai trés bien

A Y 0 faux bien

A Y 1 faux trés bien

C Y 1 faux trés bien

A Y 1 vrai trés bien

B Y 0 vrai trés bien

B X 1 faux trés bien


Arbre de décision basé sur le calcul de l’indice de Gini:

IG(avant sep) = 1 - ((3/12)² + (9/12)²) = 1 - (0.0625 + 0.5625) = 1 - 0.625 = 0.375

IG(A1) = IG(avant sep) - (IG(A1=A) + IG(A1=B) + IG(A1=C))


= 0.375 - (0.48 + 0 + 0) = -0.105
IG(A1=A) = 1 - ((3/5)² + (2/5)²) = 0.48
IG(A1=B) = 1 - ((4/4)² + 0) = 0
IG(A1=C) = 1 - ((3/3)² + 0) = 0

IG(A2) = IG(avant sep) - (IG(A2=X) + IG(A2=Y))


= 0.375 - (0.27 + 0.44) = -0.335
IG(A2=X) = 1 - ((2/6)² + (4/6)²) = 0.44
IG(A2=Y) = 1 - ((1/6)² + (5/6)²) = 0.27

IG(A3) = IG(avant sep) - (IG(A3=0) + IG(A3=1))


= 0.375 - (0.5 + 0) = -0.125
IG(A3=0) = 1 - ((3/6)² + (3/6)²) = 0.5
IG(A3=1) = 1 - ((6/6)² + 0) = 0

IG(A4) = IG(avant sep) - (IG(A4=vrai) + IG(A4=faux))


= 0.375 - (0.375 + 0.375) = -0.375
IG(A4=vrai) = 1 - ((3/4)² + (1/4)²) = 0.375
IG(A4=faux) = 1 - ((6/8)² + (2/8)²) = 0.375

IG(A1) > IG(A3) > IG(A2) > IG(A4)


La meilleure variable descriptive, qui va être un nœud de division racine, est A1 avec IG = -0.105
A2 A3 A4 Classe

X 0 faux bien

X 0 vrai bien

Y 0 faux bien

Y 1 faux trés bien

Y 1 vrai trés bien

Indice de Gini avant sep:


IG(avant sep) = 1 - ((2/5)² + (3/5)²) = 1 - (0.16 + 0.36) = 1 - 0.52 = 0.48

IG(A2) = IG(avant sep) - (IG(A2=X) + IG(A2=Y)) = 0.48 - (0 + 0.44) = 0.04


IG(A2=X) = 1 - ((2/2)² + (0/2)²) = 0
IG(A2=Y) = 1 - ((1/3)² + (2/3)²) = 0.44

IG(A3) = IG(avant sep) - (IG(A3=0) + IG(A3=1)) = 0.48 - (0 + 0) = 0.48


IG(A3=0) = 1 - ((3/3)² + (0/3)²) = 0
IG(A3=1) = 1 - ((2/2)² + (0/2)²) = 0

IG(A4) = IG(avant sep) - (IG(A4=vrai) + IG(A4=faux)) = 0.48 - (0.44 + 0.5) = -0.46


IG(A4=faux) = 1 - ((1/3)² + (2/3)²) = 0.44
IG(A4=vrai) = 1 - ((1/2)² + (1/2)²) = 0.5

IG(A3) > IG(A2) > IG(A4)


La variable descriptive qui va occuper le nœud de séparation suivant est “A3”.
Il n’est pas nécessaire de passer à un nœud A2 ni A4 car le résultat est indépendant de ces
variables mais A3 uniquement .
Performing euclidean distance
calculations for the K-Nearest Neighbors
(KNN) section
A1 A2 A3 A4 Classe Distance

1 0 0 0 0 1

1 0 0 1 0 √2

2 0 0 0 1 √2

3 1 0 0 1 √6

3 0 1 0 1 2

2 0 1 1 1 √2

1 1 0 0 0 √2

1 1 1 0 1 1

3 1 1 0 1 √5

1 1 1 1 1 √2

2 1 0 1 1 2

2 0 1 0 1 1

1 0 1 0 ?

On applique KNN quand K = 2


A1 A2 A3 A4 Classe Distance

1 0 0 0 0 1

1 1 1 0 1 1

A1 A2 A3 A4 Classe Distance

1 0 1 0 Tres bien bien Same distance

4)

Pour l'arbre de décision utilisant le calcul de Gini, "très bien" est la prédiction résultante.
En ce qui concerne KNN, pour k = 2 où les distances sont identiques, le choix se situe
entre "très bien" ou "bien". En prenant en compte le vote majoritaire des modèles
appliqués, la classe déterminée est "très bien".

Vous aimerez peut-être aussi