Created
June 13, 2020 08:24
-
-
Save yumaueno/2617319b0d00686ac48a9edcf1dba4a3 to your computer and use it in GitHub Desktop.
kmeans法をPythonで実装
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from sklearn.datasets import load_iris | |
from sklearn.cluster import KMeans | |
from sklearn.metrics import confusion_matrix | |
from sklearn.metrics import accuracy_score | |
iris = load_iris() | |
df = pd.DataFrame(iris.data, columns=iris.feature_names) | |
pred_cluster = KMeans(n_clusters=3).fit_predict(df) | |
confusion_matrix(iris.target,pred_cluster) | |
accuracy_score(iris.target,pred_cluster) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment