1053 lines
892 KiB
Plaintext
1053 lines
892 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 37,
|
||
|
"id": "a7ba08af-89d2-455a-9d9a-8eb9828b9d42",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Importowanie potrzebnych bibliotek\n",
|
||
|
"import numpy as np\n",
|
||
|
"import pandas as pd\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import seaborn as sns\n",
|
||
|
"from sklearn import datasets\n",
|
||
|
"from collections import defaultdict\n",
|
||
|
"import warnings\n",
|
||
|
"from sklearn.utils import Bunch\n",
|
||
|
"warnings.simplefilter(\"ignore\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "52abc99b-2ab5-4185-b955-64f0069e7521",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Metryka euklidesowa z 3 klasami"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 50,
|
||
|
"id": "4755089e-f8bc-4cbc-88c5-606df2e03e1c",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Liczba elementów w klasie 0: 39\n",
|
||
|
"Liczba elementów w klasie 1: 61\n",
|
||
|
"Liczba elementów w klasie 2: 50\n",
|
||
|
"Centroidy:\n",
|
||
|
"[6.85384615 3.07692308 5.71538462 2.05384615]\n",
|
||
|
"[5.88360656 2.74098361 4.38852459 1.43442623]\n",
|
||
|
"[5.006 3.428 1.462 0.246]\n",
|
||
|
"Macierz pomyłek:\n",
|
||
|
"[[ 0 0 50]\n",
|
||
|
" [ 3 47 0]\n",
|
||
|
" [36 14 0]]\n",
|
||
|
"Dokładność modelu: 31.33%\n",
|
||
|
"Recall: 31.33%\n",
|
||
|
"Precyzja: 25.68%\n",
|
||
|
"F1-score: 28.23%\n",
|
||
|
"Klasyfikacja przy użyciu wbudowanego KMeans: [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
|
||
|
" 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
|
||
|
" 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 2 0 0 0 0 2 0 0 0 0\n",
|
||
|
" 0 0 2 2 0 0 0 0 2 0 2 0 2 0 0 2 2 0 0 0 0 0 2 0 0 0 0 2 0 0 0 2 0 0 0 2 0\n",
|
||
|
" 0 2]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"iris=datasets.load_iris()\n",
|
||
|
"\n",
|
||
|
"X=pd.DataFrame(iris.data,columns=['Sepal Length', 'Sepal Width', 'Petal Length', 'Petal Width'])\n",
|
||
|
"y=pd.DataFrame(iris.target,columns=['Classes'])\n",
|
||
|
"\n",
|
||
|
"X['species'] = pd.Series(np.random.randn(150), index=X.index)\n",
|
||
|
"X['species'][y['Classes']==0]='Setosa'\n",
|
||
|
"X['species'][y['Classes']==1]='versicolor'\n",
|
||
|
"X['species'][y['Classes']==2]='virginica'\n",
|
||
|
"\n",
|
||
|
"# Ustawienie liczby klastrów\n",
|
||
|
"clusters=len(np.unique(y))\n",
|
||
|
"\n",
|
||
|
"# Funkcja obliczania odległości euklidesowej\n",
|
||
|
"def euclidean_dis(x1, x2):\n",
|
||
|
" return np.sqrt(np.sum((x1 - x2)**2))\n",
|
||
|
"\n",
|
||
|
"# Implementacja KMeans\n",
|
||
|
"class KMeans:\n",
|
||
|
" def __init__(self, data, k, max_ite):\n",
|
||
|
" self.data = data\n",
|
||
|
" self.k = k\n",
|
||
|
" self.max_ite = max_ite\n",
|
||
|
" \n",
|
||
|
" def predict(self):\n",
|
||
|
" centroids = defaultdict(int)\n",
|
||
|
" for i in range(self.k):\n",
|
||
|
" centroids[i] = self.data[i]\n",
|
||
|
" \n",
|
||
|
" for _ in range(self.max_ite):\n",
|
||
|
" classes = defaultdict(list)\n",
|
||
|
" for key in range(self.k):\n",
|
||
|
" classes[key] = []\n",
|
||
|
" \n",
|
||
|
" for datapoint in self.data:\n",
|
||
|
" distances = [euclidean_dis(datapoint, centroids[j]) for j in range(self.k)]\n",
|
||
|
" min_distance_index = distances.index(min(distances))\n",
|
||
|
" classes[min_distance_index].append(datapoint)\n",
|
||
|
" \n",
|
||
|
" old_centroids = dict(centroids)\n",
|
||
|
" for t in range(self.k):\n",
|
||
|
" centroids[t] = np.mean(classes[t], axis=0)\n",
|
||
|
" \n",
|
||
|
" if all(np.sum((centroids[t] - old_centroids[t])/old_centroids[t] * 100) <= 0.001 for t in range(self.k)):\n",
|
||
|
" break\n",
|
||
|
" \n",
|
||
|
" return classes, centroids\n",
|
||
|
"\n",
|
||
|
"# Predykcja z użyciem implementacji KMeans\n",
|
||
|
"kmeans = KMeans(iris.data[:, :4], clusters, 10000)\n",
|
||
|
"classes, centroids = kmeans.predict()\n",
|
||
|
"\n",
|
||
|
"# Drukowanie wyników\n",
|
||
|
"for i in range(0, 3):\n",
|
||
|
" classes[i] = np.array(classes[i]).tolist()\n",
|
||
|
" print(f\"Liczba elementów w klasie {i}: {len(classes[i])}\")\n",
|
||
|
"\n",
|
||
|
"print(\"Centroidy:\")\n",
|
||
|
"for centroid in centroids.values():\n",
|
||
|
" print(centroid)\n",
|
||
|
"\n",
|
||
|
"# Funkcja do tworzenia macierzy pomyłek\n",
|
||
|
"def subset(array1, array2):\n",
|
||
|
" return any(np.array_equal(array2, elem) for elem in array1)\n",
|
||
|
"\n",
|
||
|
"def confusion_matrix(a, b, c, classes):\n",
|
||
|
" cm = [[0] * len(np.unique(y)) for _ in range(len(np.unique(y)))]\n",
|
||
|
" for idx, data_class in enumerate([a, b, c]):\n",
|
||
|
" for element in data_class:\n",
|
||
|
" for i, cluster in enumerate(classes.values()):\n",
|
||
|
" if subset(cluster, element):\n",
|
||
|
" cm[idx][i] += 1\n",
|
||
|
" return cm\n",
|
||
|
"\n",
|
||
|
"# Obliczanie metryk wydajności\n",
|
||
|
"class Metrics:\n",
|
||
|
" def __init__(self, confusion_m):\n",
|
||
|
" self.confusion_m = np.array(confusion_m)\n",
|
||
|
" self.total = np.sum(confusion_m)\n",
|
||
|
" self.diagonal = np.sum(np.diag(confusion_m))\n",
|
||
|
"\n",
|
||
|
" def accuracy(self):\n",
|
||
|
" return self.diagonal / self.total\n",
|
||
|
"\n",
|
||
|
" def recall(self):\n",
|
||
|
" return np.mean(np.diag(self.confusion_m) / np.sum(self.confusion_m, axis=1))\n",
|
||
|
"\n",
|
||
|
" def precision(self):\n",
|
||
|
" return np.mean(np.diag(self.confusion_m) / np.sum(self.confusion_m, axis=0))\n",
|
||
|
"\n",
|
||
|
" def f1_score(self, precision, recall):\n",
|
||
|
" return (2 * precision * recall) / (precision + recall)\n",
|
||
|
"\n",
|
||
|
"# Obliczenie metryk i wyświetlenie wyników\n",
|
||
|
"class0 = np.array([iris.data[i] for i in range(len(iris.target)) if iris.target[i] == 0])\n",
|
||
|
"class1 = np.array([iris.data[i] for i in range(len(iris.target)) if iris.target[i] == 1])\n",
|
||
|
"class2 = np.array([iris.data[i] for i in range(len(iris.target)) if iris.target[i] == 2])\n",
|
||
|
"\n",
|
||
|
"matrix = confusion_matrix(class0, class1, class2, classes)\n",
|
||
|
"performance = Metrics(matrix)\n",
|
||
|
"\n",
|
||
|
"accuracy = performance.accuracy()\n",
|
||
|
"recall = performance.recall()\n",
|
||
|
"precision = performance.precision()\n",
|
||
|
"f1_score = performance.f1_score(precision, recall)\n",
|
||
|
"\n",
|
||
|
"print('Macierz pomyłek:')\n",
|
||
|
"print(np.array(matrix))\n",
|
||
|
"\n",
|
||
|
"print(f\"Dokładność modelu: {accuracy * 100:.2f}%\")\n",
|
||
|
"print(f\"Recall: {recall * 100:.2f}%\")\n",
|
||
|
"print(f\"Precyzja: {precision * 100:.2f}%\")\n",
|
||
|
"print(f\"F1-score: {f1_score * 100:.2f}%\")\n",
|
||
|
"\n",
|
||
|
"# Wykorzystanie wbudowanej funkcji KMeans ze scikit-learn\n",
|
||
|
"from sklearn.cluster import KMeans as SklearnKMeans\n",
|
||
|
"\n",
|
||
|
"kmeans_sklearn = SklearnKMeans(n_clusters=3, random_state=42)\n",
|
||
|
"y_kmeans = kmeans_sklearn.fit_predict(iris.data)\n",
|
||
|
"\n",
|
||
|
"print(\"Klasyfikacja przy użyciu wbudowanego KMeans:\", y_kmeans)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "4cf6521d-c29f-4c55-8947-4556a783c9cf",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Metryka L1 z 3 klasami"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 51,
|
||
|
"id": "36eeb4d3-65eb-42c3-9b1e-4c1dbbc8dd2e",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Liczba elementów w klasie 0: 63\n",
|
||
|
"Liczba elementów w klasie 1: 37\n",
|
||
|
"Liczba elementów w klasie 2: 50\n",
|
||
|
"Centroidy:\n",
|
||
|
"[5.9047619 2.74603175 4.41269841 1.43333333]\n",
|
||
|
"[6.87027027 3.08648649 5.74594595 2.08918919]\n",
|
||
|
"[5.006 3.428 1.462 0.246]\n",
|
||
|
"Macierz pomyłek:\n",
|
||
|
"[[ 0 0 50]\n",
|
||
|
" [48 2 0]\n",
|
||
|
" [15 35 0]]\n",
|
||
|
"Dokładność modelu: 1.33%\n",
|
||
|
"Recall: 1.33%\n",
|
||
|
"Precyzja: 1.80%\n",
|
||
|
"F1-score: 1.53%\n",
|
||
|
"Klasyfikacja przy użyciu wbudowanego KMeans: [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
|
||
|
" 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
|
||
|
" 2 2 2 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 2 0 0 0 0 2 0 0 0 0\n",
|
||
|
" 0 0 2 2 0 0 0 0 2 0 2 0 2 0 0 2 2 0 0 0 0 0 2 0 0 0 0 2 0 0 0 2 0 0 0 2 0\n",
|
||
|
" 0 2]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Odległość Manhatan\n",
|
||
|
"def manhattan_dis(x1, x2):\n",
|
||
|
" return np.sum(np.abs(x1 - x2))\n",
|
||
|
"\n",
|
||
|
"# Implementacja KMeans\n",
|
||
|
"class KMeans:\n",
|
||
|
" def __init__(self, data, k, max_ite):\n",
|
||
|
" self.data = data\n",
|
||
|
" self.k = k\n",
|
||
|
" self.max_ite = max_ite\n",
|
||
|
" \n",
|
||
|
" def predict(self):\n",
|
||
|
" centroids = defaultdict(int)\n",
|
||
|
" for i in range(self.k):\n",
|
||
|
" centroids[i] = self.data[i]\n",
|
||
|
" \n",
|
||
|
" for _ in range(self.max_ite):\n",
|
||
|
" classes = defaultdict(list)\n",
|
||
|
" for key in range(self.k):\n",
|
||
|
" classes[key] = []\n",
|
||
|
" \n",
|
||
|
" for datapoint in self.data:\n",
|
||
|
" distances = [manhattan_dis(datapoint, centroids[j]) for j in range(self.k)]\n",
|
||
|
" min_distance_index = distances.index(min(distances))\n",
|
||
|
" classes[min_distance_index].append(datapoint)\n",
|
||
|
" \n",
|
||
|
" old_centroids = dict(centroids)\n",
|
||
|
" for t in range(self.k):\n",
|
||
|
" centroids[t] = np.mean(classes[t], axis=0)\n",
|
||
|
" \n",
|
||
|
" if all(np.sum((centroids[t] - old_centroids[t])/old_centroids[t] * 100) <= 0.001 for t in range(self.k)):\n",
|
||
|
" break\n",
|
||
|
" \n",
|
||
|
" return classes, centroids\n",
|
||
|
"\n",
|
||
|
"# Predykcja z użyciem implementacji KMeans\n",
|
||
|
"kmeans = KMeans(iris.data[:, :4], clusters, 10000)\n",
|
||
|
"classes, centroids = kmeans.predict()\n",
|
||
|
"\n",
|
||
|
"# Drukowanie wyników\n",
|
||
|
"for i in range(0, 3):\n",
|
||
|
" classes[i] = np.array(classes[i]).tolist()\n",
|
||
|
" print(f\"Liczba elementów w klasie {i}: {len(classes[i])}\")\n",
|
||
|
"\n",
|
||
|
"print(\"Centroidy:\")\n",
|
||
|
"for centroid in centroids.values():\n",
|
||
|
" print(centroid)\n",
|
||
|
"\n",
|
||
|
"# Funkcja do tworzenia macierzy pomyłek\n",
|
||
|
"def subset(array1, array2):\n",
|
||
|
" return any(np.array_equal(array2, elem) for elem in array1)\n",
|
||
|
"\n",
|
||
|
"def confusion_matrix(a, b, c, classes):\n",
|
||
|
" cm = [[0] * len(np.unique(y)) for _ in range(len(np.unique(y)))]\n",
|
||
|
" for idx, data_class in enumerate([a, b, c]):\n",
|
||
|
" for element in data_class:\n",
|
||
|
" for i, cluster in enumerate(classes.values()):\n",
|
||
|
" if subset(cluster, element):\n",
|
||
|
" cm[idx][i] += 1\n",
|
||
|
" return cm\n",
|
||
|
"\n",
|
||
|
"# Obliczanie metryk wydajności\n",
|
||
|
"class Metrics:\n",
|
||
|
" def __init__(self, confusion_m):\n",
|
||
|
" self.confusion_m = np.array(confusion_m)\n",
|
||
|
" self.total = np.sum(confusion_m)\n",
|
||
|
" self.diagonal = np.sum(np.diag(confusion_m))\n",
|
||
|
"\n",
|
||
|
" def accuracy(self):\n",
|
||
|
" return self.diagonal / self.total\n",
|
||
|
"\n",
|
||
|
" def recall(self):\n",
|
||
|
" return np.mean(np.diag(self.confusion_m) / np.sum(self.confusion_m, axis=1))\n",
|
||
|
"\n",
|
||
|
" def precision(self):\n",
|
||
|
" return np.mean(np.diag(self.confusion_m) / np.sum(self.confusion_m, axis=0))\n",
|
||
|
"\n",
|
||
|
" def f1_score(self, precision, recall):\n",
|
||
|
" return (2 * precision * recall) / (precision + recall)\n",
|
||
|
"\n",
|
||
|
"# Obliczenie metryk i wyświetlenie wyników\n",
|
||
|
"class0 = np.array([iris.data[i] for i in range(len(iris.target)) if iris.target[i] == 0])\n",
|
||
|
"class1 = np.array([iris.data[i] for i in range(len(iris.target)) if iris.target[i] == 1])\n",
|
||
|
"class2 = np.array([iris.data[i] for i in range(len(iris.target)) if iris.target[i] == 2])\n",
|
||
|
"\n",
|
||
|
"matrix = confusion_matrix(class0, class1, class2, classes)\n",
|
||
|
"performance = Metrics(matrix)\n",
|
||
|
"\n",
|
||
|
"accuracy = performance.accuracy()\n",
|
||
|
"recall = performance.recall()\n",
|
||
|
"precision = performance.precision()\n",
|
||
|
"f1_score = performance.f1_score(precision, recall)\n",
|
||
|
"\n",
|
||
|
"print('Macierz pomyłek:')\n",
|
||
|
"print(np.array(matrix))\n",
|
||
|
"\n",
|
||
|
"print(f\"Dokładność modelu: {accuracy * 100:.2f}%\")\n",
|
||
|
"print(f\"Recall: {recall * 100:.2f}%\")\n",
|
||
|
"print(f\"Precyzja: {precision * 100:.2f}%\")\n",
|
||
|
"print(f\"F1-score: {f1_score * 100:.2f}%\")\n",
|
||
|
"\n",
|
||
|
"# Wykorzystanie wbudowanej funkcji KMeans ze scikit-learn\n",
|
||
|
"from sklearn.cluster import KMeans as SklearnKMeans\n",
|
||
|
"\n",
|
||
|
"kmeans_sklearn = SklearnKMeans(n_clusters=3, random_state=42)\n",
|
||
|
"y_kmeans = kmeans_sklearn.fit_predict(iris.data)\n",
|
||
|
"\n",
|
||
|
"print(\"Klasyfikacja przy użyciu wbudowanego KMeans:\", y_kmeans)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "d68189cd-45d8-404a-8f55-9dccfe1eaf19",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Metryka euklidesowa z 2 klasami"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 56,
|
||
|
"id": "5914c6ba-eb11-445f-b0ff-744df411f0c7",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Liczba elementów w klasie 0: 50\n",
|
||
|
"Liczba elementów w klasie 1: 50\n",
|
||
|
"Centroidy:\n",
|
||
|
"[5.006 3.428 1.462 0.246]\n",
|
||
|
"[5.936 2.77 4.26 1.326]\n",
|
||
|
"Macierz pomyłek:\n",
|
||
|
"[[50 0]\n",
|
||
|
" [ 0 50]]\n",
|
||
|
"Dokładność modelu: 100.00%\n",
|
||
|
"Recall: 100.00%\n",
|
||
|
"Precyzja: 100.00%\n",
|
||
|
"F1-score: 100.00%\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Usunięcie jednej z klas (np. klasy 2)\n",
|
||
|
"X = X[y['Classes'] != 2]\n",
|
||
|
"y = y[y['Classes'] != 2]\n",
|
||
|
"\n",
|
||
|
"# Zresetowanie indeksów po usunięciu klasy\n",
|
||
|
"X.reset_index(drop=True, inplace=True)\n",
|
||
|
"y.reset_index(drop=True, inplace=True)\n",
|
||
|
"\n",
|
||
|
"# Ustawienie liczby klastrów po usunięciu klasy\n",
|
||
|
"clusters = len(np.unique(y))\n",
|
||
|
"\n",
|
||
|
"# Funkcja obliczania odległości euklidesowej\n",
|
||
|
"def euclidean_dis(x1, x2):\n",
|
||
|
" return np.sqrt(np.sum((x1 - x2)**2))\n",
|
||
|
"\n",
|
||
|
"# Implementacja KMeans z metryką Manhattan\n",
|
||
|
"class KMeans:\n",
|
||
|
" def __init__(self, data, k, max_ite):\n",
|
||
|
" self.data = data\n",
|
||
|
" self.k = k\n",
|
||
|
" self.max_ite = max_ite\n",
|
||
|
" \n",
|
||
|
" def predict(self):\n",
|
||
|
" centroids = defaultdict(int)\n",
|
||
|
" for i in range(self.k):\n",
|
||
|
" centroids[i] = self.data[i]\n",
|
||
|
" \n",
|
||
|
" for _ in range(self.max_ite):\n",
|
||
|
" classes = defaultdict(list)\n",
|
||
|
" for key in range(self.k):\n",
|
||
|
" classes[key] = []\n",
|
||
|
" \n",
|
||
|
" for datapoint in self.data:\n",
|
||
|
" distances = [euclidean_dis(datapoint, centroids[j]) for j in range(self.k)]\n",
|
||
|
" min_distance_index = distances.index(min(distances))\n",
|
||
|
" classes[min_distance_index].append(datapoint)\n",
|
||
|
" \n",
|
||
|
" old_centroids = dict(centroids)\n",
|
||
|
" for t in range(self.k):\n",
|
||
|
" centroids[t] = np.mean(classes[t], axis=0)\n",
|
||
|
" \n",
|
||
|
" if all(np.sum((centroids[t] - old_centroids[t])/old_centroids[t] * 100) <= 0.001 for t in range(self.k)):\n",
|
||
|
" break\n",
|
||
|
" \n",
|
||
|
" return classes, centroids\n",
|
||
|
"\n",
|
||
|
"# Predykcja z użyciem zmodyfikowanej implementacji KMeans\n",
|
||
|
"kmeans = KMeans(X.values, clusters, 10000)\n",
|
||
|
"classes, centroids = kmeans.predict()\n",
|
||
|
"\n",
|
||
|
"# Drukowanie wyników\n",
|
||
|
"for i in range(clusters):\n",
|
||
|
" classes[i] = np.array(classes[i]).tolist()\n",
|
||
|
" print(f\"Liczba elementów w klasie {i}: {len(classes[i])}\")\n",
|
||
|
"\n",
|
||
|
"print(\"Centroidy:\")\n",
|
||
|
"for centroid in centroids.values():\n",
|
||
|
" print(centroid)\n",
|
||
|
"\n",
|
||
|
"# Obliczenie metryk i wyświetlenie wyników dla pozostałych klas\n",
|
||
|
"class0 = np.array([X.values[i] for i in range(len(y)) if y.iloc[i, 0] == 0])\n",
|
||
|
"class1 = np.array([X.values[i] for i in range(len(y)) if y.iloc[i, 0] == 1])\n",
|
||
|
"\n",
|
||
|
"matrix = confusion_matrix(class0, class1, [], classes)\n",
|
||
|
"performance = Metrics(matrix)\n",
|
||
|
"\n",
|
||
|
"accuracy = performance.accuracy()\n",
|
||
|
"recall = performance.recall()\n",
|
||
|
"precision = performance.precision()\n",
|
||
|
"f1_score = performance.f1_score(precision, recall)\n",
|
||
|
"\n",
|
||
|
"print('Macierz pomyłek:')\n",
|
||
|
"print(np.array(matrix))\n",
|
||
|
"\n",
|
||
|
"print(f\"Dokładność modelu: {accuracy * 100:.2f}%\")\n",
|
||
|
"print(f\"Recall: {recall * 100:.2f}%\")\n",
|
||
|
"print(f\"Precyzja: {precision * 100:.2f}%\")\n",
|
||
|
"print(f\"F1-score: {f1_score * 100:.2f}%\")\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "0e29854d-e26f-4250-b8f2-b075d7ed6306",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Porównanie wyników klasyfikacji przy użyciu metryki euklidesowej\n",
|
||
|
"\n",
|
||
|
"## 1. Wyniki z metryką euklidesową dla wszystkich klas:\n",
|
||
|
"- **Liczba elementów w klasach**:\n",
|
||
|
" - Klasa 0: 39\n",
|
||
|
" - Klasa 1: 61\n",
|
||
|
" - Klasa 2: 50\n",
|
||
|
"\n",
|
||
|
"- **Centroidy**:\n",
|
||
|
" - Klasa 0: [6.8538, 3.0769, 5.7154, 2.0538]\n",
|
||
|
" - Klasa 1: [5.8836, 2.7410, 4.3885, 1.4344]\n",
|
||
|
" - Klasa 2: [5.006, 3.428, 1.462, 0.246]\n",
|
||
|
"\n",
|
||
|
"- **Macierz pomyłek**:\n",
|
||
|
" - [[ 0, 0, 50], [ 3, 47, 0], [36, 14, 0]]\n",
|
||
|
"\n",
|
||
|
"- **Metryki wydajności**:\n",
|
||
|
" - Dokładność: 31.33%\n",
|
||
|
" - Recall: 31.33%\n",
|
||
|
" - Precyzja: 25.68%\n",
|
||
|
" - F1-score: 28.23%\n",
|
||
|
"\n",
|
||
|
"- **Komentarz**: Model wykazuje niską jakość klasyfikacji, szczególnie dla klasy 2, która została całkowicie pominięta w prognozach. Chociaż klasa 1 ma relatywnie wysoką precyzję, wyniki ogólne są słabe, co sugeruje problemy z klastrowaniem przy pełnym zbiorze danych."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "ea82dc2a-9c7f-46a5-a496-f40b808ef9ec",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## 2. Wyniki z metryką euklidesową po usunięciu jednej klasy:\n",
|
||
|
"- **Liczba elementów w klasach**:\n",
|
||
|
" - Klasa 0: 50\n",
|
||
|
" - Klasa 1: 50\n",
|
||
|
"\n",
|
||
|
"- **Centroidy**:\n",
|
||
|
" - Klasa 0: [5.006, 3.428, 1.462, 0.246]\n",
|
||
|
" - Klasa 1: [5.936, 2.770, 4.260, 1.326]\n",
|
||
|
"\n",
|
||
|
"- **Macierz pomyłek**:\n",
|
||
|
" - [[50, 0], [ 0, 50]]\n",
|
||
|
"\n",
|
||
|
"- **Metryki wydajności**:\n",
|
||
|
" - Dokładność: 100.00%\n",
|
||
|
" - Recall: 100.00%\n",
|
||
|
" - Precyzja: 100.00%\n",
|
||
|
" - F1-score: 100.00%\n",
|
||
|
"\n",
|
||
|
"- **Komentarz**: Po usunięciu jednej klasy model osiągnął perfekcyjne wyniki. Wszystkie punkty danych zostały poprawnie sklasyfikowane, co pokazuje, że zredukowanie liczby klas poprawiło znacząco wydajność algorytmu.\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "453b9ac5-9651-4846-8860-7428e91ce138",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## 3. Wyniki z metryką L1 dla wszystkich klas:\n",
|
||
|
"- **Liczba elementów w klasach**:\n",
|
||
|
" - Klasa 0: 63\n",
|
||
|
" - Klasa 1: 37\n",
|
||
|
" - Klasa 2: 50\n",
|
||
|
"\n",
|
||
|
"- **Centroidy**:\n",
|
||
|
" - Klasa 0: [5.9048, 2.7460, 4.4127, 1.4333]\n",
|
||
|
" - Klasa 1: [6.8703, 3.0865, 5.7459, 2.0892]\n",
|
||
|
" - Klasa 2: [5.006, 3.428, 1.462, 0.246]\n",
|
||
|
"\n",
|
||
|
"- **Macierz pomyłek**:\n",
|
||
|
" - [[ 0, 0, 50], [48, 2, 0], [15, 35, 0]]\n",
|
||
|
"\n",
|
||
|
"- **Metryki wydajności**:\n",
|
||
|
" - Dokładność: 1.33%\n",
|
||
|
" - Recall: 1.33%\n",
|
||
|
" - Precyzja: 1.80%\n",
|
||
|
" - F1-score: 1.53%\n",
|
||
|
"\n",
|
||
|
"- **Komentarz**: Podobnie jak w przypadku metryki euklidesowej z 3 klasami, model z tą metryką wykazuje bardzo niską dokładność. Klasyfikacja nie działa dobrze przy wykorzystaniu metryki L1 dla pełnego zbioru danych."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "7041caf0-71cb-4d7c-bf6e-003176854ee2",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Podsumowanie:\n",
|
||
|
"- **Metryka euklidesowa dla wszystkich klas**: Niska wydajność z punktami błędnie klasyfikowanymi. Klasa 2 została całkowicie pominięta.\n",
|
||
|
"- **Metryka euklidesowa po usunięciu klasy**: Perfekcyjne wyniki. Algorytm działa doskonale przy dwóch klasach.\n",
|
||
|
"- **Metryka L1 dla wszystkich klas**: Bardzo niska jakość klasyfikacji, co wskazuje na nieodpowiedniość metryki do struktury danych w tym przypadku.\n",
|
||
|
"\n",
|
||
|
"## Wnioski:\n",
|
||
|
"Zastosowanie metryki euklidesowej przy pełnym zbiorze danych wykazuje lepsze rezultaty w porównaniu do metryki L1, ale po usunięciu jednej klasy algorytm KMeans osiąga idealne wyniki. To podkreśla znaczenie doboru metryki oraz liczby klas w analizie klastrów."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 58,
|
||
|
"id": "6d49ca08-fe5b-40af-a98c-5d03e589d440",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"<class 'pandas.core.frame.DataFrame'>\n",
|
||
|
"RangeIndex: 150 entries, 0 to 149\n",
|
||
|
"Data columns (total 5 columns):\n",
|
||
|
" # Column Non-Null Count Dtype \n",
|
||
|
"--- ------ -------------- ----- \n",
|
||
|
" 0 sepal_length 150 non-null float64\n",
|
||
|
" 1 sepal_width 150 non-null float64\n",
|
||
|
" 2 petal_length 150 non-null float64\n",
|
||
|
" 3 petal_width 150 non-null float64\n",
|
||
|
" 4 species 150 non-null object \n",
|
||
|
"dtypes: float64(4), object(1)\n",
|
||
|
"memory usage: 6.0+ KB\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th></th>\n",
|
||
|
" <th>sepal_length</th>\n",
|
||
|
" <th>sepal_width</th>\n",
|
||
|
" <th>petal_length</th>\n",
|
||
|
" <th>petal_width</th>\n",
|
||
|
" <th>species</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>5.1</td>\n",
|
||
|
" <td>3.5</td>\n",
|
||
|
" <td>1.4</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>4.9</td>\n",
|
||
|
" <td>3.0</td>\n",
|
||
|
" <td>1.4</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>4.7</td>\n",
|
||
|
" <td>3.2</td>\n",
|
||
|
" <td>1.3</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>4.6</td>\n",
|
||
|
" <td>3.1</td>\n",
|
||
|
" <td>1.5</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>5.0</td>\n",
|
||
|
" <td>3.6</td>\n",
|
||
|
" <td>1.4</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>5</th>\n",
|
||
|
" <td>5.4</td>\n",
|
||
|
" <td>3.9</td>\n",
|
||
|
" <td>1.7</td>\n",
|
||
|
" <td>0.4</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>6</th>\n",
|
||
|
" <td>4.6</td>\n",
|
||
|
" <td>3.4</td>\n",
|
||
|
" <td>1.4</td>\n",
|
||
|
" <td>0.3</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>7</th>\n",
|
||
|
" <td>5.0</td>\n",
|
||
|
" <td>3.4</td>\n",
|
||
|
" <td>1.5</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>8</th>\n",
|
||
|
" <td>4.4</td>\n",
|
||
|
" <td>2.9</td>\n",
|
||
|
" <td>1.4</td>\n",
|
||
|
" <td>0.2</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>9</th>\n",
|
||
|
" <td>4.9</td>\n",
|
||
|
" <td>3.1</td>\n",
|
||
|
" <td>1.5</td>\n",
|
||
|
" <td>0.1</td>\n",
|
||
|
" <td>setosa</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" sepal_length sepal_width petal_length petal_width species\n",
|
||
|
"0 5.1 3.5 1.4 0.2 setosa\n",
|
||
|
"1 4.9 3.0 1.4 0.2 setosa\n",
|
||
|
"2 4.7 3.2 1.3 0.2 setosa\n",
|
||
|
"3 4.6 3.1 1.5 0.2 setosa\n",
|
||
|
"4 5.0 3.6 1.4 0.2 setosa\n",
|
||
|
"5 5.4 3.9 1.7 0.4 setosa\n",
|
||
|
"6 4.6 3.4 1.4 0.3 setosa\n",
|
||
|
"7 5.0 3.4 1.5 0.2 setosa\n",
|
||
|
"8 4.4 2.9 1.4 0.2 setosa\n",
|
||
|
"9 4.9 3.1 1.5 0.1 setosa"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 58,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"iris = pd.read_csv(\"iris.csv\")\n",
|
||
|
"x = iris.iloc[:, [0, 1, 2, 3]].values\n",
|
||
|
"iris.info()\n",
|
||
|
"iris[0:10]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 59,
|
||
|
"id": "67c9ab0e-f9be-4745-a9a8-3948db8f6029",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<div>\n",
|
||
|
"<style scoped>\n",
|
||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||
|
" vertical-align: middle;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe tbody tr th {\n",
|
||
|
" vertical-align: top;\n",
|
||
|
" }\n",
|
||
|
"\n",
|
||
|
" .dataframe thead th {\n",
|
||
|
" text-align: right;\n",
|
||
|
" }\n",
|
||
|
"</style>\n",
|
||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||
|
" <thead>\n",
|
||
|
" <tr style=\"text-align: right;\">\n",
|
||
|
" <th>col_0</th>\n",
|
||
|
" <th>count</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>species</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>setosa</th>\n",
|
||
|
" <td>50</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>versicolor</th>\n",
|
||
|
" <td>50</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>virginica</th>\n",
|
||
|
" <td>50</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"col_0 count\n",
|
||
|
"species \n",
|
||
|
"setosa 50\n",
|
||
|
"versicolor 50\n",
|
||
|
"virginica 50"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 59,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"iris_outcome = pd.crosstab(index=iris[\"species\"], # Make a crosstab\n",
|
||
|
" columns=\"count\") # Name the count column\n",
|
||
|
"\n",
|
||
|
"iris_outcome"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 60,
|
||
|
"id": "f5de2e39-30dc-4fab-86bb-325d7abc2455",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"iris_setosa=iris.loc[iris[\"species\"]==\"Iris-setosa\"]\n",
|
||
|
"iris_virginica=iris.loc[iris[\"species\"]==\"Iris-virginica\"]\n",
|
||
|
"iris_versicolor=iris.loc[iris[\"species\"]==\"Iris-versicolor\"]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 61,
|
||
|
"id": "60299a20-6423-4f91-98bb-d8aa0aecfcd7",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEiCAYAAADwEwVaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAABP7ElEQVR4nO3deVxU9frA8c+sDIuCCO5bikslBYJiqbnkcjX369LyM/VmWRSp7eltsbKrLbfSNkvbl2vXqzfX0tzSq6GmFmqYmAgCIovsDLP+/hhmlADZhpkBnvfrNa/gzOGcZyDPc77L+T4Kq9VqRQghRJOjdHcAQggh3EMSgBBCNFGSAIQQoomSBCCEEE2UJAAhhGiiJAEIIUQTJQlACCGaKEkAQgjRRDX6BGC1WjGbzcjzbkIIUVajTwAWi4Vjx45hsVjcHUq1WCwWfv311wYTb03J52u4GuNnauoafQJoaKxWK0ajsdG2WOTzNVyN8TM1dZIAhBCiiZIEIIQQTZQkACGEaKIkAQghRBMl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1+Ue7+wsBBvb+8y23Q6HUVFRTU+V1xcXK3jrI7T52wxWYx60i6k0c5PiUFfCEBaRjbHjh2r0fHqO153k8/XMEVERLg7BOFEbksABQUFPP3005w4cYIvvviCnj17ltvH29sbvV5fZpter8fX17fG5wsNDa3Xu5ddmaeBPFo086Ntm7b4+foSHBAA5KHx9iMsLKxaxzGbzcTFxdV7vO4in6/haoytmqbOLQkgKSmJe++9l3bt2rF
|
||
|
"text/plain": [
|
||
|
"<Figure size 409.5x300 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEiCAYAAAD05tVnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAABCFElEQVR4nO3dd3iUVdrH8e/UTHojCZ1QA0oUSCACUSBSFGRRpCgsCi6IoCgoqCsWEEEsyCK7AgKiothYeBWQJp0FQpdI7wkJ6b1nyvvHkIEAgUzaTDL357pyOeUpd45kfnOeco7CZDKZEEII4bCUti5ACCGEbUkQCCGEg5MgEEIIBydBIIQQDk6CQAghHJwEgRBCODgJAiGEcHASBEII4eBqXRCYTCYMBgNyn5wQQpRNrQsCo9HI0aNHMRqNVq1z7Ngxq9apzaQ9rpO2uE7aovaqdUFQHiaTiaKiIulFXCPtcZ20xXXSFrWXBIEQQjg4CQIhhHBwEgRCCOHgJAiEEMLBSRAIIYSDkyAQQggHJ0EghBAOToJACCEcnASBEEI4OLWtC6jpMvKKyMovAsBdp8HTWWPjioQQwjrSI6igrPwiDl9O5/DldEsgCCFETSI9gkpQZJBBuIQQNZf0CIQQwsFJEAghhIOTIBBCCAcnQSCEEA5OgkAIIRycBIEQQjg4CQIhhHBwEgRCCOHgJAiEEMLBSR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EDVDnz59uHTpEuPGjSMtLQ1fX1/eeustmjVrBoCnpycPP/wwAE899ZTlSseRI0d
|
||
|
"text/plain": [
|
||
|
"<Figure size 409.5x300 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEiCAYAAADwEwVaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAABmoUlEQVR4nO3dd3xUVfr48c+dOzOZSSa9JwQCCQlIDQSyKkpVFBXUFXT1Z1tRlFUEy+LKqoDKYlldRbGBddWviqKAIiAqsoqEFgktkEB6SO9tyr2/PyaJxBRSJpmEnLeveb3IzC1PrpP73HvuOc+RVFVVEQRBEPocjbMDEARBEJxDJABBEIQ+SiQAQRCEPkokAEEQhD5KJABBEIQ+SiQAQRCEPkokAEEQhD5KJABBEIQ+6pxPAKqqYrPZEOPdBEEQGjvnE4CiKCQkJKAoSqe2cfDgwU5to68Rx6xjxHETutM5nwAcQVVVLBaLuItoB3HMOkYcN6E7iQQgCILQR4kEIAiC0EeJBCAIgtBHiQQgCILQR4kEIAiC0EeJBCAIgtBHiQQgCILQR4kEIAiC0EeJBCAIgtBHaZ0dgNAxpdUWymssrS7jbtDhadR1U0SCIPQ2IgH0UuU1FvanlWCxNV8zRidrGDPASyQAQRBaJBJAL2axKdRaRdEwQRA6RjwDEARB6KNEAhAEQeijRAIQBEHoo0QCEARB6KNEAhAEQeijRAIQBEHoo5yeAIqKirjkkkvYvXv3WZc9fvw4o0aNatOygiAIQuucmgD27dvH9ddfT3p6+lmXra6u5sEHH6SmpqYbIhMEQTj3OS0BrF+/noceeohFixa1aflly5Yxbdq0Lo5KEASh73BaApgwYQLbtm1jxowZZ132yy+/JC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adata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.FacetGrid(iris,hue=\"species\").map(sns.distplot,\"petal_length\").add_legend()\n",
|
||
|
"sns.FacetGrid(iris,hue=\"species\").map(sns.distplot,\"petal_width\").add_legend()\n",
|
||
|
"sns.FacetGrid(iris,hue=\"species\").map(sns.distplot,\"sepal_length\").add_legend()\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 62,
|
||
|
"id": "dc86ef38-14d9-41c6-bb02-45a3b0b00c2b",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAicAAAGsCAYAAAAGzwdbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAwe0lEQVR4nO3de1hVdaL/8Q+bi0gIiiIqWWkmRlGiCFNWqJlOanlJ7IyOlqlplje8lXazsbLyklmYpl1Mc+yip/JSjhzzaVIxUwvv6WQidBAVEUSFvff6/eFxT/y0iW3A+up+v56nB9lr7bU+bReuD99187MsyxIAAIAhHHYHAAAA+DXKCQAAMArlBAAAGIVyAgAAjEI5AQAARqGcAAAAo1BOAACAUQLsDuAtt9stp9Mph8MhPz8/u+MAAIBysCxLbrdbAQEBcjj+89jIJVdOnE6nMjMz7Y4BAAAuQlxcnIKCgv7jPJdcOTnXtuLi4uTv729zGgAAUB4ul0uZmZm/O2oiXYLl5NyhHH9/f8oJAACXmPKcksEJsQAAwCiUEwAAYBTKCQAAMArlBAAAGIVyAgAAjGLL1TqfffaZnnnmmTKvlZaWSpK2b99uRyQAAGAIW8rJvffeq3vvvdfzfW5uru677z6NHTvWjjgAAMAgtt/nxLIsjR07Vm3atFHXrl3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Af/4Sy2Bfgyr+9z0qBBA/33f//3ea8HBgYqIiJCzZs3V/Xq1SsiG+BzFu7JtzsCANjO63KyZMkSbdu2TbVr11Z0dLR++eUX5eXlqV69ejp
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.boxplot(x=\"species\",y=\"petal_length\",data=iris, palette=\"Set2\")\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 70,
|
||
|
"id": "3b3457af-8d7d-4cfd-8f78-100d719aefc8",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAicAAAGsCAYAAAAGzwdbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAABUoElEQVR4nO3dd3hUZdoG8HvmTEtvpJDQCZAggdCCgFQFVFCKoGsBG6jruvbu6i67rGvBRWQFdcG1rqsfyq40URCwBQRCSQIhIC2992TaOe/3xyQDkZYJmZyZzP27Li4npz7EIXPnPW/RCCEEiIiIiDyEVu0CiIiIiM7EcEJEREQeheGEiIiIPArDCREREXkUhhMiIiLyKAwnRERE5FEYToiIiMij6NQuwFWKosBut0Or1UKj0ahdDhEREbWAEAKKokCn00GrvXDbiNeFE7vdjvT0dLXLICIiolZISkqCwWC44DFeF06a0lZSUhIkSVK5GiIiImoJWZaRnp5+0VYTwAvDSdOjHEmSGE6IiIi8TEu6ZLBDLBEREXkUhhMiIiLyKAwnRERE5FEYToiIiMijMJwQERGRR2E4ISIiIo/CcEJEREQeheGEiIiIPArDCREREXkUhhMiIiLyKAwnRER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6Kurg7l5eVYsmQJrrrqKmcHWSIiIndocUdY2Qb/QxtgzN8HjXD0ldDaG+B/aAMg2y58rs4AW3hP5OXlYv/+/W1Rts9p93Ci1+vx4YcfQpIkTJkyBVOmTEFMTAxefPHF9i6FiIh8SElJCXbt2g17YBQUv9ALHmvM3wf
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.violinplot(x=\"species\",y=\"petal_length\",data=iris)\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "97f58987-e092-4f9a-a456-7104ceae4b5f",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABRYAAASeCAYAAACzT3LfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzddZxUVf/A8c90b3cSS3eqSAkoooio6ONjYvtgdz124mPx8zEfUezuQBEDRAUB6V5yu3tndnfi98eVhXFnNmdr+L598RLumXvvuWdmz9753nPOV+XxeDwIIYQQQgghhBBCCCFEC6g7uwJCCCGEEEIIIYQQQojuRwKLQgghhBBCCCGEEEKIFpPAohBCCCGEEEIIIYQQosUksCiEEEIIIYQQQgghhGgxCSwKIYQQQgghhBBCCCFaTAKLQgghhBBCCCGEEEKIFpPAohBCCCGEEEIIIYQQosUksCiEEEIIIYQQQgghhGixoA8sejweXC4XHo+ns6sihAgy0r8IIdqT9DFCiPYi/YsQQohACfrAotvtZv369bjd7oAec+PGjQE9ZmcIhusIhmuA4LiOYLgGOHQdzX1toPuX9h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Zo9boc7+q2iq+2fMND616qH7b0gNLiTXHsujERSTZkgJwZV1DVkUWF393MdlV2fXb3t72NreNuY3ZabOx6q2dWDshhGiekMQQ5v0wj50lO+u3fbTrIy4YeAGXDbmsPgDQEvnV+by19S1e2/Ja/bYl+5fQM6Qnz019jtW5q7n393vryw4+nHlt+mukhKS06XqEEG1X7Ch
|
||
|
"text/plain": [
|
||
|
"<Figure size 1309.5x1200 with 20 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sns.set_style(\"whitegrid\")\n",
|
||
|
"sns.pairplot(iris,hue=\"species\",size=3);\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 25,
|
||
|
"id": "4d26607a-d8c2-45f8-9229-6747e116d284",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"from sklearn.cluster import KMeans\n",
|
||
|
"wcss = []\n",
|
||
|
"\n",
|
||
|
"for i in range(1, 11):\n",
|
||
|
" kmeans = KMeans(n_clusters = i, init = 'k-means++', max_iter = 300, n_init = 10, random_state = 0)\n",
|
||
|
" kmeans.fit(x)\n",
|
||
|
" wcss.append(kmeans.inertia_)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 26,
|
||
|
"id": "e21ea4ee-d91c-4b9c-9049-5d1554a6806a",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjYAAAHBCAYAAAB6yfEJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAABPzUlEQVR4nO3de1xUdf4/8Ndc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IwdOxZZWVn2X7t27YJGo0FycjJ0Oh2mTZuGcePGITMzE8nJyVixYgVycnIAABkZGVi+fDlWrlyJzMxMjB07Fk8//TRqa2vdfRpEREQkQoJO97ZarZg3bx4eeOABJCQkYPfu3dBoNJg8eTLkcjni4uIwZswYbNy4EQCQmpqKUaNGISYmBgqFAklJSdBqtdi5c6eQp0FEREQiIegYmy+//BIFBQVYu3YtACA/Px8REREO24SFhWHz5s0AgIKCAkyYMKHR+ry8vGZ/t9lsvs2qPZvtuvD6iAPbQ3zYJuLC9hAXV7aHs8cULNhYLBa8++67mD59Ovz9/QEA1dXVUKvVDtupVCrU1NQ4tb45OOX75nh9xIXtIT5sE3Fhe4iLkO0hWLDJyMhAcXExEhMT7cvUajUqKysdttPr9fDz87Ov1+v1jdZrtdpmfz+nBt4Yp06KC9tDfNgm4sL2EBd3TPe+FcGCzTfffIP4+Hj4+vral0VERODgwYMO2xUUFCA8PBwAEB4ejvz8/Ebrhw4d2uzv59T
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.plot(range(1, 11), wcss)\n",
|
||
|
"plt.title('The elbow method')\n",
|
||
|
"plt.xlabel('Number of clusters')\n",
|
||
|
"plt.ylabel('WCSS') #within cluster sum of squares\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 27,
|
||
|
"id": "4adcad95-5b58-467c-b1bb-a5f875db06a7",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"kmeans = KMeans(n_clusters = 3, init = 'k-means++', max_iter = 300, n_init = 10, random_state = 0)\n",
|
||
|
"y_kmeans = kmeans.fit_predict(x)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 28,
|
||
|
"id": "de929a44-bc98-4c7a-a28e-9099bc09efc7",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.legend.Legend at 0x189f13ee3f0>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 28,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiEAAAGdCAYAAADE96MUAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB/XUlEQVR4nO3de3wTVf4//tekSdqkRZoWcLlLWwo/pNBiaUW5CF+lKBdZymU/YCkorqxuUVABAXWVy+quQqXrBQW1LrIfEIpytawLgn5gW1kpVFguLXeKhV6CLWmaNJnfH9PUprfMTDKTSfJ++ugDmcx0zpnJJG/mcl4My7IsCCGEEEJkpvJ2AwghhBASmKgIIYQQQohXUBFCCCGEEK+gIoQQQgghXkFFCCGEEEK8gooQQgghhHgFFSGEEEII8QoqQgghhBDiFVSEEEIIIcQrRBUhNpsNaWlpWLx4cavzzJkzB3FxcUhISGj4OXTokOiGEkIIIcS/qMUs9Le//Q1Hjx5F165dW53np59+woYNG5CUlCSqYXa7HXV1dVCpVGAYRtTvIIQQQoi8WJaF3W6HWq2GStX2uQ7BRciRI0ewb98+jB49utV5rly5glu3bqFfv35Cf32Duro6FBYWil6eEEIIId4TFxcHrVbb5jyCipDy8nIsXboU7733Hj799NNW5yssLERoaCjmz5+PwsJCdOjQAbNmzcLkyZN5r8tRPfXr1w9BQUFCmqkINpsNp06d8tn2ixWo/Qao74HY90DtNxC4fQ/UfgP8++6Yz9VZEEBAEWK32/Hiiy9i9uzZ6Nu3b5vzWiwWxMfHY/78+ejduzfy8vKQkZGB0NBQP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>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"#Visualising the clusters\n",
|
||
|
"plt.scatter(x[y_kmeans == 0, 0], x[y_kmeans == 0, 1], s = 100, c = 'purple', label = 'Iris-setosa')\n",
|
||
|
"plt.scatter(x[y_kmeans == 1, 0], x[y_kmeans == 1, 1], s = 100, c = 'orange', label = 'Iris-versicolour')\n",
|
||
|
"plt.scatter(x[y_kmeans == 2, 0], x[y_kmeans == 2, 1], s = 100, c = 'green', label = 'Iris-virginica')\n",
|
||
|
"\n",
|
||
|
"#Plotting the centroids of the clusters\n",
|
||
|
"plt.scatter(kmeans.cluster_centers_[:, 0], kmeans.cluster_centers_[:,1], s = 100, c = 'red', label = 'Centroids')\n",
|
||
|
"\n",
|
||
|
"plt.legend()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 29,
|
||
|
"id": "60bfa195-09d2-40d0-b8b8-aaf795eeef73",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJcAAASXCAYAAABcCZ7oAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9a4wra1offP+rfCrb3Xaf1urudV7LPRsyzw7JvAwwzMO8DwiC0JBMJgrKR6RISIRRQKNEgKIJiphIE0Q2fBgEypcIvvCBIIIS6UVhv9LzCkgY2AkzPDzviMPM7EPb3ba73XaffCpX1f186Llrld12t6ts1/H/k7Zg9uq92n27qlz17+u6bkUIIUBEREREREREROSBGvQLICIiIiIiIiKi6GK4REREREREREREnjFcIiIiIiIiIiIizxguERERERERERGRZwyXiIiIiIiIiIjIM4ZLRERERERERETkGcMlIiIiIiIiIiLyjOESERERERERERF5xnCJiIiIiIiIiIg8Y7hERERERERERESeMVwiIiIiIiIiIiLPGC4REREREREREZFnDJeIiIiIiIiIiMgzhktEREREREREROQZwyUiIiIiIiIiIvKM4RIREREREREREXnGcImIiIiIiIiIiDxjuERERERERERERJ4xXCIiIiIiIiIiIs8YLhERERERERERkWcMl4iIiIiIiIiIyDOGS0RERERERERE5BnDJSIiIiIiIiIi8ozhEhERERERERERecZwiYiIiIiIiIiIPGO4REREREREREREnjFcIiIiIiIiIiIizxguERERERERERGRZwyXiIiIiIiIiIjIM4ZLRERERERERETkGcMlIiIiIiIiIiLyjOESERERERERERF5xnCJiIiIiIiIiIg8Y7hERERERERERESeMVwiIiIiIiIiIiLPGC4REREREREREZFnDJeIiIiIiIiIiMgzhktEREREREREROQZwyUiIiIiIiIiIvKM4RIREREREREREXnGcImIiIiIiIiIiDxjuERERERERERERJ4xXCIiIiIiIiIiIs8YLhERERERERERkWcMl4iIiIiIiIiIyDOGS0RERERERERE5BnDJSIiIiIiIiIi8ozhEhERERERERERecZwiYiIiIiIiIiIPGO4REREREREREREnjFcIiIiIiIiIiIizxguERERERERERGRZwyXiIiIiIiIiIjIM4ZLRERERERERETkGcMlIiIiIiIiIiLyjOESERERERERERF5xnCJiIiIiIiIiIg8Y7hERERERERERESeMVwiIiIiIiIiIiLPGC4REREREREREZFnDJeIiIiIiIiIiMgzhktEREREREREROQZwyUiIiIiIiIiIvKM4RIREREREREREXnGcImIiIiIiIiIiDxjuERERERERERERJ4xXCIiIiIiIiIiIs8YLhERERERERERkWcMl4iIiIiIiIiIyDOGS0RERERERERE5BnDJSIiIiIiIiIi8ozhEhERERERERERecZwiYiIiIiIiIiIPGO4REREREREREREnjFcIiIiIiIiIiIizxguERERERERERGRZwyXiIiIiIiIiIjIM4ZLRERERERERETkGcMlIiIiIiIiIiLyjOESERERERERERF5xnCJiIiIiIiIiIg8Y7hERERERERERESeMVwiIiIiIiIiIiLPGC4REREREREREZFnDJeIiIiIiIiIiMgzhktEREREREREROQZwyUiIiIiIiIiIvKM4RIREREREREREXnGcImIiIiIiIiIiDxjuERERERERERERJ4xXCIiIiIiIiIiIs8YLhERERERERERkWcMl4iIiIiIiIiIyDOGS0RERERERERE5BnDJSIiIiIiIiIi8ozhEhERERERERERecZwiYiIiIiIiIiIPGO4REREtAJCCJimCSFE0C+FiIiIiGil0kG/ACIiorixLAuGYaDX60FRFKTTaaTTaaRSKaRSKSiKEvRLJCIiIiJaGkXwV6pERERLIYSAZVkYjUawLAu6rkMIASGEHSipqopMJoNUKoV0Og1VVRk2EREREVGkMVwiIiJaAiEEDMOAYRj2v9N1HYqiQFEUO2SSARQAKIpih02ysolhExERERFFDcMlIiKiBclqJdM07cBIVi7JcGnSrLBJVjQxbCIiIiKiqGC4RERE5JEc2m0YBizLGguChBAYDoczw6VpfxfDJiIiIiKKIoZLREREHggh7GolALdCJCEEdF23/8zL3z/5j6qqUFWVYRMRERERhQrDJSIiIpdky9tktZLTouHStL/PWdUk/16GTUREREQUtHTQL4CIiCgqZKvb9fU1CoWCr0GOrIxSVdV+Lc62PPnnk21087blERERERF5xXCJiIhoDrINrtvt4ujoCN/yLd8SaGgzK2wyDAOj0YhhExERERH5huESERHRPUzTxGg0stvghBChC2jchE2ZTAapVMpuoyMiIiIiWgTDJSIiohlkOGMYBgBEap7RvGGTs6qJYRMRERERecFwiYiIaArLsuxqJQB26KIoCqK4F8assGk0GtmDxyeHgzNsIiIiIqJ5MFwiIiJykDuyOdvgolKt5Ma0sEn+3Lqus7KJiIiIiObGcImIiOibZCWPaZoAprfBRbVy6T5yHpPkDJtGo5H9Nc6wKZ1OxzJ4IyIiIiJ3GC4RERHhdRucaZqxrVZy466wSVY2qap6a0B40teNiIiIKIkYLhERUaIJIWCaJgzDmKsNLq6VS/eZN2yabKNj2EREREQUfwyXiIgoseZpg1tEnIMoZ9gkf0bLsqDrOobDIcMmIiIiogRhuERERIlkmqanod3y64QQDEq+Sa7DfWGTYR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JNrowh7FEREQUfwyXiIgoMM5Bx1Fqg5u3conVTbQo566DzqCJYRMRERGFCcMlIiIKRNiHdhOF0bxhUyqVGhsQzvOLiIiIVonhEhER+U5WK5mmGcmHXs5c8o7rtlyzwib
|
||
|
"text/plain": [
|
||
|
"<Figure size 1500x1500 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# 3d scatterplot using matplotlib\n",
|
||
|
"\n",
|
||
|
"fig = plt.figure(figsize = (15,15))\n",
|
||
|
"ax = fig.add_subplot(111, projection='3d')\n",
|
||
|
"plt.scatter(x[y_kmeans == 0, 0], x[y_kmeans == 0, 1], s = 100, c = 'purple', label = 'Iris-setosa')\n",
|
||
|
"plt.scatter(x[y_kmeans == 1, 0], x[y_kmeans == 1, 1], s = 100, c = 'orange', label = 'Iris-versicolour')\n",
|
||
|
"plt.scatter(x[y_kmeans == 2, 0], x[y_kmeans == 2, 1], s = 100, c = 'green', label = 'Iris-virginica')\n",
|
||
|
"\n",
|
||
|
"#Plotting the centroids of the clusters\n",
|
||
|
"plt.scatter(kmeans.cluster_centers_[:, 0], kmeans.cluster_centers_[:,1], s = 100, c = 'red', label = 'Centroids')\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.12.3"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|