From c1bede91e264c0421e5fad5fdfea4ff16af933a0 Mon Sep 17 00:00:00 2001 From: Louis AUTHIE <65625876+LouisAUTHIE@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:37:43 +0200 Subject: [PATCH] Update SVR.php (#344) --- 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); } /**