-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestData.py
More file actions
executable file
·35 lines (29 loc) · 831 Bytes
/
testData.py
File metadata and controls
executable file
·35 lines (29 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 23 2017
@author: ZZY
"""
import numpy as np
import random
from sklearn.datasets.samples_generator import make_blobs
from pandas import DataFrame
def genData():
"""
generate test data for clustering algorithms using make_blob
"""
# the number of samples
n_samples=random.randint(50,200)
# cluster centers
centers=[(3,2),(5,4),(7,6)]
# standard deviation of cluster
cluster_std=[0.5,0.5,0.5]
X,y=make_blobs(n_samples=n_samples,centers=centers,cluster_std=cluster_std)
df=DataFrame(X,columns=['A','B']).astype(np.float)
df=df.sort_values(['A'],ascending=True)
return df
info='YOUR_PATH'
for i in range(100):
# create test data
filename="%d.csv"%i
filepath=info+filename
genData().to_csv(filepath,index=False)