def plot_learing_curve(clf, train_x, train_y): ''' clf :estimator . ''' a = learning_curve(clf, train_x, train_y, verbose=1) plt.plot(a[0], a[1].mean(axis=1), label='train') plt.plot(a[0], a[2].mean(axis=1), label='eval') plt.legend() plt.show()
s=100, c='blue', label='Cluster 2') plt.scatter(x[y_hc == 2, 0], x[y_hc == 2, 1], s=100, c='green', label='Cluster 3') plt.scatter(x[y_hc == 3, 0], x[y_hc == 3, 1], s=100, c='cyan', label='Cluster 4') plt.scatter(x[y_hc == 4, 0], x[y_hc == 4, 1], s=100, c='magenta', label='Cluster 5') plt.scatter(kmeans.cluster_centers_[:, 0], kmeans.cluster_centers_[:, 1], s=300, c='yellow', label='Centroids') plt.title('Clusters of customers') plt.xlabel('Annual Income (k$)') plt.ylabel('Spending Score (1-100)') plt.legend() plt.show() # Dataset source: https://www.kaggle.com/shwetabh123/mall-customers