Skip to content

Commit

Permalink
Added: Simple test for SklearnOptimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Caparrini committed Feb 24, 2024
1 parent 6d7eaf9 commit c5afd5d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mloptimizer/test/test_genoptimizer/test_meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest
from mloptimizer import SklearnOptimizer, Hyperparam
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_iris

default_hyperparams = {
"min_samples_split": Hyperparam("min_samples_split", 2, 50, int),
"min_samples_leaf": Hyperparam("min_samples_leaf", 1, 20, int),
"max_depth": Hyperparam("max_depth", 2, 20, int),
"min_impurity_decrease": Hyperparam("min_impurity_decrease", 0, 150, float, 1000),
"ccp_alpha": Hyperparam("ccp_alpha", 0, 300, float, 100000)
}


def test_mloptimizer():
X, y = load_iris(return_X_y=True)

Check notice on line 16 in mloptimizer/test/test_genoptimizer/test_meta.py

View workflow job for this annotation

GitHub Actions / Qodana Community for Python

PEP 8 naming convention violation

Variable in function should be lowercase
mlopt = SklearnOptimizer(clf_class=DecisionTreeClassifier, custom_hyperparams=default_hyperparams,
features=X, labels=y)
mlopt.optimize_clf(5, 5)
assert mlopt is not None

0 comments on commit c5afd5d

Please sign in to comment.