Created May 11, 2018 20:18
Save vihar/48739d02f0342159b74b03bd13d2410c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters # Importing Modules from sklearn.datasets import load_iris import matplotlib.pyplot as plt from sklearn.cluster import DBSCAN from sklearn.decomposition import PCA # Load Dataset iris = load_iris() # Declaring Model dbscan = DBSCAN() # Fitting dbscan.fit(iris.data) # Transoring Using PCA pca = PCA(n_components=2).fit(iris.data) pca_2d = pca.transform(iris.data) # Plot based on Class for i in range(0, pca_2d.shape[0]): if dbscan.labels_[i] == 0: c1 = plt.scatter(pca_2d[i, 0], pca_2d[i, 1], c='r', marker='+') elif dbscan.labels_[i] == 1: c2 = plt.scatter(pca_2d[i, 0], pca_2d[i, 1], c='g', marker='o') elif dbscan.labels_[i] == -1: c3 = plt.scatter(pca_2d[i, 0], pca_2d[i, 1], c='b', marker='*') plt.legend([c1, c2, c3], ['Cluster 1', 'Cluster 2', 'Noise']) plt.title('DBSCAN finds 2 clusters and Noise') plt.show()You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4