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
MVVMReactiveCocoa - GitBucket iOS A 2017-02-19
ios-webkit-debug-proxy - A DevTools proxy (Chrome Remote Debugging Protocol... 2017-02-19
jump.js - A modern smooth scrolling library. ... 2017-02-19
GoSublime - A Golang plugin collection for SublimeText **3**, ... 2017-02-19
awesome-emacs - A community driven list of useful Emacs packages, ... 2017-02-19
RKNotificationHub - Make any UIView a full fledged notification center 2017-02-19
vimr - Project VimR - Refined Neovim experience for macOS... 2017-02-19
vue-admin - Vue Admin Panel Framework, Powered by Vue 2.0 and ... 2017-02-19
dev-setup - Mac OS X development environment setup: Easy-to-un... 2017-02-19
CMPopTipView - Custom UIView for iOS that pops up an animated "bu... 2017-02-19

 Back to top