Skip to content

Commit

Permalink
Merge pull request #269 from biostaz/gridsearch-best-params
Browse files Browse the repository at this point in the history
GridSearch score sorting
  • Loading branch information
andrewdalpino authored Dec 6, 2022
2 parents 4cda6bc + c98c00b commit 48624ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GridSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function train(Dataset $dataset) : void

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

array_multisort($scores, $combinations, SORT_DESC);
array_multisort($scores, SORT_DESC, $combinations);

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

Expand Down
8 changes: 8 additions & 0 deletions tests/GridSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,13 @@ public function trainPredictBest() : void
$score = $this->metric->score($predictions, $testing->labels());

$this->assertGreaterThanOrEqual(self::MIN_SCORE, $score);

$expectedBest = [
'k' => 10,
'weighted' => true,
'kernel' => new Manhattan(),
];

$this->assertEquals($expectedBest, $this->estimator->base()->params());
}
}

0 comments on commit 48624ad

Please sign in to comment.