Permalink
Browse files

FIX : putting back common.py

  • Loading branch information...
1 parent b0ed0f3 commit e33f336fcb51288034f69ba83054f421c78c3aed @agramfort agramfort committed Aug 25, 2011
Showing with 27 additions and 0 deletions.
  1. +27 −0 scikits/learn/cluster/tests/common.py
View
27 scikits/learn/cluster/tests/common.py
@@ -0,0 +1,27 @@
+"""
+Common utilities for testing clustering.
+
+"""
+
+import numpy as np
+
+################################################################################
+# Generate sample data
+
+def generate_clustered_data(seed=0, n_clusters=3, n_features=2,
+ n_samples_per_cluster=20, std=.4):
+ prng = np.random.RandomState(seed)
+
+ # the data is voluntary shifted away from zero to check clustering
+ # algorithm robustness w.r.t. non centered data
+ means = np.array([[ 1, 1, 1, 0],
+ [-1, -1, 0, 1],
+ [ 1, -1, 1, 1],
+ [ -1, 1, 1, 0],
+ ]) + 10
+
+ X = np.empty((0, n_features))
+ for i in range(n_clusters):
+ X = np.r_[X, means[i][:n_features]
+ + std * prng.randn(n_samples_per_cluster, n_features)]
+ return X

3 comments on commit e33f336

@mblondel
scikit-learn member

What about moving it to the sample generator module?

@GaelVaroquaux
scikit-learn member
@agramfort
scikit-learn member

no it should be removed and the tests should use make_blobs which does the same. I started for some algos but it's not finished.

Please sign in to comment.