| Server IP : 162.253.224.18 / Your IP : 216.73.217.120 Web Server : Apache System : Linux s18.infinitysrv.com 3.10.0-962.3.2.lve1.5.89.el7.x86_64 #1 SMP Thu Jul 9 15:55:31 UTC 2026 x86_64 User : dejavumk ( 1184) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /opt/alt/python35/lib64/python3.5/site-packages/sklearn/cluster/tests/ |
Upload File : |
"""
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 with regards to 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