Skip to content

Commit c1bede9

Browse files
authored
Update SVR.php (RubixML#344)
1 parent 65251d9 commit c1bede9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Regressors/SVR.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,12 @@ public function predictSample(array $sample)
235235
if (!$this->model) {
236236
throw new RuntimeException('Estimator has not been trained.');
237237
}
238-
239-
return $this->model->predict($sample);
238+
//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
239+
$sampleWithOffset = [];
240+
foreach($sample as $key=>$value){
241+
$sampleWithOffset[$key+1] = $value;
242+
}
243+
return $this->model->predict($sampleWithOffset);
240244
}
241245

242246
/**

0 commit comments

Comments
 (0)