From 146a0c84cc0653ca4258f0cc5b55a85bff5b1420 Mon Sep 17 00:00:00 2001 From: Louis AUTHIE <65625876+LouisAUTHIE@users.noreply.github.com> Date: Tue, 27 Aug 2024 14:14:44 +0200 Subject: [PATCH] Update SVR.php --- src/Regressors/SVR.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Regressors/SVR.php b/src/Regressors/SVR.php index 4bf161bf0..05d90c615 100644 --- a/src/Regressors/SVR.php +++ b/src/Regressors/SVR.php @@ -235,8 +235,12 @@ public function predictSample(array $sample) if (!$this->model) { throw new RuntimeException('Estimator has not been trained.'); } - - return $this->model->predict($sample); + //As SVM needs to have the same keys and order between training samples and those to predict we need to put an offset to the keys + $sampleWithOffset = []; + foreach($sample as $key=>$value){ + $sampleWithOffset[$key+1] = $value; + } + return $this->model->predict($sampleWithOffset); } /**