8000 FIX Do not use deprecated API in fetch_20newsgroups_vectorized (#21216) · scikit-learn/scikit-learn@6f91cbe · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f91cbe

Browse files
thomasjpfanlesteve
andauthored
FIX Do not use deprecated API in fetch_20newsgroups_vectorized (#21216)
* FIX Do not use deprecated API in fetch_20newsgroups_vectorized * BLD [scipy-dev] * TST Be explicit about fill value [scipy-dev] * TST Fixes tests for fill value * [scipy-dev] trigger nightly build Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
1 parent 5ea46a5 commit 6f91cbe

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sklearn/datasets/_twenty_newsgroups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def fetch_20newsgroups_vectorized(
479479
vectorizer = CountVectorizer(dtype=np.int16)
480480
X_train = vectorizer.fit_transform(data_train.data).tocsr()
481481
X_test = vectorizer.transform(data_test.data).tocsr()
482-
feature_names = vectorizer.get_feature_names()
482+
feature_names = vectorizer.get_feature_names_out()
483483

484484
joblib.dump((X_train, X_test, feature_names), target_file, compress=9)
485485

sklearn/utils/tests/test_validation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,8 @@ def test_check_pandas_sparse_invalid(ntype1, ntype2):
14141414
pd = pytest.importorskip("pandas", minversion="0.25.0")
14151415
df = pd.DataFrame(
14161416
{
1417-
"col1": pd.arrays.SparseArray([0, 1, 0], dtype=ntype1),
1418-
"col2": pd.arrays.SparseArray([1, 0, 1], dtype=ntype2),
1417+
"col1": pd.arrays.SparseArray([0, 1, 0], dtype=ntype1, fill_value=0),
1418+
"col2": pd.arrays.SparseArray([1, 0, 1], dtype=ntype2, fill_value=0),
14191419
}
14201420
)
14211421

@@ -1456,8 +1456,8 @@ def test_check_pandas_sparse_valid(ntype1, ntype2, expected_subtype):
14561456
pd = pytest.importorskip("pandas", minversion="0.25.0")
14571457
df = pd.DataFrame(
14581458
{
1459-
"col1": pd.arrays.SparseArray([0, 1, 0], dtype=ntype1),
1460-
"col2": pd.arrays.SparseArray([1, 0, 1], dtype=ntype2),
1459+
"col1": pd.arrays.SparseArray([0, 1, 0], dtype=ntype1, fill_value=0),
1460+
"col2": pd.arrays.SparseArray([1, 0, 1], dtype=ntype2, fill_value=0),
14611461
}
14621462
)
14631463
arr = check_array(df, accept_sparse=["csr", "csc"])

0 commit comments

Comments
 (0)
0