Created
August 11, 2015 05:09
-
-
Save cshjin/7eb0b4bb353be9af7935 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Jul 28 15:28:15 2015 | |
""" | |
from sklearn.cluster import KMeans | |
import numpy as np | |
import pandas | |
dataset = np.array([1, 4, 5, 6, 9]) | |
km = KMeans(n_clusters=3) | |
km.fit(dataset.reshape(-1, 1)) | |
df = pandas.DataFrame(pandas.Series(dataset), pandas.Series(km.labels_)).reset_index() | |
print df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment