Skip to content

Commit 8f0ed42

Browse files
committed
Pushing the docs to dev/ for branch: main, commit 893d5accaf9d16f447645e704f85a216187564f7
1 parent bbde60e commit 8f0ed42

File tree

1,320 files changed

+4744
-4780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,320 files changed

+4744
-4780
lines changed
Binary file not shown.

dev/_downloads/0dd5e0a7942f1446accf7dffd47aed28/plot_label_propagation_digits_active_learning.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@
115115
n_labeled_points += len(uncertainty_index)
116116

117117
f.suptitle(
118-
"Active learning with Label Propagation.\nRows show 5 most "
119-
"uncertain labels to learn with the next model.",
118+
(
119+
"Active learning with Label Propagation.\nRows show 5 most "
120+
"uncertain labels to learn with the next model."
121+
),
120122
y=1.15,
121123
)
122124
plt.subplots_adjust(left=0.2, bottom=0.03, right=0.9, top=0.9, wspace=0.2, hspace=0.85)

dev/_downloads/10754505339af88c10b8a48127535a4a/plot_quantile_regression.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
},
175175
"outputs": [],
176176
"source": [
177-
"from sklearn.linear_model import LinearRegression\nfrom sklearn.metrics import mean_absolute_error\nfrom sklearn.metrics import mean_squared_error\n\nlinear_regression = LinearRegression()\nquantile_regression = QuantileRegressor(quantile=0.5, alpha=0, solver=solver)\n\ny_pred_lr = linear_regression.fit(X, y_pareto).predict(X)\ny_pred_qr = quantile_regression.fit(X, y_pareto).predict(X)\n\nprint(\n f\"\"\"Training error (in-sample performance)\n {linear_regression.__class__.__name__}:\n MAE = {mean_absolute_error(y_pareto, y_pred_lr):.3f}\n MSE = {mean_squared_error(y_pareto, y_pred_lr):.3f}\n {quantile_regression.__class__.__name__}:\n MAE = {mean_absolute_error(y_pareto, y_pred_qr):.3f}\n MSE = {mean_squared_error(y_pareto, y_pred_qr):.3f}\n \"\"\"\n)"
177+
"from sklearn.linear_model import LinearRegression\nfrom sklearn.metrics import mean_absolute_error\nfrom sklearn.metrics import mean_squared_error\n\nlinear_regression = LinearRegression()\nquantile_regression = QuantileRegressor(quantile=0.5, alpha=0, solver=solver)\n\ny_pred_lr = linear_regression.fit(X, y_pareto).predict(X)\ny_pred_qr = quantile_regression.fit(X, y_pareto).predict(X)\n\nprint(f\"\"\"Training error (in-sample performance)\n {linear_regression.__class__.__name__}:\n MAE = {mean_absolute_error(y_pareto, y_pred_lr):.3f}\n MSE = {mean_squared_error(y_pareto, y_pred_lr):.3f}\n {quantile_regression.__class__.__name__}:\n MAE = {mean_absolute_error(y_pareto, y_pred_qr):.3f}\n MSE = {mean_squared_error(y_pareto, y_pred_qr):.3f}\n \"\"\")"
178178
]
179179
},
180180
{
@@ -192,7 +192,7 @@
192192
},
193193
"outputs": [],
194194
"source": [
195-
"from sklearn.model_selection import cross_validate\n\ncv_results_lr = cross_validate(\n linear_regression,\n X,\n y_pareto,\n cv=3,\n scoring=[\"neg_mean_absolute_error\", \"neg_mean_squared_error\"],\n)\ncv_results_qr = cross_validate(\n quantile_regression,\n X,\n y_pareto,\n cv=3,\n scoring=[\"neg_mean_absolute_error\", \"neg_mean_squared_error\"],\n)\nprint(\n f\"\"\"Test error (cross-validated performance)\n {linear_regression.__class__.__name__}:\n MAE = {-cv_results_lr[\"test_neg_mean_absolute_error\"].mean():.3f}\n MSE = {-cv_results_lr[\"test_neg_mean_squared_error\"].mean():.3f}\n {quantile_regression.__class__.__name__}:\n MAE = {-cv_results_qr[\"test_neg_mean_absolute_error\"].mean():.3f}\n MSE = {-cv_results_qr[\"test_neg_mean_squared_error\"].mean():.3f}\n \"\"\"\n)"
195+
"from sklearn.model_selection import cross_validate\n\ncv_results_lr = cross_validate(\n linear_regression,\n X,\n y_pareto,\n cv=3,\n scoring=[\"neg_mean_absolute_error\", \"neg_mean_squared_error\"],\n)\ncv_results_qr = cross_validate(\n quantile_regression,\n X,\n y_pareto,\n cv=3,\n scoring=[\"neg_mean_absolute_error\", \"neg_mean_squared_error\"],\n)\nprint(f\"\"\"Test error (cross-validated performance)\n {linear_regression.__class__.__name__}:\n MAE = {-cv_results_lr[\"test_neg_mean_absolute_error\"].mean():.3f}\n MSE = {-cv_results_lr[\"test_neg_mean_squared_error\"].mean():.3f}\n {quantile_regression.__class__.__name__}:\n MAE = {-cv_results_qr[\"test_neg_mean_absolute_error\"].mean():.3f}\n MSE = {-cv_results_qr[\"test_neg_mean_squared_error\"].mean():.3f}\n \"\"\")"
196196
]
197197
},
198198
{

dev/_downloads/21b82d82985712b5de6347f382c77c86/plot_partial_dependence.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
},
232232
"outputs": [],
233233
"source": [
234-
"import matplotlib.pyplot as plt\nfrom sklearn.inspection import PartialDependenceDisplay\n\ncommon_params = {\n \"subsample\": 50,\n \"n_jobs\": 2,\n \"grid_resolution\": 20,\n \"random_state\": 0,\n}\n\nprint(\"Computing partial dependence plots...\")\nfeatures_info = {\n # features of interest\n \"features\": [\"temp\", \"humidity\", \"windspeed\", \"season\", \"weather\", \"hour\"],\n # type of partial dependence plot\n \"kind\": \"average\",\n # information regarding categorical features\n \"categorical_features\": categorical_features,\n}\ntic = time()\n_, ax = plt.subplots(ncols=3, nrows=2, figsize=(9, 8), constrained_layout=True)\ndisplay = PartialDependenceDisplay.from_estimator(\n mlp_model,\n X_train,\n **features_info,\n ax=ax,\n **common_params,\n)\nprint(f\"done in {time() - tic:.3f}s\")\n_ = display.figure_.suptitle(\n \"Partial dependence of the number of bike rentals\\n\"\n \"for the bike rental dataset with an MLPRegressor\",\n fontsize=16,\n)"
234+
"import matplotlib.pyplot as plt\nfrom sklearn.inspection import PartialDependenceDisplay\n\ncommon_params = {\n \"subsample\": 50,\n \"n_jobs\": 2,\n \"grid_resolution\": 20,\n \"random_state\": 0,\n}\n\nprint(\"Computing partial dependence plots...\")\nfeatures_info = {\n # features of interest\n \"features\": [\"temp\", \"humidity\", \"windspeed\", \"season\", \"weather\", \"hour\"],\n # type of partial dependence plot\n \"kind\": \"average\",\n # information regarding categorical features\n \"categorical_features\": categorical_features,\n}\ntic = time()\n_, ax = plt.subplots(ncols=3, nrows=2, figsize=(9, 8), constrained_layout=True)\ndisplay = PartialDependenceDisplay.from_estimator(\n mlp_model,\n X_train,\n **features_info,\n ax=ax,\n **common_params,\n)\nprint(f\"done in {time() - tic:.3f}s\")\n_ = display.figure_.suptitle(\n (\n \"Partial dependence of the number of bike rentals\\n\"\n \"for the bike rental dataset with an MLPRegressor\"\n ),\n fontsize=16,\n)"
235235
]
236236
},
237237
{
@@ -267,7 +267,7 @@
267267
},
268268
"outputs": [],
269269
"source": [
270-
"print(\"Computing partial dependence plots...\")\ntic = time()\n_, ax = plt.subplots(ncols=3, nrows=2, figsize=(9, 8), constrained_layout=True)\ndisplay = PartialDependenceDisplay.from_estimator(\n hgbdt_model,\n X_train,\n **features_info,\n ax=ax,\n **common_params,\n)\nprint(f\"done in {time() - tic:.3f}s\")\n_ = display.figure_.suptitle(\n \"Partial dependence of the number of bike rentals\\n\"\n \"for the bike rental dataset with a gradient boosting\",\n fontsize=16,\n)"
270+
"print(\"Computing partial dependence plots...\")\ntic = time()\n_, ax = plt.subplots(ncols=3, nrows=2, figsize=(9, 8), constrained_layout=True)\ndisplay = PartialDependenceDisplay.from_estimator(\n hgbdt_model,\n X_train,\n **features_info,\n ax=ax,\n **common_params,\n)\nprint(f\"done in {time() - tic:.3f}s\")\n_ = display.figure_.suptitle(\n (\n \"Partial dependence of the number of bike rentals\\n\"\n \"for the bike rental dataset with a gradient boosting\"\n ),\n fontsize=16,\n)"
271271
]
272272
},
273273
{

dev/_downloads/23614d75e8327ef369659da7d2ed62db/plot_nested_cross_validation_iris.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070

7171
# Loop for each trial
7272
for i in range(NUM_TRIALS):
73-
7473
# Choose cross-validation techniques for the inner and outer loops,
7574
# independently of the dataset.
7675
# E.g "GroupKFold", "LeaveOneOut", "LeaveOneGroupOut", etc.

dev/_downloads/2840d928d4f93cd381486b35c2031752/plot_stock_market.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
},
117117
"outputs": [],
118118
"source": [
119-
"import matplotlib.pyplot as plt\nfrom matplotlib.collections import LineCollection\n\nplt.figure(1, facecolor=\"w\", figsize=(10, 8))\nplt.clf()\nax = plt.axes([0.0, 0.0, 1.0, 1.0])\nplt.axis(\"off\")\n\n# Plot the graph of partial correlations\npartial_correlations = edge_model.precision_.copy()\nd = 1 / np.sqrt(np.diag(partial_correlations))\npartial_correlations *= d\npartial_correlations *= d[:, np.newaxis]\nnon_zero = np.abs(np.triu(partial_correlations, k=1)) > 0.02\n\n# Plot the nodes using the coordinates of our embedding\nplt.scatter(\n embedding[0], embedding[1], s=100 * d**2, c=labels, cmap=plt.cm.nipy_spectral\n)\n\n# Plot the edges\nstart_idx, end_idx = np.where(non_zero)\n# a sequence of (*line0*, *line1*, *line2*), where::\n# linen = (x0, y0), (x1, y1), ... (xm, ym)\nsegments = [\n [embedding[:, start], embedding[:, stop]] for start, stop in zip(start_idx, end_idx)\n]\nvalues = np.abs(partial_correlations[non_zero])\nlc = LineCollection(\n segments, zorder=0, cmap=plt.cm.hot_r, norm=plt.Normalize(0, 0.7 * values.max())\n)\nlc.set_array(values)\nlc.set_linewidths(15 * values)\nax.add_collection(lc)\n\n# Add a label to each node. The challenge here is that we want to\n# position the labels to avoid overlap with other labels\nfor index, (name, label, (x, y)) in enumerate(zip(names, labels, embedding.T)):\n\n dx = x - embedding[0]\n dx[index] = 1\n dy = y - embedding[1]\n dy[index] = 1\n this_dx = dx[np.argmin(np.abs(dy))]\n this_dy = dy[np.argmin(np.abs(dx))]\n if this_dx > 0:\n horizontalalignment = \"left\"\n x = x + 0.002\n else:\n horizontalalignment = \"right\"\n x = x - 0.002\n if this_dy > 0:\n verticalalignment = \"bottom\"\n y = y + 0.002\n else:\n verticalalignment = \"top\"\n y = y - 0.002\n plt.text(\n x,\n y,\n name,\n size=10,\n horizontalalignment=horizontalalignment,\n verticalalignment=verticalalignment,\n bbox=dict(\n facecolor=\"w\",\n edgecolor=plt.cm.nipy_spectral(label / float(n_labels)),\n alpha=0.6,\n ),\n )\n\nplt.xlim(\n embedding[0].min() - 0.15 * embedding[0].ptp(),\n embedding[0].max() + 0.10 * embedding[0].ptp(),\n)\nplt.ylim(\n embedding[1].min() - 0.03 * embedding[1].ptp(),\n embedding[1].max() + 0.03 * embedding[1].ptp(),\n)\n\nplt.show()"
119+
"import matplotlib.pyplot as plt\nfrom matplotlib.collections import LineCollection\n\nplt.figure(1, facecolor=\"w\", figsize=(10, 8))\nplt.clf()\nax = plt.axes([0.0, 0.0, 1.0, 1.0])\nplt.axis(\"off\")\n\n# Plot the graph of partial correlations\npartial_correlations = edge_model.precision_.copy()\nd = 1 / np.sqrt(np.diag(partial_correlations))\npartial_correlations *= d\npartial_correlations *= d[:, np.newaxis]\nnon_zero = np.abs(np.triu(partial_correlations, k=1)) > 0.02\n\n# Plot the nodes using the coordinates of our embedding\nplt.scatter(\n embedding[0], embedding[1], s=100 * d**2, c=labels, cmap=plt.cm.nipy_spectral\n)\n\n# Plot the edges\nstart_idx, end_idx = np.where(non_zero)\n# a sequence of (*line0*, *line1*, *line2*), where::\n# linen = (x0, y0), (x1, y1), ... (xm, ym)\nsegments = [\n [embedding[:, start], embedding[:, stop]] for start, stop in zip(start_idx, end_idx)\n]\nvalues = np.abs(partial_correlations[non_zero])\nlc = LineCollection(\n segments, zorder=0, cmap=plt.cm.hot_r, norm=plt.Normalize(0, 0.7 * values.max())\n)\nlc.set_array(values)\nlc.set_linewidths(15 * values)\nax.add_collection(lc)\n\n# Add a label to each node. The challenge here is that we want to\n# position the labels to avoid overlap with other labels\nfor index, (name, label, (x, y)) in enumerate(zip(names, labels, embedding.T)):\n dx = x - embedding[0]\n dx[index] = 1\n dy = y - embedding[1]\n dy[index] = 1\n this_dx = dx[np.argmin(np.abs(dy))]\n this_dy = dy[np.argmin(np.abs(dx))]\n if this_dx > 0:\n horizontalalignment = \"left\"\n x = x + 0.002\n else:\n horizontalalignment = \"right\"\n x = x - 0.002\n if this_dy > 0:\n verticalalignment = \"bottom\"\n y = y + 0.002\n else:\n verticalalignment = \"top\"\n y = y - 0.002\n plt.text(\n x,\n y,\n name,\n size=10,\n horizontalalignment=horizontalalignment,\n verticalalignment=verticalalignment,\n bbox=dict(\n facecolor=\"w\",\n edgecolor=plt.cm.nipy_spectral(label / float(n_labels)),\n alpha=0.6,\n ),\n )\n\nplt.xlim(\n embedding[0].min() - 0.15 * embedding[0].ptp(),\n embedding[0].max() + 0.10 * embedding[0].ptp(),\n)\nplt.ylim(\n embedding[1].min() - 0.03 * embedding[1].ptp(),\n embedding[1].max() + 0.03 * embedding[1].ptp(),\n)\n\nplt.show()"
120120
]
121121
}
122122
],

