You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test function check_supervised_y_2d reuses an already fitted estimator which could leave potential side effects. For example, if an estimator uses a flag to only set random state once, the call to set_random_state(estimator) will have no effect and that can lead to a false negative (failure) in this test.
Steps/Code to Reproduce
importnumpyimportwarningsfromsklearn.baseimportBaseEstimatorfromsklearn.exceptionsimportDataConversionWarningfromsklearn.utils.estimator_checksimportcheck_supervised_y_2dclassRoundRobinClassifier(BaseEstimator):
def__init__(self, random_state=0):
self.random_state=random_statedeffit(self, X, y):
iflen(y.shape[1:]) >=1:
warnings.warn(
'A column-vector y was passed when a 1d array was expected',
DataConversionWarning)
ifnothasattr(self, 'idx'):
self.idx=int(self.random_state)
self.classes_=numpy.unique(y)
returnselfdefpredict(self, X):
pred= []
fori, _inenumerate(X):
pred.append(self.classes_[self.idx%len(self.classes_)])
self.idx= (self.idx+1) %len(self.classes_)
returnnumpy.asarray(pred)
classif=RoundRobinClassifier()
check_supervised_y_2d(classif.__class__.__name__, classif)
Expected Results
Test passes, since the required warning is thrown.
Actual Results
AssertionError:
Not equal to tolerance rtol=1e-07, atol=0
Description
Test function
check_supervised_y_2d
reuses an already fitted estimator which could leave potential side effects. For example, if an estimator uses a flag to only set random state once, the call toset_random_state(estimator)
will have no effect and that can lead to a false negative (failure) in this test.Steps/Code to Reproduce
Expected Results
Test passes, since the required warning is thrown.
Actual Results
Versions
Platform info:
Tested in the following versions:
The text was updated successfully, but these errors were encountered: