Skip to content

Commit

Permalink
fix unit test for the latest version of scikit-learn
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Dupre <[email protected]>
  • Loading branch information
xadupre committed Jan 23, 2024
1 parent 5edf1cf commit 5ace336
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
12 changes: 4 additions & 8 deletions tests/test_sklearn_array_feature_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class TestSklearnArrayFeatureExtractor(unittest.TestCase):
def test_array_feature_extractor(self):
data_to_cluster = pd.DataFrame(
[[1, 2, 3.5, 4.5], [1, 2, 1.7, 4.0], [2, 4, 2.4, 4.3], [2, 4, 2.5, 4.0]],
columns=[1, 2, 3, 4],
columns=["x1", "x2", "x3", "x4"],
)
cat_attributes_clustering = [1, 2]
num_attributes_clustering = [3, 4] # this is of length 12 in reality
cat_attributes_clustering = ["x1", "x2"]
num_attributes_clustering = ["x3", "x4"] # this is of length 12 in reality
gmm = GaussianMixture(n_components=2, random_state=1)
ohe_cat = [
OneHotEncoder(categories="auto", sparse_output=False, drop=None)
Expand All @@ -44,11 +44,7 @@ def test_array_feature_extractor(self):
],
remainder="passthrough",
)
onehotencoding_pipeline = Pipeline(
[
("columnTransformer", ct_cat),
]
)
onehotencoding_pipeline = Pipeline([("columnTransformer", ct_cat)])
clustering_pipeline = Pipeline(
[("onehotencoder_and_scaler", onehotencoding_pipeline), ("clustering", gmm)]
)
Expand Down
26 changes: 13 additions & 13 deletions tests/test_sklearn_calibrated_classifier_cv_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_model_calibrated_classifier_cv_logistic_regression(self):
X, y = data.data, data.target
y[y > 1] = 1
model = CalibratedClassifierCV(
base_estimator=LogisticRegression(), method="sigmoid"
estimator=LogisticRegression(), method="sigmoid"
).fit(X, y)
model_onnx = convert_sklearn(
model,
Expand All @@ -215,7 +215,7 @@ def test_model_calibrated_classifier_cv_rf(self):
X, y = data.data, data.target
y[y > 1] = 1
model = CalibratedClassifierCV(
base_estimator=RandomForestClassifier(n_estimators=2), method="sigmoid"
estimator=RandomForestClassifier(n_estimators=2), method="sigmoid"
).fit(X, y)
model_onnx = convert_sklearn(
model,
Expand All @@ -239,7 +239,7 @@ def test_model_calibrated_classifier_cv_gbt(self):
X, y = data.data, data.target
y[y > 1] = 1
model = CalibratedClassifierCV(
base_estimator=GradientBoostingClassifier(n_estimators=2), method="sigmoid"
estimator=GradientBoostingClassifier(n_estimators=2), method="sigmoid"
).fit(X, y)
model_onnx = convert_sklearn(
model,
Expand All @@ -264,7 +264,7 @@ def test_model_calibrated_classifier_cv_hgbt(self):
X, y = data.data, data.target
y[y > 1] = 1
model = CalibratedClassifierCV(
base_estimator=HistGradientBoostingClassifier(max_iter=4), method="sigmoid"
estimator=HistGradientBoostingClassifier(max_iter=4), method="sigmoid"
).fit(X, y)
model_onnx = convert_sklearn(
model,
Expand All @@ -288,7 +288,7 @@ def test_model_calibrated_classifier_cv_tree(self):
X, y = data.data, data.target
y[y > 1] = 1
model = CalibratedClassifierCV(
base_estimator=DecisionTreeClassifier(), method="sigmoid"
estimator=DecisionTreeClassifier(), method="sigmoid"
).fit(X, y)
model_onnx = convert_sklearn(
model,
Expand All @@ -311,7 +311,7 @@ def test_model_calibrated_classifier_cv_tree(self):
def test_model_calibrated_classifier_cv_svc(self):
data = load_iris()
X, y = data.data, data.target
model = CalibratedClassifierCV(base_estimator=SVC(), method="sigmoid").fit(X, y)
model = CalibratedClassifierCV(estimator=SVC(), method="sigmoid").fit(X, y)
model_onnx = convert_sklearn(
model,
"unused",
Expand All @@ -333,9 +333,9 @@ def test_model_calibrated_classifier_cv_svc(self):
def test_model_calibrated_classifier_cv_linearsvc(self):
data = load_iris()
X, y = data.data, data.target
model = CalibratedClassifierCV(
base_estimator=LinearSVC(), method="sigmoid"
).fit(X, y)
model = CalibratedClassifierCV(estimator=LinearSVC(), method="sigmoid").fit(
X, y
)
model_onnx = convert_sklearn(
model,
"unused",
Expand All @@ -359,9 +359,9 @@ def test_model_calibrated_classifier_cv_linearsvc2(self):
X, y = data.data, data.target
y[y == 2] = 0
self.assertEqual(len(set(y)), 2)
model = CalibratedClassifierCV(
base_estimator=LinearSVC(), method="sigmoid"
).fit(X, y)
model = CalibratedClassifierCV(estimator=LinearSVC(), method="sigmoid").fit(
X, y
)
model_onnx = convert_sklearn(
model,
"unused",
Expand Down Expand Up @@ -391,7 +391,7 @@ def test_model_calibrated_classifier_cv_svc2_binary(self):
model_sub.fit(X, y)
with self.subTest(model=model_sub):
model = CalibratedClassifierCV(
base_estimator=model_sub, cv=2, method="sigmoid"
estimator=model_sub, cv=2, method="sigmoid"
).fit(X, y)
model_onnx = convert_sklearn(
model,
Expand Down

0 comments on commit 5ace336

Please sign in to comment.