diff --git a/docs/_scripts/meta-models.py b/docs/_scripts/meta-models.py index b7134ebea..9069c8ed5 100644 --- a/docs/_scripts/meta-models.py +++ b/docs/_scripts/meta-models.py @@ -132,7 +132,7 @@ def plot_model(model): ("datagrab", FeatureUnion([ ("discrete", Pipeline([ ("grab", ColumnSelector("diet")), - ("encode", OneHotEncoder(categories="auto", sparse=False)) + ("encode", OneHotEncoder(categories="auto")) ])), ("continuous", Pipeline([ ("grab", ColumnSelector("time")), @@ -265,8 +265,15 @@ def plot_model(model): mod1 = (GroupedPredictor(DummyRegressor(), groups=["m"]) .fit(df[["m"]], df["yt"])) -mod2 = (GroupedPredictor(DecayEstimator(DummyRegressor(), decay_func="exponential", decay_rate=0.9), groups=["m"]) - .fit(df[["index", "m"]], df["yt"])) +mod2 = (GroupedPredictor( + estimator=DecayEstimator( + model=DummyRegressor(), + decay_func="exponential", + decay_kwargs={"decay_rate": 0.9} + ), + groups=["m"] + ).fit(df[["index", "m"]], df["yt"]) +) plt.figure(figsize=(12, 3)) plt.plot(df["yt"], alpha=0.5); @@ -494,12 +501,16 @@ def false_negatives(mod, x, y): from sklearn.linear_model import LogisticRegression from sklego.meta import OrdinalClassifier -ord_clf = OrdinalClassifier(LogisticRegression(), n_jobs=-1, use_calibration=False) -_ = ord_clf.fit(X, y) -ord_clf.predict_proba(X[0]) +ord_clf = OrdinalClassifier( + LogisticRegression(), + n_jobs=-1, + use_calibration=False, + ).fit(X, y) + +ord_clf.predict_proba(X[:1]) # --8<-- [end:ordinal-classifier] -print(ord_clf.predict_proba(X[0])) +print(ord_clf.predict_proba(X[:1])) # --8<-- [start:ordinal-classifier-with-calibration] from sklearn.calibration import CalibratedClassifierCV diff --git a/docs/_static/meta-models/baseline-model.png b/docs/_static/meta-models/baseline-model.png index 4da4b554b..555f933ca 100644 Binary files a/docs/_static/meta-models/baseline-model.png and b/docs/_static/meta-models/baseline-model.png differ diff --git a/docs/_static/meta-models/confusion-balanced-grid.html b/docs/_static/meta-models/confusion-balanced-grid.html index f79165111..9b4eb4727 100644 --- a/docs/_static/meta-models/confusion-balanced-grid.html +++ b/docs/_static/meta-models/confusion-balanced-grid.html @@ -1,4 +1,408 @@ -
GridSearchCV(cv=5, +GridSearchCV(cv=5, estimator=ConfusionBalancer(alpha=1.0, estimator=LogisticRegression(max_iter=1000)), n_jobs=-1, @@ -10,9 +414,9 @@ 2.33333333, 2.46666667, 2.6 , 2.73333333, 2.86666667, 3. ])}, refit='negatives', return_train_score=True, - scoring={'accuracy': make_scorer(accuracy_score), - 'negatives': <function false_negatives at 0x7f33dfb60c10>, - 'positives': <function false_positives at 0x7f33dfb61fc0>})In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.\ No newline at end of file + scoring={'accuracy': make_scorer(accuracy_score, response_method='predict'), + 'negatives': <function false_negatives at 0x7f2eb713e830>, + 'positives': <function false_positives at 0x7f2eb713ef80>})GridSearchCV(cv=5, + scoring={'accuracy': make_scorer(accuracy_score, response_method='predict'), + 'negatives': <function false_negatives at 0x7f2eb713e830>, + 'positives': <function false_positives at 0x7f2eb713ef80>})In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.GridSearchCV(cv=5, estimator=ConfusionBalancer(alpha=1.0, estimator=LogisticRegression(max_iter=1000)), n_jobs=-1, @@ -24,6 +428,6 @@ 2.33333333, 2.46666667, 2.6 , 2.73333333, 2.86666667, 3. ])}, refit='negatives', return_train_score=True, - scoring={'accuracy': make_scorer(accuracy_score), - 'negatives': <function false_negatives at 0x7f33dfb60c10>, - 'positives': <function false_positives at 0x7f33dfb61fc0>})ConfusionBalancer(alpha=1.0, estimator=LogisticRegression(max_iter=1000))LogisticRegression(max_iter=1000)LogisticRegression(max_iter=1000)ConfusionBalancer(alpha=1.0, estimator=LogisticRegression(max_iter=1000))LogisticRegression(max_iter=1000)LogisticRegression(max_iter=1000)
StackingClassifier(estimators=[('anomaly', +StackingClassifier(estimators=[('anomaly', OutlierClassifier(model=IsolationForest())), ('classifier', RandomForestClassifier())], - passthrough=True, stack_method='predict_proba')In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.\ No newline at end of file + passthrough=True, stack_method='predict_proba')StackingClassifier(estimators=[('anomaly', + passthrough=True, stack_method='predict_proba')In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.StackingClassifier(estimators=[('anomaly', OutlierClassifier(model=IsolationForest())), ('classifier', RandomForestClassifier())], - passthrough=True, stack_method='predict_proba')IsolationForest()IsolationForest()RandomForestClassifier()LogisticRegression()IsolationForest()IsolationForest()RandomForestClassifier()LogisticRegression()
OutlierClassifier(model=IsolationForest(contamination=0.01, n_estimators=1000, - random_state=0))In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
OutlierClassifier(model=IsolationForest(contamination=0.01, n_estimators=1000, - random_state=0))
IsolationForest(contamination=0.01, n_estimators=1000, random_state=0)
IsolationForest(contamination=0.01, n_estimators=1000, random_state=0)
OutlierClassifier(model=IsolationForest(contamination=0.01, n_estimators=1000, + random_state=0))In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
OutlierClassifier(model=IsolationForest(contamination=0.01, n_estimators=1000, + random_state=0))
IsolationForest(contamination=0.01, n_estimators=1000, random_state=0)
IsolationForest(contamination=0.01, n_estimators=1000, random_state=0)