Skip to content

Commit

Permalink
added LogisticRegression to search space. (#67)
Browse files Browse the repository at this point in the history
Added LogisticRegression to the search space for classification.
  • Loading branch information
fmohr authored Sep 23, 2024
1 parent c6999af commit 3810b00
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
4 changes: 4 additions & 0 deletions python/naiveautoml/algorithm_selection/_sklearn_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ def score_func(X, y):
if clazz == sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis:
return sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis(**params)

if clazz == sklearn.linear_model.LogisticRegression:
params["dual"] = check_for_bool(params["dual"])
return sklearn.linear_model.LogisticRegression(**params)

if clazz == sklearn.neural_network.MLPClassifier:
max_iter = 512 # hard coded in auto-sklearn
hidden_layer_depth = int(params["hidden_layer_depth"])
Expand Down
37 changes: 37 additions & 0 deletions python/naiveautoml/searchspace-classification.json
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,43 @@
"json_format_version": 0.2
}
},
{
"class": "sklearn.linear_model.LogisticRegression",
"params": {
"hyperparameters": [
{
"name": "penalty",
"type": "categorical",
"choices": [
"l1",
"l2",
"elasticnet",
"None"
],
"default": "l2"
},
{
"name": "dual",
"type": "categorical",
"choices": [
"True",
"False"
],
"default": "False"
},
{
"name": "C",
"type": "uniform_float",
"log": true,
"lower": 0.03125,
"upper": 32768.0,
"default": 1.0
}
],
"conditions": [],
"forbiddens": []
}
},
{
"class": "sklearn.neural_network._multilayer_perceptron.MLPClassifier",
"params": {
Expand Down
2 changes: 1 addition & 1 deletion python/naiveautoml/searchspace-regression.json
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@
"name": "alpha",
"type": "uniform_float",
"log": true,
"lower": 1e-14,
"lower": 1e-10,
"upper": 1.0,
"default": 1e-08
},
Expand Down
2 changes: 1 addition & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy<2.0.0
pandas
scikit-learn>=1.3
configspace<0.7.1
configspace==1.2
scipy
pynisher
psutil
Expand Down
2 changes: 1 addition & 1 deletion python/test/test_naiveautoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def test_constant_algorithms_in_hpo_phase(self):
field = f"{step}_class"
class_in_phase1 = best_solution_in_phase_1[field]
class_in_phase2 = pd.unique(history[field])[0]
self.assertEquals(
self.assertEqual(
class_in_phase1,
class_in_phase2,
f"Choice for {step} should conicide but is {class_in_phase1} in AS phase and {class_in_phase2} in HPO."
Expand Down

0 comments on commit 3810b00

Please sign in to comment.