Skip to content

Commit 89e5d51

Browse files
committed
Pushing the docs to dev/ for branch: main, commit 78f0c0000a293ee4d01e3aa95e507f980088db4e
1 parent ed7eaa5 commit 89e5d51

File tree

1,249 files changed

+6029
-6095
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,249 files changed

+6029
-6095
lines changed
Binary file not shown.

dev/_downloads/49cd91d05440a1c88b074430761aeb76/plot_cv_indices.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
},
5252
"outputs": [],
5353
"source": [
54-
"def plot_cv_indices(cv, X, y, group, ax, n_splits, lw=10):\n \"\"\"Create a sample plot for indices of a cross-validation object.\"\"\"\n\n # Generate the training/testing visualizations for each CV split\n for ii, (tr, tt) in enumerate(cv.split(X=X, y=y, groups=group)):\n # Fill in indices with the training/test groups\n indices = np.array([np.nan] * len(X))\n indices[tt] = 1\n indices[tr] = 0\n\n # Visualize the results\n ax.scatter(\n range(len(indices)),\n [ii + 0.5] * len(indices),\n c=indices,\n marker=\"_\",\n lw=lw,\n cmap=cmap_cv,\n vmin=-0.2,\n vmax=1.2,\n )\n\n # Plot the data classes and groups at the end\n ax.scatter(\n range(len(X)), [ii + 1.5] * len(X), c=y, marker=\"_\", lw=lw, cmap=cmap_data\n )\n\n ax.scatter(\n range(len(X)), [ii + 2.5] * len(X), c=group, marker=\"_\", lw=lw, cmap=cmap_data\n )\n\n # Formatting\n yticklabels = list(range(n_splits)) + [\"class\", \"group\"]\n ax.set(\n yticks=np.arange(n_splits + 2) + 0.5,\n yticklabels=yticklabels,\n xlabel=\"Sample index\",\n ylabel=\"CV iteration\",\n ylim=[n_splits + 2.2, -0.2],\n xlim=[0, 100],\n )\n ax.set_title(\"{}\".format(type(cv).__name__), fontsize=15)\n return ax"
54+
"def plot_cv_indices(cv, X, y, group, ax, n_splits, lw=10):\n \"\"\"Create a sample plot for indices of a cross-validation object.\"\"\"\n use_groups = \"Group\" in type(cv).__name__\n groups = group if use_groups else None\n # Generate the training/testing visualizations for each CV split\n for ii, (tr, tt) in enumerate(cv.split(X=X, y=y, groups=groups)):\n # Fill in indices with the training/test groups\n indices = np.array([np.nan] * len(X))\n indices[tt] = 1\n indices[tr] = 0\n\n # Visualize the results\n ax.scatter(\n range(len(indices)),\n [ii + 0.5] * len(indices),\n c=indices,\n marker=\"_\",\n lw=lw,\n cmap=cmap_cv,\n vmin=-0.2,\n vmax=1.2,\n )\n\n # Plot the data classes and groups at the end\n ax.scatter(\n range(len(X)), [ii + 1.5] * len(X), c=y, marker=\"_\", lw=lw, cmap=cmap_data\n )\n\n ax.scatter(\n range(len(X)), [ii + 2.5] * len(X), c=group, marker=\"_\", lw=lw, cmap=cmap_data\n )\n\n # Formatting\n yticklabels = list(range(n_splits)) + [\"class\", \"group\"]\n ax.set(\n yticks=np.arange(n_splits + 2) + 0.5,\n yticklabels=yticklabels,\n xlabel=\"Sample index\",\n ylabel=\"CV iteration\",\n ylim=[n_splits + 2.2, -0.2],\n xlim=[0, 100],\n )\n ax.set_title(\"{}\".format(type(cv).__name__), fontsize=15)\n return ax"
5555
]
5656
},
5757
{
Binary file not shown.

dev/_downloads/f1caa332331b42f32518c03ec8a71341/plot_cv_indices.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ def visualize_groups(classes, groups, name):
9999

100100
def plot_cv_indices(cv, X, y, group, ax, n_splits, lw=10):
101101
"""Create a sample plot for indices of a cross-validation object."""
102-
102+
use_groups = "Group" in type(cv).__name__
103+
groups = group if use_groups else None
103104
# Generate the training/testing visualizations for each CV split
104-
for ii, (tr, tt) in enumerate(cv.split(X=X, y=y, groups=group)):
105+
for ii, (tr, tt) in enumerate(cv.split(X=X, y=y, groups=groups)):
105106
# Fill in indices with the training/test groups
106107
indices = np.array([np.nan] * len(X))
107108
indices[tt] = 1

dev/_downloads/scikit-learn-docs.zip

-2.53 KB
Binary file not shown.
-173 Bytes
-166 Bytes
147 Bytes
94 Bytes
-62 Bytes

0 commit comments

Comments
 (0)