From 21c4311471ebe66e25a883b86175a9b093375052 Mon Sep 17 00:00:00 2001 From: tremblap Date: Tue, 21 Feb 2023 11:59:39 +0000 Subject: [PATCH] Knnregressor multiout (#153) Amend `KNNRegressor` to multi-dimensional mapping --- .../Classes/FluidKNNRegressor.sc | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/release-packaging/Classes/FluidKNNRegressor.sc b/release-packaging/Classes/FluidKNNRegressor.sc index 992b67e..5f009e5 100644 --- a/release-packaging/Classes/FluidKNNRegressor.sc +++ b/release-packaging/Classes/FluidKNNRegressor.sc @@ -23,23 +23,27 @@ FluidKNNRegressor : FluidModelObject { ^this.prMakeMsg(\predict,this.id,sourceDataSet.id,targetDataSet.id) } - predict{ |sourceDataSet, targetDataSet,action| + predict{ |sourceDataSet, targetDataSet, action| actions[\predict] = [nil, action]; this.prSendMsg(this.predictMsg(sourceDataSet, targetDataSet)); } - predictPointMsg { |buffer| - ^this.prMakeMsg(\predictPoint,id, this.prEncodeBuffer(buffer)); + predictPointMsg { |sourceBuffer, targetBuffer| + ^this.prMakeMsg(\predictPoint,id, + this.prEncodeBuffer(sourceBuffer), + this.prEncodeBuffer(targetBuffer), + ["/b_query", targetBuffer.asUGenInput]); } - predictPoint { |buffer, action| - actions[\predictPoint] = [number(FluidMessageResponse,_,_),action]; - this.prSendMsg(this.predictPointMsg(buffer)); + predictPoint { |sourceBuffer, targetBuffer, action| + actions[\predictPoint] = [nil,{action.value(targetBuffer)}]; + this.predictPointMsg(sourceBuffer, targetBuffer); + this.prSendMsg(this.predictPointMsg(sourceBuffer, targetBuffer)); } - kr{|trig, inputBuffer,outputBuffer| + kr{|trig, inputBuffer, outputBuffer, numNeighbours, weight| ^FluidKNNRegressorQuery.kr(K2A.ar(trig), - this, this.numNeighbours, this.weight, + this, numNeighbours??{this.numNeighbours}, weight??{this.weight}, this.prEncodeBuffer(inputBuffer), this.prEncodeBuffer(outputBuffer)); }