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

Skip to content

Commit 8316127

Browse files
thomasjpfanlesteve
authored andcommitted
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 8d0a426 commit 8316127

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
@@ -1406,8 +1406,8 @@ def test_check_pandas_sparse_invalid(ntype1, ntype2):
14061406
pd = pytest.importorskip("pandas", minversion="0.25.0")
14071407
df = pd.DataFrame(
14081408
{
1409-
"col1": pd.arrays.SparseArray([0, 1, 0], dtype=ntype1),
1410-
"col2": pd.arrays.SparseArray([1, 0, 1], dtype=ntype2),
1409+
"col1": pd.arrays.SparseArray([0, 1, 0], dtype=ntype1, fill_value=0),
1410+
"col2": pd.arrays.SparseArray([1, 0, 1], dtype=ntype2, fill_value=0),
14111411
}
14121412
)
14131413

@@ -1448,8 +1448,8 @@ def test_check_pandas_sparse_valid(ntype1, ntype2, expected_subtype):
14481448
pd = pytest.importorskip("pandas", minversion="0.25.0")
14491449
df = pd.DataFrame(
14501450
{
1451-
"col1": pd.arrays.SparseArray([0, 1, 0], dtype=ntype1),
1452-
"col2": pd.arrays.SparseArray([1, 0, 1], dtype=ntype2),
1451+
"col1": pd.arrays.SparseArray([0, 1, 0], dtype=ntype1, fill_value=0),
1452+
"col2": pd.arrays.SparseArray([1, 0, 1], dtype=ntype2, fill_value=0),
14531453
}
14541454
)
14551455
arr = check_array(df, accept_sparse=["csr", "csc"])

0 commit comments

Comments
 (0)
0