Let's say you open this notebook after taking a few days off. You wonder, How did I make that scatter plot? Didn't I have a better version of it? And can I get clean this code without breaking things?
The problem is that the cells are out of order and code was overwritten.
nbgather, you can answer these questions!
You can gather code for any
nbgather was installed. Try it by producing defining some variables and displaying some results.
Learn more about these tools and leave feedback at the nbgather site.
kmeans = KMeans(n_clusters=4) clusters = kmeans.fit(data).labels_
scatter(petal_length, petal_width, c=clusters)
<matplotlib.collections.PathCollection at 0x11e5cdb38>
from matplotlib.pyplot import scatter from sklearn.cluster import KMeans from sklearn import datasets
data = datasets.load_iris().data[:,2:4] petal_length, petal_width = data[:,0], data[:,1]
petal_length, petal_width = data[:,1], data[:,0]
print("Average petal length: %.3f" % (sum(petal_length) / len(petal_length),))
Average petal length: 3.758