From: Jérôme Benoit Date: Tue, 13 Nov 2018 20:26:02 +0000 (+0100) Subject: Finish TP1 exo1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=5b0cb811ca7760eafcb3bae2de43ccb57690e848;p=TP_AA.git Finish TP1 exo1 Signed-off-by: Jérôme Benoit --- diff --git a/TP1/exo1/TP1prog1.py b/TP1/exo1/TP1prog1.py index f0e5324..9953cf7 100755 --- a/TP1/exo1/TP1prog1.py +++ b/TP1/exo1/TP1prog1.py @@ -9,17 +9,70 @@ irisData = load_iris() X = irisData.data Y = irisData.target +colors = ["red", "green", "blue"] + x = 0 y = 1 +for i in range(3): + pl.scatter(X[Y == i][:, x], X[Y == i][:, y], color=colors[i], + label=irisData.target_names[i]) +pl.legend() +pl.xlabel(irisData.feature_names[x]) +pl.ylabel(irisData.feature_names[y]) +pl.title(u"Données Iris - dimension des sépales uniquement") +pl.show() -colors = ["red", "green", "blue"] +x = 2 +y = 3 +for i in range(3): + pl.scatter(X[Y == i][:, x], X[Y == i][:, y], color=colors[i], + label=irisData.target_names[i]) +pl.legend() +pl.xlabel(irisData.feature_names[x]) +pl.ylabel(irisData.feature_names[y]) +pl.title(u"Données Iris - dimension des pétales uniquement") +pl.show() + +x = 0 +y = 3 +for i in range(3): + pl.scatter(X[Y == i][:, x], X[Y == i][:, y], color=colors[i], + label=irisData.target_names[i]) +pl.legend() +pl.xlabel(irisData.feature_names[x]) +pl.ylabel(irisData.feature_names[y]) +pl.title(u"Données Iris - dimension des sépales et pétales") +pl.show() + +x = 1 +y = 2 +for i in range(3): + pl.scatter(X[Y == i][:, x], X[Y == i][:, y], color=colors[i], + label=irisData.target_names[i]) +pl.legend() +pl.xlabel(irisData.feature_names[x]) +pl.ylabel(irisData.feature_names[y]) +pl.title(u"Données Iris - dimension des sépales et pétales") +pl.show() +x = 0 +y = 2 for i in range(3): pl.scatter(X[Y == i][:, x], X[Y == i][:, y], color=colors[i], label=irisData.target_names[i]) +pl.legend() +pl.xlabel(irisData.feature_names[x]) +pl.ylabel(irisData.feature_names[y]) +pl.title(u"Données Iris - dimension des sépales et pétales") +pl.show() +x = 1 +y = 3 +for i in range(3): + pl.scatter(X[Y == i][:, x], X[Y == i][:, y], color=colors[i], + label=irisData.target_names[i]) pl.legend() pl.xlabel(irisData.feature_names[x]) pl.ylabel(irisData.feature_names[y]) -pl.title(u"Données Iris - dimension des sépales uniquement") +pl.title(u"Données Iris - dimension des sépales et pétales") pl.show() diff --git a/TP1/exo1/iris4.py b/TP1/exo1/iris4.py index 6646561..ad61e2d 100755 --- a/TP1/exo1/iris4.py +++ b/TP1/exo1/iris4.py @@ -9,9 +9,9 @@ X = irisData.data Y = irisData.target x = 0 y = 1 -Y == 0 -X[Y == 0] -X[Y == 0][:, x] +print(Y == 0) +print(X[Y == 0]) +print(X[Y == 0][:, x]) pl.scatter(X[Y == 0][:, x], X[Y == 0][:, y], color="red", label=irisData.target_names[0]) pl.scatter(X[Y == 1][:, x], X[Y == 1][:, y],