Skip to content

Commit 3e23ef4

Browse files
committed
Fix Grid Search best model selection
1 parent cc27290 commit 3e23ef4

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
- 1.3.5
2+
- Fix Grid Search best model selection
3+
14
- 1.3.4
25
- Fix Decision Tree max height terminating condition
36

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@
9292
"config": {
9393
"preferred-install": "dist",
9494
"sort-packages": true,
95-
"process-timeout": 3000
95+
"process-timeout": 3000,
96+
"allow-plugins": {
97+
"phpstan/extension-installer": true
98+
}
9699
},
97100
"funding": [
98101
{

src/GridSearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public function train(Dataset $dataset) : void
284284

285285
$scores = $this->backend->process();
286286

287-
array_multisort($scores, $combinations, SORT_DESC);
287+
array_multisort($scores, SORT_DESC, $combinations);
288288

289289
$best = reset($combinations) ?: [];
290290

tests/GridSearchTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,13 @@ public function trainPredictBest() : void
140140
$score = $this->metric->score($predictions, $testing->labels());
141141

142142
$this->assertGreaterThanOrEqual(self::MIN_SCORE, $score);
143+
144+
$expectedBest = [
145+
'k' => 10,
146+
'weighted' => true,
147+
'kernel' => new Manhattan(),
148+
];
149+
150+
$this->assertEquals($expectedBest, $this->estimator->base()->params());
143151
}
144152
}

0 commit comments

Comments
 (0)