def test_refit_fits_underlying(): X = np.array([1, 2, 3, 4]).reshape(-1, 1) y_ones = np.array([0, 1, 1, 1]).reshape(-1, ) y_zeros = np.array([0, 0, 0, 1]).reshape(-1, ) clf = DummyClassifier(strategy="most_frequent") clf.fit(X, y_ones) a = Thresholder(clf, threshold=0.2, refit=True) a.fit(X, y_zeros) assert a.predict(np.array([[1]])) == 0
def test_stacking_classifier(): ''' Tests issue https://github.com/koaning/scikit-lego/issues/501 No asserts are added as we only test for being exception free. When cloning the model in Thresholder an unfitted model is generated where no predict_proba exists ''' estimators = [("dummy", DummyClassifier(strategy="constant", constant=0))] X = np.random.normal(0, 1, (100, 3)) y = np.random.normal(0, 1, (100, )) < 0 clf = StackingClassifier(estimators=estimators, final_estimator=DummyClassifier( strategy="constant", constant=0)) clf.fit(X, y) a = Thresholder(clf, threshold=0.2) a.fit(X, y) a.predict(X)