Feature/skmeans (#66)

* add PCA whitening parameter

* add FluidSKMeans

* SKMeans correction

* added RT query

* <fit>transform<point> -> <fit>encode<point>

* added to overview

Co-authored-by: Gerard <gerard@bumblebee.lan>
Co-authored-by: tremblap <info@pierrealexandretremblay.com>
nix
Gerard Roma 4 years ago committed by GitHub
parent 2982ba1bf6
commit 81110de196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,136 @@
FluidSKMeans : FluidModelObject {
var clusters, threshold, maxiter;
*new {|server, numClusters = 4, encodingThreshold = 0.25, maxIter = 100|
^super.new(server,[numClusters,maxIter, encodingThreshold])
.numClusters_(numClusters)
.encodingThreshold_(encodingThreshold)
.maxIter_(maxIter);
}
numClusters_{|n| clusters = n.asInteger}
numClusters{ ^clusters }
encodingThreshold_{|t| threshold = t.asFloat}
encodingThreshold{ ^threshold }
maxIter_{|i| maxiter = i.asInteger}
maxIter{ ^maxiter }
prGetParams{^[this.id,this.numClusters, this.encodingThreshold, this.maxIter];}
fitMsg{ |dataSet| ^this.prMakeMsg(\fit,id,dataSet.id);}
fit{|dataSet, action|
actions[\fit] = [
numbers( FluidMessageResponse, _, this.numClusters ,_),
action
];
this.prSendMsg(this.fitMsg(dataSet));
}
fitPredictMsg{|dataSet, labelSet|
^this.prMakeMsg(\fitPredict, id, dataSet.id, labelSet.id)
}
fitPredict{|dataSet, labelSet,action|
actions[\fitPredict] = [
numbers(FluidMessageResponse, _, this.numClusters, _),
action
];
this.prSendMsg(this.fitPredictMsg(dataSet,labelSet));
}
predictMsg{|dataSet, labelSet|
^this.prMakeMsg(\predict, id, dataSet.id, labelSet.id)
}
predict{ |dataSet, labelSet, action|
actions[\predict] = [
numbers(FluidMessageResponse, _, this.numClusters, _),
action
];
this.prSendMsg(this.predictMsg(dataSet,labelSet));
}
predictPointMsg{|buffer|
^this.prMakeMsg(\predictPoint, id, this.prEncodeBuffer(buffer))
}
predictPoint { |buffer, action|
actions[\predictPoint] = [number(FluidMessageResponse,_,_),action];
this.prSendMsg(this.predictPointMsg(buffer))
}
fitEncodeMsg{|srcDataSet, dstDataSet|
^this.prMakeMsg(\fitEncode, id, srcDataSet.id, dstDataSet.id)
}
fitEncode{|srcDataSet, dstDataSet,action|
actions[\fitEncode] = [nil,action];
this.prSendMsg(this.fitEncodeMsg(srcDataSet,dstDataSet));
}
encodeMsg{|srcDataSet, dstDataSet|
^this.prMakeMsg(\encode, id, srcDataSet.id, dstDataSet.id)
}
encode{ |srcDataSet, dstDataSet, action|
actions[\encode] = [nil,action];
this.prSendMsg(this.encodeMsg(srcDataSet,dstDataSet));
}
encodePointMsg{ |sourceBuffer, targetBuffer|
^this.prMakeMsg(\encodePoint, id,
this.prEncodeBuffer(sourceBuffer),
this.prEncodeBuffer(targetBuffer),
["/b_query", targetBuffer.asUGenInput]);
}
encodePoint { |sourceBuffer, targetBuffer, action|
actions[\encodePoint] = [nil,{action.value(targetBuffer)}];
this.prSendMsg(this.encodePointMsg(sourceBuffer, targetBuffer));
}
getMeansMsg{|dataSet| ^this.prMakeMsg(\getMeans, id, dataSet.asUGenInput) }
getMeans{ |dataSet, action|
actions[\getMeans] = [nil, action];
this.prSendMsg(this.getMeansMsg(dataSet));
}
setMeansMsg{|dataSet| ^this.prMakeMsg(\setMeans, id, dataSet.asUGenInput) }
setMeans{ |dataSet, action|
actions[\setMeans] = [nil, action];
this.prSendMsg(this.setMeansMsg(dataSet));
}
clearMsg{ ^this.prMakeMsg(\clear, id) }
clear{ |action|
actions[\clear] = [nil, action];
this.prSendMsg(this.clearMsg);
}
kr{|trig, inputBuffer,outputBuffer|
^FluidSKMeansQuery.kr(trig,
this,
this.prEncodeBuffer(inputBuffer),
this.prEncodeBuffer(outputBuffer));
}
}
FluidSKMeansQuery : FluidRTMultiOutUGen {
*kr{ |trig, model,inputBuffer, outputBuffer |
^this.multiNew('control',trig, model.asUGenInput,inputBuffer.asUGenInput, outputBuffer.asUGenInput)
}
init { arg ... theInputs;
inputs = theInputs;
^this.initOutputs(1, rate);
}
}

@ -99,6 +99,7 @@ table::
##link::Classes/FluidPCA:: || Principal Component Analysis for preprocessing and dimension reduction
##link::Classes/FluidMDS:: || Multidimensional Scaling for dimension reduction
##link::Classes/FluidKMeans:: || K-Means clustering
##link::Classes/FluidSKMeans:: || Spherical K-Means clustering
##link::Classes/FluidUMAP:: || Dimension reduction with UMAP algorithm
##link::Classes/FluidGrid:: || Transform a data set of two dimensional points into a two dimensional grid using the Munkres Algorithm.
::

@ -1,5 +1,6 @@
makeSCWrapper<RTKDTreeQueryClient>("FluidKDTreeQuery",inTable);
makeSCWrapper<RTKMeansQueryClient>("FluidKMeansQuery",inTable);
makeSCWrapper<RTSKMeansQueryClient>("FluidSKMeansQuery",inTable);
makeSCWrapper<RTKNNClassifierQueryClient>("FluidKNNClassifierQuery",inTable);
makeSCWrapper<RTKNNRegressorQueryClient>("FluidKNNRegressorQuery",inTable);
makeSCWrapper<RTNormalizeQueryClient>("FluidNormalizeQuery",inTable);

Loading…
Cancel
Save