Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

MAINT parameter validation for sklearn.datasets.fetch_lfw_people #25735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions 15 sklearn/datasets/_lfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from os import listdir, makedirs, remove
from os.path import join, exists, isdir

from ..utils._param_validation import validate_params,HasMethods
import logging

import numpy as np
Expand Down Expand Up @@ -230,7 +230,18 @@ def _fetch_lfw_people(
faces, target = faces[indices], target[indices]
return faces, target, target_names


@validate_params(
{
"data_home":[str,None],
"funneled":["boolean"],
"resize":[float,None],
"min_faces_per_person":[int,None],
"color":["boolean"],
"slice":["tuple of slice",(slice(0, 250), slice(0, 250))],
"download_if_missing":["boolean"],
"return_X_y":["boolean"],
}
)
def fetch_lfw_people(
*,
data_home=None,
Expand Down
11 changes: 10 additions & 1 deletion 11 sklearn/datasets/_svmlight_format_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .. import __version__

from ..utils import check_array, IS_PYPY
from ..utils._param_validation import validate_params,StrOptions

if not IS_PYPY:
from ._svmlight_format_fast import (
Expand Down Expand Up @@ -403,7 +404,15 @@ def _dump_svmlight(X, y, f, multilabel, one_based, comment, query_id):
y_is_sp,
)


@validate_params({
"X":["array-like","sparse matrix"],
"y":["array-like","sparse matrix"],
"f":[str,StrOptions({"file"})],
"zero_based":[bool,True],
"comment":[str,None],
"query_id":["array-like",None],
"multilabel":[bool,False],
})
def dump_svmlight_file(
X,
y,
Expand Down
2 changes: 2 additions & 0 deletions 2 sklearn/tests/test_public_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def _check_function_param_validation(
"sklearn.datasets.make_classification",
"sklearn.datasets.make_friedman1",
"sklearn.datasets.make_sparse_coded_signal",
"sklearn.datasets.dump_svmlight_file",
"sklearn.datasets.fetch_lfw_people",
"sklearn.decomposition.sparse_encode",
"sklearn.feature_extraction.grid_to_graph",
"sklearn.feature_extraction.img_to_graph",
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.