Created
December 1, 2017 11:11
-
-
Save ronekko/99932362a9fc78e2edf3aa30b81360fb 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 Mon Jun 29 14:55:33 2015 | |
@author: sakurai | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn import preprocessing | |
def generate_clustering_data(): | |
N, D, K = 100, 2, 4 | |
X = [] | |
X_k = np.random.randn(N, D) * [50, 1] + [0, 10] + [0, -100] | |
X.append(X_k) | |
X_k = np.random.randn(N, D) * [50, 1] + [0, -10] + [0, -100] | |
X.append(X_k) | |
X_k = np.random.randn(N, D) * [1, 50] + [10, 0] + [0, 100] | |
X.append(X_k) | |
X_k = np.random.randn(N, D) * [1, 50] + [-10, 0] + [0, 100] | |
X.append(X_k) | |
X = np.concatenate(X) | |
np.random.shuffle(X) | |
return X | |
if __name__ == '__main__': | |
X = generate_clustering_data() | |
plt.plot(X[:, 0], X[:, 1], '.') | |
plt.title('Number of clusters is 4.') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment