BVB Source Codes

golearn Show gen_test.py Source code

Return Download golearn: download gen_test.py Source code - Download golearn Source code - Type:.py
  1. #
  2. # Generate sample data for the DBSCAN test
  3. #
  4. # Lifted from http://scikit-learn.org/stable/auto_examples/cluster/plot_dbscan.html#example-cluster-plot-dbscan-py
  5. #
  6.  
  7. import numpy as np
  8.  
  9. from sklearn.cluster import DBSCAN
  10. from sklearn import metrics
  11. from sklearn.datasets.samples_generator import make_blobs
  12. from sklearn.preprocessing import StandardScaler
  13.  
  14. centers = [[1, 1], [-1, -1], [1, -1]]
  15. X, labels_true = make_blobs(n_samples=750, centers=centers, cluster_std=0.4,
  16.     random_state=0)
  17.  
  18. X = StandardScaler().fit_transform(X)
  19. X = X.astype(np.float64)
  20. db = DBSCAN(eps=0.3, min_samples=10, metric='l2', algorithm='brute').fit(X)
  21. core_samples_mask = np.zeros_like(db.labels_, dtype=bool)
  22. core_samples_mask[db.core_sample_indices_] = True
  23. labels = db.labels_
  24.  
  25. with open('dbscan.csv', 'w') as fscanout:
  26.     with open('dbscan_labels.csv', 'w') as fscanlabout:
  27.         for i in range(750):
  28.             fscanout.write(",".join([str(x) for x in X[i,:]]) + "\n")
  29.             fscanlabout.write(str(labels[i]) + "\n")
  30.  
  31.  
downloadgen_test.py Source code - Download golearn Source code
Related Source Codes/Software:
structor - An advanced visual editor for React components ... 2017-01-10
Workerman - An asynchronous event driven PHP framework for eas... 2017-01-10
waterline - An adapter-based ORM for Node.js with support for ... 2017-01-10
notepad-plus-plus - Notepad++ official repository h... 2017-01-10
che - Eclipse Che: Next-generation Eclipse IDE. Open sou... 2017-01-10
poisontap - Exploits locked/password protected computers over ... 2017-01-10
kcptun - A Simple UDP Tunnel Based On KCP 2017-01-11
svelte - The magical disappearing UI framework ... 2017-01-11
androidmvp - MVP Android Example 2017-01-11
IGListKit - A data-driven UICollectionView framework for build... 2017-01-11
mongo-express - Web-based MongoDB admin interface, written with No... 2017-05-17
XCL-Charts - Android charting libraries (XCL-Charts is a free c... 2017-05-17
scrollMonitor - A simple and fast API to monitor elements as you s... 2017-05-16
XCDYouTubeKit - YouTube video player for iOS, tvOS and macOS 2017-05-16
rails-erd - Generate Entity-Relationship Diagrams for Rails ap... 2017-05-16
np - A better `npm publish` 2017-05-16
android - Smartisan open source code for full build.(repo ma... 2017-05-16
word_cloud - A little word cloud generator in Pytho 2017-05-16
mobileplayer-ios - 2017-05-16
Destroy-Windows-10-Spying - Destroy Windows Spying tool ... 2017-05-15

 Back to top