From 2ae48d82239e1d9f13be74051e69761c1ad1eca3 Mon Sep 17 00:00:00 2001 From: "thibault.capt" <thibault.capt@etu.hesge.ch> Date: Wed, 15 Nov 2023 11:31:26 +0100 Subject: [PATCH] update wrong dimensions --- .idea/misc.xml | 2 +- perceptron-tp3.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 372062d..da907c3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -6,5 +6,5 @@ <component name="MarkdownSettingsMigration"> <option name="stateVersion" value="1" /> </component> - <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" /> + <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (tp-clustering)" project-jdk-type="Python SDK" /> </project> \ No newline at end of file diff --git a/perceptron-tp3.py b/perceptron-tp3.py index da63e76..97c970a 100644 --- a/perceptron-tp3.py +++ b/perceptron-tp3.py @@ -35,7 +35,7 @@ if __name__ == '__main__': y = dataset.iloc[:, 0].values num_features = X.shape[1] - learning_rate = 1e-2 + learning_rate = 1e-3 max_iterations = 2000 num_hidden = 10 @@ -82,12 +82,12 @@ if __name__ == '__main__': print(f"Taux de classifications correctes: {accuracy * 100}%") # Affichage de la droite de séparation des classes - w1, w2, b = weights_hidden_output[1], weights_hidden_output[2], weights_hidden_output[0] + w1, w2, b = weights_input_hidden[1, 1], weights_input_hidden[2, 1], weights_input_hidden[0, 1] pente = -w1 / w2 intercept = -b / w2 print(f"Droite de séparation: y = {pente}x + {intercept}") - # Tracer la droite de séparation (diagonale) + # Tracer la droite de séparation plt.figure() plt.scatter(X[y == 0][:, 0], X[y == 0][:, 1], color='red', label='Classe 0') plt.scatter(X[y == 1][:, 0], X[y == 1][:, 1], color='blue', label='Classe 1') @@ -97,3 +97,4 @@ if __name__ == '__main__': plt.ylabel('Norm_Grade_2') plt.legend() plt.show() + -- GitLab