You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
FluidKNNClassifier : FluidRealTimeModel {
|
|
|
|
var <>numNeighbours, <>weight;
|
|
|
|
*new {|server, numNeighbours = 3, weight = 1|
|
|
^super.new(server,[numNeighbours,weight])
|
|
.numNeighbours_(numNeighbours)
|
|
.weight_(weight);
|
|
}
|
|
|
|
prGetParams{^[this.numNeighbours,this.weight,-1,-1];}
|
|
|
|
fitMsg{|dataSet, labelSet|
|
|
^this.prMakeMsg(\fit, id, dataSet.id, labelSet.id)
|
|
}
|
|
|
|
fit{|dataSet, labelSet, action|
|
|
actions[\fit] = [nil,action];
|
|
this.prSendMsg(this.fitMsg(dataSet, labelSet));
|
|
}
|
|
|
|
predictMsg{|dataSet, labelSet|
|
|
^this.prMakeMsg(\predict, id, dataSet.id, labelSet.id)
|
|
}
|
|
|
|
predict{|dataSet, labelSet, action|
|
|
actions[\predict] = [nil, action];
|
|
this.prSendMsg(this.predictMsg(dataSet, labelSet));
|
|
}
|
|
|
|
predictPointMsg{|buffer|
|
|
^this.prMakeMsg(\predictPoint, id, this.prEncodeBuffer(buffer))
|
|
}
|
|
|
|
predictPoint {|buffer, action|
|
|
actions[\predictPoint] = [string(FluidMessageResponse,_,_),action];
|
|
this.prSendMsg(this.predictPointMsg(buffer));
|
|
}
|
|
|
|
kr{|trig, inputBuffer,outputBuffer|
|
|
^FluidProxyUgen.kr(this.class.name.asString++'/query', K2A.ar(trig),
|
|
id, this.numNeighbours, this.weight,
|
|
this.prEncodeBuffer(inputBuffer),
|
|
this.prEncodeBuffer(outputBuffer));
|
|
}
|
|
|
|
}
|