kmeans new functionalities - classes done, with help+doc+examples in progress
parent
3ec019e410
commit
4fbd3d2558
@ -1,70 +1,114 @@
|
|||||||
FluidKMeans : FluidRealTimeModel {
|
FluidKMeans : FluidRealTimeModel {
|
||||||
|
|
||||||
var clusters, maxiter;
|
var clusters, maxiter;
|
||||||
|
|
||||||
*new {|server, numClusters = 4, maxIter = 100|
|
*new {|server, numClusters = 4, maxIter = 100|
|
||||||
^super.new(server,[numClusters,maxIter])
|
^super.new(server,[numClusters,maxIter])
|
||||||
.numClusters_(numClusters)
|
.numClusters_(numClusters)
|
||||||
.maxIter_(maxIter);
|
.maxIter_(maxIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
numClusters_{|n| clusters = n.asInteger}
|
numClusters_{|n| clusters = n.asInteger}
|
||||||
numClusters{ ^clusters }
|
numClusters{ ^clusters }
|
||||||
|
|
||||||
maxIter_{|i| maxiter = i.asInteger}
|
maxIter_{|i| maxiter = i.asInteger}
|
||||||
maxIter{ ^maxiter }
|
maxIter{ ^maxiter }
|
||||||
|
|
||||||
prGetParams{^[this.numClusters,this.maxIter,-1,-1];}
|
prGetParams{^[this.numClusters,this.maxIter,-1,-1];}
|
||||||
|
|
||||||
fitMsg{ |dataSet| ^this.prMakeMsg(\fit,id,dataSet.id);}
|
fitMsg{ |dataSet| ^this.prMakeMsg(\fit,id,dataSet.id);}
|
||||||
|
|
||||||
fit{|dataSet, action|
|
fit{|dataSet, action|
|
||||||
actions[\fit] = [
|
actions[\fit] = [
|
||||||
numbers( FluidMessageResponse, _, this.numClusters ,_),
|
numbers( FluidMessageResponse, _, this.numClusters ,_),
|
||||||
action
|
action
|
||||||
];
|
];
|
||||||
this.prSendMsg(this.fitMsg(dataSet));
|
this.prSendMsg(this.fitMsg(dataSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
fitPredictMsg{|dataSet, labelSet|
|
fitPredictMsg{|dataSet, labelSet|
|
||||||
^this.prMakeMsg(\fitPredict, id, dataSet.id, labelSet.id)
|
^this.prMakeMsg(\fitPredict, id, dataSet.id, labelSet.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fitPredict{|dataSet, labelSet,action|
|
fitPredict{|dataSet, labelSet,action|
|
||||||
actions[\fitPredict] = [
|
actions[\fitPredict] = [
|
||||||
numbers(FluidMessageResponse, _, this.numClusters, _),
|
numbers(FluidMessageResponse, _, this.numClusters, _),
|
||||||
action
|
action
|
||||||
];
|
];
|
||||||
this.prSendMsg(this.fitPredictMsg(dataSet,labelSet));
|
this.prSendMsg(this.fitPredictMsg(dataSet,labelSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
predictMsg{|dataSet, labelSet|
|
predictMsg{|dataSet, labelSet|
|
||||||
^this.prMakeMsg(\predict, id, dataSet.id, labelSet.id)
|
^this.prMakeMsg(\predict, id, dataSet.id, labelSet.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
predict{ |dataSet, labelSet, action|
|
predict{ |dataSet, labelSet, action|
|
||||||
actions[\predict] = [
|
actions[\predict] = [
|
||||||
numbers(FluidMessageResponse, _, this.numClusters, _),
|
numbers(FluidMessageResponse, _, this.numClusters, _),
|
||||||
action
|
action
|
||||||
];
|
];
|
||||||
this.prSendMsg(this.predictMsg(dataSet,labelSet));
|
this.prSendMsg(this.predictMsg(dataSet,labelSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
predictPointMsg{|buffer|
|
predictPointMsg{|buffer|
|
||||||
^this.prMakeMsg(\predictPoint, id, this.prEncodeBuffer(buffer))
|
^this.prMakeMsg(\predictPoint, id, this.prEncodeBuffer(buffer))
|
||||||
}
|
}
|
||||||
|
|
||||||
predictPoint { |buffer, action|
|
predictPoint { |buffer, action|
|
||||||
actions[\predictPoint] = [number(FluidMessageResponse,_,_),action];
|
actions[\predictPoint] = [number(FluidMessageResponse,_,_),action];
|
||||||
this.prSendMsg(this.predictPointMsg(buffer))
|
this.prSendMsg(this.predictPointMsg(buffer))
|
||||||
}
|
}
|
||||||
|
|
||||||
kr{|trig, inputBuffer,outputBuffer|
|
fitTransformMsg{|srcDataSet, dstDataSet|
|
||||||
^FluidKMeansQuery.kr(K2A.ar(trig),
|
^this.prMakeMsg(\fitTransform, id, srcDataSet.id, dstDataSet.id)
|
||||||
this, clusters, maxiter,
|
}
|
||||||
this.prEncodeBuffer(inputBuffer),
|
|
||||||
this.prEncodeBuffer(outputBuffer));
|
fitTransform{|srcDataSet, dstDataSet,action|
|
||||||
|
actions[\fitTransform] = [nil,action];
|
||||||
|
this.prSendMsg(this.fitTransformMsg(srcDataSet,dstDataSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
transformMsg{|srcDataSet, dstDataSet|
|
||||||
|
^this.prMakeMsg(\transform, id, srcDataSet.id, dstDataSet.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
transform{ |srcDataSet, dstDataSet, action|
|
||||||
|
actions[\transform] = [nil,action];
|
||||||
|
this.prSendMsg(this.transformMsg(srcDataSet,dstDataSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
transformPointMsg{ |sourceBuffer, targetBuffer|
|
||||||
|
^this.prMakeMsg(\transformPoint, id,
|
||||||
|
this.prEncodeBuffer(sourceBuffer),
|
||||||
|
this.prEncodeBuffer(targetBuffer),
|
||||||
|
["/b_query", targetBuffer.asUGenInput]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transformPoint { |sourceBuffer, targetBuffer, action|
|
||||||
|
actions[\transformPoint] = [nil,{action.value(targetBuffer)}];
|
||||||
|
this.prSendMsg(this.transformPointMsg(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));
|
||||||
|
}
|
||||||
|
|
||||||
|
kr{|trig, inputBuffer,outputBuffer|
|
||||||
|
^FluidKMeansQuery.kr(K2A.ar(trig),
|
||||||
|
this, clusters, maxiter,
|
||||||
|
this.prEncodeBuffer(inputBuffer),
|
||||||
|
this.prEncodeBuffer(outputBuffer));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluidKMeansQuery : FluidRTQuery {}
|
FluidKMeansQuery : FluidRTQuery {}
|
||||||
|
|||||||
Loading…
Reference in New Issue