You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewError('invalid input argument. Output vector length must match the number of data points. Expected: '+x.shape[0]+'. Actual: '+o.length+'.');
273
+
}else{
274
+
o=createVector(x.shape[0],false);// high-level
275
+
}
276
+
if(init){
277
+
returnnull;
278
+
}
279
+
cbuf=centroids.data;
280
+
sc=centroids.strides[0];
250
281
251
-
// TODO: (prediction) compute distances and assign data points to centroids
282
+
xbuf=x.data;
283
+
npts=x.shape[0];
284
+
sx1=x.strides[0];
285
+
sx2=x.strides[1];
286
+
ox=x.offset;
252
287
253
-
returnout;
288
+
// For each data point, find the closest centroid...
289
+
for(i=0;i<npts;i++){
290
+
c=closestCentroid(dist,k,ndims,cbuf,sc,0,xbuf,sx2,ox);// Magic number `0` for offset as we know that the matrix view begins at the first buffer element
291
+
292
+
// Update the output vector:
293
+
o.set(i,c);
294
+
295
+
// Compute the data point buffer index offset to point to the next data point:
0 commit comments