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
discover-flask - Full Stack Web Development with Flask. ... 2017-01-12
spring-mvc-showcase - Demonstrates the features of the Spring MVC web fr... 2017-01-12
tushare - TuShare is a utility for crawling historical data ... 2017-01-12
raml-spec - RAML Specification http://raml.... 2017-01-12
android-stackblur - Android StackBlur is a library that can perform a ... 2017-01-12
sound-redux - A Soundcloud client built with React / Redux ... 2017-01-12
httpstat - curl statistics made simple 2017-01-12
vim - Vim configuration file and plug-ins 2017-01-12
appframework - The definitive HTML5 mobile javascript framework ... 2017-01-12
BaiduExporter - Assistant for Baidu to export download links to ar... 2017-01-11

 Back to top