Inhaltsverzeichnis Kapitel 1: Lineares Regressionsmodell [Kapitel 2: Nichtlineares Regressionsmodell] (https://qiita.com/matsukura04583/items/baa3f2269537036abc57) [Kapitel 3: Logistisches Regressionsmodell] (https://qiita.com/matsukura04583/items/0fb73183e4a7a6f06aa5) [Kapitel 4: Hauptkomponentenanalyse] (https://qiita.com/matsukura04583/items/b3b5d2d22189afc9c81c) [Kapitel 5: Algorithmus 1 (k-Nachbarschaftsmethode (kNN))] (https://qiita.com/matsukura04583/items/543719b44159322221ed) [Kapitel 6: Algorithmus 2 (k-Mittel)] (https://qiita.com/matsukura04583/items/050c98c7bb1c9e91be71) [Kapitel 7: Support Vector Machine] (https://qiita.com/matsukura04583/items/6b718642bcbf97ae2ca8)
#https://datahexa.com/kmeans-clustering-with-wine-dataset/Referenz
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import cluster, preprocessing, datasets
from sklearn.cluster import KMeans
wine = datasets.load_wine()
X = wine.data
X.shape
Ergebnis
y=wine.target
y.shape
Ergebnis
(178,)
wine.target_names
Ergebnis
array(['class_0', 'class_1', 'class_2'], dtype='<U7')
model = KMeans(n_clusters=3)
labels = model.fit_predict(X)
df = pd.DataFrame({'labels': labels})
type(df)
Ergebnis
pandas.core.frame.DataFrame
def species_label(theta):
if theta == 0:
return wine.target_names[0]
if theta == 1:
return wine.target_names[1]
if theta == 2:
return wine.target_names[2]
df['species'] = [species_label(theta) for theta in wine.target]
pd.crosstab(df['labels'], df['species'])
Verwandte Seiten Kapitel 1: Lineares Regressionsmodell [Kapitel 2: Nichtlineares Regressionsmodell] (https://qiita.com/matsukura04583/items/baa3f2269537036abc57) [Kapitel 3: Logistisches Regressionsmodell] (https://qiita.com/matsukura04583/items/0fb73183e4a7a6f06aa5) [Kapitel 4: Hauptkomponentenanalyse] (https://qiita.com/matsukura04583/items/b3b5d2d22189afc9c81c) [Kapitel 5: Algorithmus 1 (k-Nachbarschaftsmethode (kNN))] (https://qiita.com/matsukura04583/items/543719b44159322221ed) [Kapitel 6: Algorithmus 2 (k-Mittel)] (https://qiita.com/matsukura04583/items/050c98c7bb1c9e91be71) [Kapitel 7: Support Vector Machine] (https://qiita.com/matsukura04583/items/6b718642bcbf97ae2ca8)
Recommended Posts