8000 how can cv folds can be more than number of groups in cross_validate? · Issue #13972 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
how can cv folds can be more than number of groups in cross_validate? #13972
Closed
@omarcr

Description

@omarcr

In the following code:

from sklearn import datasets, linear_model
from sklearn.model_selection import cross_validate
from sklearn.metrics.scorer import make_scorer
from sklearn.metrics import confusion_matrix
from sklearn.svm import LinearSVC
import numpy as np

digits = datasets.load_digits()

X = digits.data[:500]
y = digits.target[:500]

counts, unique = np.unique(y, return_counts=True)

g1 = np.repeat(0, int(len(y)/2))
g2 = np.repeat(1, int(len(y)/2))

g = np.concatenate((g1, g2))

linear = LinearSVC()

cv_results = cross_validate(linear, X, y, cv=5)
sorted(cv_results.keys())
print(cv_results)


print('cv_results')
print(cv_results['test_score'])


print('cross-validate')
scores = cross_validate(linear, X, y, cv=5,
                        scoring=('f1_weighted'),
                        return_train_score=True, groups=g)
print(scores)

Shouldn't it be returned that:
groups should be equal to CV for the folds?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0