From 5b0cb811ca7760eafcb3bae2de43ccb57690e848 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 13 Nov 2018 21:26:02 +0100 Subject: [PATCH] Finish TP1 exo1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- TP1/exo1/TP1prog1.py | 57 ++++++++++++++++++++++++++++++++++++++++++-- TP1/exo1/iris4.py | 6 ++--- 2 files changed, 58 insertions(+), 5 deletions(-) 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], -- 2.34.1