-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverCluster.js
More file actions
26 lines (20 loc) · 1.1 KB
/
Copy pathserverCluster.js
File metadata and controls
26 lines (20 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Demo for unsupervised Machine Learning - K-Means Clustering (for more Info: http://joonku.com/project/machine_learning/apidoc#k_means )
// Clustering of music fans
var ml = require('machine_learning');
// Columns: Dataset of user: 0 stands for "Not listened" ; 1 stands for "listened"
var data = [
// Red Hot Chilli Peppers, Justin Bieber, System of a down, Eminem, David Guetta, WuTangClan, Lady Gaga, Daft Punk
[1, 0, 1, 0, 0, 0, 0, 0], // User 0(Rock)
[1, 0, 1, 1, 0, 1, 0, 0], // User 1 (Rock & Hip Hop)
[0, 0, 0, 1, 0, 1, 0, 0], // User 2 (Hip Hop)
[0, 0, 0, 0, 1, 0, 0, 1], // User 3 (Electro)
[0, 1, 0, 0, 1, 0, 1, 1], // User 4 (Electro & Pop)
[0, 1, 0, 0, 0, 0, 1, 0], // User 5 (Pop)
];
var result = ml.kmeans.cluster({
data : data,
k : 2, //Number Groups
epochs:20, // Numper epochs
distance : {type : "pearson"} // alternative : {type : 'euclidean'}
});
console.log("Clustered Datasets: ", result.clusters);