dev/_downloads/32173eb704d697c23dffbbf3fd74942a/plot_digits_denoising.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ def plot_digits(X, title):
135135
)
136136
plot_digits(
137137
X_reconstructed_kernel_pca,
138-
"Kernel PCA reconstruction\n"
139-
f"MSE: {np.mean((X_test - X_reconstructed_kernel_pca) ** 2):.2f}",
138+
(
139+
"Kernel PCA reconstruction\n"
140+
f"MSE: {np.mean((X_test - X_reconstructed_kernel_pca) ** 2):.2f}"
141+
),
140142
)
141143

142144
# %%

dev/_downloads/358cfc6f7881b63fd4067f3b13ced9ab/plot_svm_tie_breaking.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"# Code source: Andreas Mueller, Adrin Jalali\n# License: BSD 3 clause\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.svm import SVC\nfrom sklearn.datasets import make_blobs\n\nX, y = make_blobs(random_state=27)\n\nfig, sub = plt.subplots(2, 1, figsize=(5, 8))\ntitles = (\"break_ties = False\", \"break_ties = True\")\n\nfor break_ties, title, ax in zip((False, True), titles, sub.flatten()):\n\n svm = SVC(\n kernel=\"linear\", C=1, break_ties=break_ties, decision_function_shape=\"ovr\"\n ).fit(X, y)\n\n xlim = [X[:, 0].min(), X[:, 0].max()]\n ylim = [X[:, 1].min(), X[:, 1].max()]\n\n xs = np.linspace(xlim[0], xlim[1], 1000)\n ys = np.linspace(ylim[0], ylim[1], 1000)\n xx, yy = np.meshgrid(xs, ys)\n\n pred = svm.predict(np.c_[xx.ravel(), yy.ravel()])\n\n colors = [plt.cm.Accent(i) for i in [0, 4, 7]]\n\n points = ax.scatter(X[:, 0], X[:, 1], c=y, cmap=\"Accent\")\n classes = [(0, 1), (0, 2), (1, 2)]\n line = np.linspace(X[:, 1].min() - 5, X[:, 1].max() + 5)\n ax.imshow(\n -pred.reshape(xx.shape),\n cmap=\"Accent\",\n alpha=0.2,\n extent=(xlim[0], xlim[1], ylim[1], ylim[0]),\n )\n\n for coef, intercept, col in zip(svm.coef_, svm.intercept_, classes):\n line2 = -(line * coef[1] + intercept) / coef[0]\n ax.plot(line2, line, \"-\", c=colors[col[0]])\n ax.plot(line2, line, \"--\", c=colors[col[1]])\n ax.set_xlim(xlim)\n ax.set_ylim(ylim)\n ax.set_title(title)\n ax.set_aspect(\"equal\")\n\nplt.show()"
29+
"# Code source: Andreas Mueller, Adrin Jalali\n# License: BSD 3 clause\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.svm import SVC\nfrom sklearn.datasets import make_blobs\n\nX, y = make_blobs(random_state=27)\n\nfig, sub = plt.subplots(2, 1, figsize=(5, 8))\ntitles = (\"break_ties = False\", \"break_ties = True\")\n\nfor break_ties, title, ax in zip((False, True), titles, sub.flatten()):\n svm = SVC(\n kernel=\"linear\", C=1, break_ties=break_ties, decision_function_shape=\"ovr\"\n ).fit(X, y)\n\n xlim = [X[:, 0].min(), X[:, 0].max()]\n ylim = [X[:, 1].min(), X[:, 1].max()]\n\n xs = np.linspace(xlim[0], xlim[1], 1000)\n ys = np.linspace(ylim[0], ylim[1], 1000)\n xx, yy = np.meshgrid(xs, ys)\n\n pred = svm.predict(np.c_[xx.ravel(), yy.ravel()])\n\n colors = [plt.cm.Accent(i) for i in [0, 4, 7]]\n\n points = ax.scatter(X[:, 0], X[:, 1], c=y, cmap=\"Accent\")\n classes = [(0, 1), (0, 2), (1, 2)]\n line = np.linspace(X[:, 1].min() - 5, X[:, 1].max() + 5)\n ax.imshow(\n -pred.reshape(xx.shape),\n cmap=\"Accent\",\n alpha=0.2,\n extent=(xlim[0], xlim[1], ylim[1], ylim[0]),\n )\n\n for coef, intercept, col in zip(svm.coef_, svm.intercept_, classes):\n line2 = -(line * coef[1] + intercept) / coef[0]\n ax.plot(line2, line, \"-\", c=colors[col[0]])\n ax.plot(line2, line, \"--\", c=colors[col[1]])\n ax.set_xlim(xlim)\n ax.set_ylim(ylim)\n ax.set_title(title)\n ax.set_aspect(\"equal\")\n\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/40f4aad91af595a370d7582e3a23bed7/plot_roc.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
},
272272
"outputs": [],
273273
"source": [
274-
"pair_scores = []\nmean_tpr = dict()\n\nfor ix, (label_a, label_b) in enumerate(pair_list):\n\n a_mask = y_test == label_a\n b_mask = y_test == label_b\n ab_mask = np.logical_or(a_mask, b_mask)\n\n a_true = a_mask[ab_mask]\n b_true = b_mask[ab_mask]\n\n idx_a = np.flatnonzero(label_binarizer.classes_ == label_a)[0]\n idx_b = np.flatnonzero(label_binarizer.classes_ == label_b)[0]\n\n fpr_a, tpr_a, _ = roc_curve(a_true, y_score[ab_mask, idx_a])\n fpr_b, tpr_b, _ = roc_curve(b_true, y_score[ab_mask, idx_b])\n\n mean_tpr[ix] = np.zeros_like(fpr_grid)\n mean_tpr[ix] += np.interp(fpr_grid, fpr_a, tpr_a)\n mean_tpr[ix] += np.interp(fpr_grid, fpr_b, tpr_b)\n mean_tpr[ix] /= 2\n mean_score = auc(fpr_grid, mean_tpr[ix])\n pair_scores.append(mean_score)\n\n fig, ax = plt.subplots(figsize=(6, 6))\n plt.plot(\n fpr_grid,\n mean_tpr[ix],\n label=f\"Mean {label_a} vs {label_b} (AUC = {mean_score :.2f})\",\n linestyle=\":\",\n linewidth=4,\n )\n RocCurveDisplay.from_predictions(\n a_true,\n y_score[ab_mask, idx_a],\n ax=ax,\n name=f\"{label_a} as positive class\",\n )\n RocCurveDisplay.from_predictions(\n b_true,\n y_score[ab_mask, idx_b],\n ax=ax,\n name=f\"{label_b} as positive class\",\n plot_chance_level=True,\n )\n plt.axis(\"square\")\n plt.xlabel(\"False Positive Rate\")\n plt.ylabel(\"True Positive Rate\")\n plt.title(f\"{target_names[idx_a]} vs {label_b} ROC curves\")\n plt.legend()\n plt.show()\n\nprint(f\"Macro-averaged One-vs-One ROC AUC score:\\n{np.average(pair_scores):.2f}\")"
274+
"pair_scores = []\nmean_tpr = dict()\n\nfor ix, (label_a, label_b) in enumerate(pair_list):\n a_mask = y_test == label_a\n b_mask = y_test == label_b\n ab_mask = np.logical_or(a_mask, b_mask)\n\n a_true = a_mask[ab_mask]\n b_true = b_mask[ab_mask]\n\n idx_a = np.flatnonzero(label_binarizer.classes_ == label_a)[0]\n idx_b = np.flatnonzero(label_binarizer.classes_ == label_b)[0]\n\n fpr_a, tpr_a, _ = roc_curve(a_true, y_score[ab_mask, idx_a])\n fpr_b, tpr_b, _ = roc_curve(b_true, y_score[ab_mask, idx_b])\n\n mean_tpr[ix] = np.zeros_like(fpr_grid)\n mean_tpr[ix] += np.interp(fpr_grid, fpr_a, tpr_a)\n mean_tpr[ix] += np.interp(fpr_grid, fpr_b, tpr_b)\n mean_tpr[ix] /= 2\n mean_score = auc(fpr_grid, mean_tpr[ix])\n pair_scores.append(mean_score)\n\n fig, ax = plt.subplots(figsize=(6, 6))\n plt.plot(\n fpr_grid,\n mean_tpr[ix],\n label=f\"Mean {label_a} vs {label_b} (AUC = {mean_score :.2f})\",\n linestyle=\":\",\n linewidth=4,\n )\n RocCurveDisplay.from_predictions(\n a_true,\n y_score[ab_mask, idx_a],\n ax=ax,\n name=f\"{label_a} as positive class\",\n )\n RocCurveDisplay.from_predictions(\n b_true,\n y_score[ab_mask, idx_b],\n ax=ax,\n name=f\"{label_b} as positive class\",\n plot_chance_level=True,\n )\n plt.axis(\"square\")\n plt.xlabel(\"False Positive Rate\")\n plt.ylabel(\"True Positive Rate\")\n plt.title(f\"{target_names[idx_a]} vs {label_b} ROC curves\")\n plt.legend()\n plt.show()\n\nprint(f\"Macro-averaged One-vs-One ROC AUC score:\\n{np.average(pair_scores):.2f}\")"
275275
]
276276
},
277277
{

dev/_downloads/43e84df0b93ff974da370e8da900f2ee/plot_discretization_strategies.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
figure = plt.figure(figsize=(14, 9))
5959
i = 1
6060
for ds_cnt, X in enumerate(X_list):
61-
6261
ax = plt.subplot(len(X_list), len(strategies) + 1, i)
6362
ax.scatter(X[:, 0], X[:, 1], edgecolors="k")
6463
if ds_cnt == 0:

0 commit comments

Comments
 (0)