def generate_data(N, seed=10):
""" This generates some test data that we can use to test our pairwise-
distance functions.
Required arguments:
N -- The number of datapoints in the test data.
Optional arguments:
seed -- The seed for NumPy's random module.
"""
# Generate some data:
np.random.seed(seed)
n_samples1 = N * 3 // 4 # same as floor(3/4 * N)
n_samples2 = N - n_samples1
# Blob set 1
centers1 = [[0., 0.],
[1., 0.],
[0.5, np.sqrt(0.75)]]
cluster_std1 = [0.3] * len(centers1)
data, _ = make_blobs(n_samples=n_samples1,
centers=centers1,
cluster_std=cluster_std1)
# Make sure Blob 1 checks out
# Blob set 2
centers2 = [[0.5, np.sqrt(0.75)]]
cluster_std2 = [0.3] * len(centers2)
extra, _ = make_blobs(n_samples=n_samples2,
centers=centers2,
cluster_std=cluster_std2)
return np.concatenate((data, extra), axis=0)
test_pairwise_distance.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录