Comparing version 0.4.0 to 0.5.0
@@ -112,3 +112,5 @@ "use strict"; | ||
if (multi) { | ||
// Sum values and count for each centroid | ||
for (var _j2 = 0; _j2 < k; _j2++) { | ||
ks[_j2] = []; | ||
} // Sum values and count for each centroid | ||
for (var _i2 = 0; _i2 < len; _i2++) { | ||
@@ -122,6 +124,6 @@ for (var h = 0; h < multi; h++) { | ||
// and de distance between old and new centroids | ||
for (var _j2 = 0; _j2 < k; _j2++) { | ||
for (var _j3 = 0; _j3 < k; _j3++) { | ||
for (var _h = 0; _h < multi; _h++) { | ||
ks[_j2][_h] = sum[_j2][_h] / count[_j2] || 0; | ||
dif += old[_j2][_h] - ks[_j2][_h]; | ||
ks[_j3][_h] = sum[_j3][_h] / count[_j3] || 0; | ||
dif += old[_j3][_h] - ks[_j3][_h]; | ||
} | ||
@@ -139,5 +141,5 @@ } | ||
// and de distance between old and new centroids | ||
for (var _j3 = 0; _j3 < k; _j3++) { | ||
ks[_j3] = sum[_j3] / count[_j3] || 0; | ||
dif += old[_j3] - ks[_j3]; | ||
for (var _j4 = 0; _j4 < k; _j4++) { | ||
ks[_j4] = sum[_j4] / count[_j4] || 0; | ||
dif += old[_j4] - ks[_j4]; | ||
} | ||
@@ -144,0 +146,0 @@ } |
/*! skmeans 2017-06-08 */ | ||
"use strict";!function r(n,o,t){function e(a,i){if(!o[a]){if(!n[a]){var u="function"==typeof require&&require;if(!i&&u)return u(a,!0);if(f)return f(a,!0);var v=new Error("Cannot find module '"+a+"'");throw v.code="MODULE_NOT_FOUND",v}var s=o[a]={exports:{}};n[a][0].call(s.exports,function(r){var o=n[a][1][r];return e(o||r)},s,s.exports,r,n,o,t)}return o[a].exports}for(var f="function"==typeof require&&require,a=0;a<t.length;a++)e(t[a]);return e}({1:[function(r,n,o){!function(n){var o=r("./main.js");n.skmeans=o}(window)},{"./main.js":2}],2:[function(r,n,o){function t(r,n){for(var o=r.length,t=0,e=0;e<o;e++){var f=(r[e]||0)-(n[e]||0);t+=f*f}return Math.sqrt(t)}function e(r,n){for(var o=[],t=0;t<r;t++)o.push(n);return o}function f(r,n,o,f){var i=[],u=[],v=r.length,s=!1,c=f||a,h=r[0].length;if(o)i=o;else for(var l=0;l<n;l++)i.push(r[Math.floor(Math.random()*v)]);do{for(var p=0;p<v;p++){for(var d=1/0,x=0,m=0;m<n;m++){var q=h?t(r[p],i[m]):Math.abs(r[p]-i[m]);q<d&&(d=q,x=m)}u[p]=x}for(var w=[],M=[],g=[],O=0,j=0;j<n;j++)w[j]=0,M[j]=h?e(h,0):0,g[j]=i[j];if(h){for(var k=0;k<v;k++){for(var y=0;y<h;y++)M[u[k]][y]+=r[k][y];w[u[k]]++}for(var D=0;D<n;D++)for(var E=0;E<h;E++)i[D][E]=M[D][E]/w[D]||0,O+=g[D][E]-i[D][E]}else{for(var N=0;N<v;N++)M[u[N]]+=r[N],w[u[N]]++;for(var U=0;U<n;U++)i[U]=M[U]/w[U]||0,O+=g[U]-i[U]}s=0===O||--c<=0}while(!s);return{it:a-c,k:n,idxs:u,centroids:i}}var a=1e4;n.exports=f},{}]},{},[1]); | ||
"use strict";!function r(n,o,t){function e(a,i){if(!o[a]){if(!n[a]){var u="function"==typeof require&&require;if(!i&&u)return u(a,!0);if(f)return f(a,!0);var v=new Error("Cannot find module '"+a+"'");throw v.code="MODULE_NOT_FOUND",v}var s=o[a]={exports:{}};n[a][0].call(s.exports,function(r){var o=n[a][1][r];return e(o||r)},s,s.exports,r,n,o,t)}return o[a].exports}for(var f="function"==typeof require&&require,a=0;a<t.length;a++)e(t[a]);return e}({1:[function(r,n,o){!function(n){var o=r("./main.js");n.skmeans=o}(window)},{"./main.js":2}],2:[function(r,n,o){function t(r,n){for(var o=r.length,t=0,e=0;e<o;e++){var f=(r[e]||0)-(n[e]||0);t+=f*f}return Math.sqrt(t)}function e(r,n){for(var o=[],t=0;t<r;t++)o.push(n);return o}function f(r,n,o,f){var i=[],u=[],v=r.length,s=!1,c=f||a,h=r[0].length;if(o)i=o;else for(var l=0;l<n;l++)i.push(r[Math.floor(Math.random()*v)]);do{for(var p=0;p<v;p++){for(var d=1/0,x=0,m=0;m<n;m++){var q=h?t(r[p],i[m]):Math.abs(r[p]-i[m]);q<d&&(d=q,x=m)}u[p]=x}for(var w=[],M=[],g=[],O=0,j=0;j<n;j++)w[j]=0,M[j]=h?e(h,0):0,g[j]=i[j];if(h){for(var k=0;k<n;k++)i[k]=[];for(var y=0;y<v;y++){for(var D=0;D<h;D++)M[u[y]][D]+=r[y][D];w[u[y]]++}for(var E=0;E<n;E++)for(var N=0;N<h;N++)i[E][N]=M[E][N]/w[E]||0,O+=g[E][N]-i[E][N]}else{for(var U=0;U<v;U++)M[u[U]]+=r[U],w[u[U]]++;for(var _=0;_<n;_++)i[_]=M[_]/w[_]||0,O+=g[_]-i[_]}s=0===O||--c<=0}while(!s);return{it:a-c,k:n,idxs:u,centroids:i}}var a=1e4;n.exports=f},{}]},{},[1]); |
@@ -83,2 +83,4 @@ /*jshint esversion: 6 */ | ||
if(multi) { | ||
for(let j=0;j<k;j++) ks[j] = []; | ||
// Sum values and count for each centroid | ||
@@ -85,0 +87,0 @@ for(let i=0;i<len;i++) { |
{ | ||
"name": "skmeans", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Super fast simple kmeans clustering for unidimiensional data", | ||
@@ -5,0 +5,0 @@ "author": "David Gómez Matarrodona <solzimer@gmail.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22320
353