Skip to content

Commit 4493f86

Browse files
authored
DOC: use curve_kwargs instead of kwargs in example to avoid warnings (scikit-learn#31447)
1 parent 398e8fe commit 4493f86

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

examples/miscellaneous/plot_outlier_detection_bench.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ def fit_predict(estimator, X):
355355
ax=ax,
356356
plot_chance_level=(model_idx == len(n_neighbors_list) - 1),
357357
chance_level_kw={"linestyle": (0, (1, 10))},
358-
linestyle=linestyle,
359-
linewidth=2,
358+
curve_kwargs=dict(linestyle=linestyle, linewidth=2),
360359
)
361360
_ = ax.set_title("RobustScaler with varying n_neighbors\non forestcover dataset")
362361

@@ -395,8 +394,7 @@ def fit_predict(estimator, X):
395394
ax=ax,
396395
plot_chance_level=(model_idx == len(preprocessor_list) - 1),
397396
chance_level_kw={"linestyle": (0, (1, 10))},
398-
linestyle=linestyle,
399-
linewidth=2,
397+
curve_kwargs=dict(linestyle=linestyle, linewidth=2),
400398
)
401399
_ = ax.set_title("Fixed n_neighbors with varying preprocessing\non forestcover dataset")
402400

@@ -447,8 +445,7 @@ def fit_predict(estimator, X):
447445
ax=ax,
448446
plot_chance_level=(model_idx == len(preprocessor_list) - 1),
449447
chance_level_kw={"linestyle": (0, (1, 10))},
450-
linestyle=linestyle,
451-
linewidth=2,
448+
curve_kwargs=dict(linestyle=linestyle, linewidth=2),
452449
)
453450
ax.set_title(
454451
"Fixed n_neighbors with varying preprocessing\non cardiotocography dataset"

examples/miscellaneous/plot_roc_curve_visualization_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
rfc = RandomForestClassifier(n_estimators=10, random_state=42)
5555
rfc.fit(X_train, y_train)
5656
ax = plt.gca()
57-
rfc_disp = RocCurveDisplay.from_estimator(rfc, X_test, y_test, ax=ax, alpha=0.8)
58-
svc_disp.plot(ax=ax, alpha=0.8)
57+
rfc_disp = RocCurveDisplay.from_estimator(
58+
rfc, X_test, y_test, ax=ax, curve_kwargs=dict(alpha=0.8)
59+
)
60+
svc_disp.plot(ax=ax, curve_kwargs=dict(alpha=0.8))
5961
plt.show()

examples/model_selection/plot_cost_sensitive_learning.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ def plot_roc_pr_curves(vanilla_model, tuned_model, *, title):
321321
X_test,
322322
y_test,
323323
pos_label=pos_label,
324-
linestyle=linestyle,
325-
color=color,
324+
curve_kwargs=dict(linestyle=linestyle, color=color),
326325
ax=axs[1],
327326
name=name,
328327
plot_chance_level=idx == 1,

examples/model_selection/plot_det.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,12 @@
103103
)
104104
clf.fit(X_train, y_train)
105105
RocCurveDisplay.from_estimator(
106-
clf, X_test, y_test, ax=ax_roc, name=name, color=color, linestyle=linestyle
106+
clf,
107+
X_test,
108+
y_test,
109+
ax=ax_roc,
110+
name=name,
111+
curve_kwargs=dict(color=color, linestyle=linestyle),
107112
)
108113
DetCurveDisplay.from_estimator(
109114
clf, X_test, y_test, ax=ax_det, name=name, color=color, linestyle=linestyle

examples/model_selection/plot_roc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
y_onehot_test[:, class_id],
130130
y_score[:, class_id],
131131
name=f"{class_of_interest} vs the rest",
132-
color="darkorange",
132+
curve_kwargs=dict(color="darkorange"),
133133
plot_chance_level=True,
134134
despine=True,
135135
)
@@ -165,7 +165,7 @@
165165
y_onehot_test.ravel(),
166166
y_score.ravel(),
167167
name="micro-average OvR",
168-
color="darkorange",
168+
curve_kwargs=dict(color="darkorange"),
169169
plot_chance_level=True,
170170
despine=True,
171171
)
@@ -290,7 +290,7 @@
290290
y_onehot_test[:, class_id],
291291
y_score[:, class_id],
292292
name=f"ROC curve for {target_names[class_id]}",
293-
color=color,
293+
curve_kwargs=dict(color=color),
294294
ax=ax,
295295
plot_chance_level=(class_id == 2),
296296
despine=True,

examples/model_selection/plot_roc_crossval.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@
8989
X[test],
9090
y[test],
9191
name=f"ROC fold {fold}",
92-
alpha=0.3,
93-
lw=1,
92+
curve_kwargs=dict(alpha=0.3, lw=1),
9493
ax=ax,
9594
plot_chance_level=(fold == n_splits - 1),
9695
)

0 commit comments

Comments
 (0)