8000 LogisticRegressionCV not compatible with LeaveOneGroupOut · Issue #8950 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
LogisticRegressionCV not compatible with LeaveOneGroupOut #8950
Closed
@ghost

Description

In LogisticRegressionCV, the documentation says the argument cv could be a cross-validation object from model_selection. However, when I pass LeaveOneGroupOut as an argument, it has errors in it. I read the source code. I think the problem is that in LogisticRegressionCV, when calling the split method, it only pass X and y, but LeaveOneGroupOut requires an additional argument groups, and we have nowhere to pass this argument. This also raises problems when I use 65EA LogisticRegressionCV as the base estimator for something like OneVsRestClassifier.

Here's a small example:

import numpy as np
from sklearn.model_selection import LeaveOneGroupOut
from sklearn.linear_model import LogisticRegressionCV

X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])
y = np.array([1, 2, 1, 2])
groups = np.array([1, 1, 2, 2])
logo = LeaveOneGroupOut()

clf = LogisticRegressionCV(cv = logo)
clf.fit(X,y)

Error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/linear_model/logistic.py", line 1581, in fit
    folds = list(cv.split(X, y))
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/model_selection/_split.py", line 91, in split
    for test_index in self._iter_test_masks(X, y, groups):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/sklearn/model_selection/_split.py", line 778, in _iter_test_masks
    raise ValueError("The groups parameter should not be None")
ValueError: The groups parameter should not be None

Darwin-15.6.0-x86_64-i386-64bit
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
NumPy 1.11.1
SciPy 0.17.1
Scikit-Learn 0.18.1

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