From ae5e65e24bfd55db6862ef9bb8050fe507bd6834 Mon Sep 17 00:00:00 2001 From: Florian Mathieu Date: Thu, 28 Mar 2024 15:15:14 +0100 Subject: [PATCH] ajout lien telechargement pandas --- knn/EXERCICES.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/knn/EXERCICES.md b/knn/EXERCICES.md index fbc5eb8..857d4fd 100644 --- a/knn/EXERCICES.md +++ b/knn/EXERCICES.md @@ -7,9 +7,34 @@ Conseil : n'oubliez pas d'importer la bibliothèque `pandas`qui permet de travai Le fichier [pokemons.csv](pokemons.csv) qui va avec. +Ne pas oublier d'installer la bibliothèque pandas + +```python +pip install --upgrade --proxy=172.16.0.253:3128 pandas +``` + + + ```python import pandas as pd pokemons = pd.read_csv('chemin/vers/pokemons.csv') ``` +```python +import numpy as np + +def calculer_distance(pokemon1, pokemon2): + # Utilise numpy pour calculer la distance euclidienne + distance = np.sqrt(np.sum(np.square(np.array(pokemon1) - np.array(pokemon2)))) + return distance + +# Exemple d'utilisation +pokemon1 = [60, 62, 63] # Exemple de stats pour le Pokémon 1 +pokemon2 = [85, 80, 75] # Exemple de stats pour le Pokémon 2 + +distance = calculer_distance(pokemon1, pokemon2) +print(f"La distance entre les deux Pokémon est : {distance}") + +``` +