scikit-learn Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

Creating a dataset for clustering

Clusters will also be covered. There are actually several functions to create datasets that can be modeled by different cluster algorithms.

  1. For example, blobs are very easy to create and can be modeled by k-means:
blobs_data, blobs_target = d.make_blobs()
  1. This will look like the following:
import matplotlib.pyplot as plt
%matplotlib inline
#Within an Ipython notebook
plt.scatter(blobs_data[:,0],blobs_data[:,1],c = blobs_target)