def test_non_meta_estimators(name, Estimator, check): # Common tests for non-meta estimators with ignore_warnings(category=(DeprecationWarning, ConvergenceWarning, UserWarning, FutureWarning)): estimator = Estimator() set_checking_parameters(estimator) check(name, estimator)
def test_check_estimator_clones(): # check that check_estimator doesn't modify the estimator it receives from sklearn.datasets import load_iris iris = load_iris() for Estimator in [GaussianMixture, LinearRegression, RandomForestClassifier, NMF, SGDClassifier, MiniBatchKMeans]: with ignore_warnings(category=FutureWarning): # when 'est = SGDClassifier()' est = Estimator() set_checking_parameters(est) set_random_state(est) # without fitting old_hash = joblib.hash(est) check_estimator(est) assert_equal(old_hash, joblib.hash(est)) with ignore_warnings(category=FutureWarning): # when 'est = SGDClassifier()' est = Estimator() set_checking_parameters(est) set_random_state(est) # with fitting est.fit(iris.data + 10, iris.target) old_hash = joblib.hash(est) check_estimator(est) assert_equal(old_hash, joblib.hash(est))
def test_estimators(estimator, check): # Common tests for estimator instances with ignore_warnings(category=(DeprecationWarning, ConvergenceWarning, UserWarning, FutureWarning)): set_checking_parameters(estimator) name = estimator.__class__.__name__ check(name, estimator)
def test_non_meta_estimators(): # input validation etc for non-meta estimators estimators = all_estimators() for name, Estimator in estimators: if issubclass(Estimator, BiclusterMixin): continue if name.startswith("_"): continue estimator = Estimator() # check this on class yield check_no_fit_attributes_set_in_init, name, Estimator for check in _yield_all_checks(name, estimator): set_checking_parameters(estimator) yield check, name, estimator
def test_non_meta_estimators(): # input validation etc for non-meta estimators estimators = all_estimators() for name, Estimator in estimators: if issubclass(Estimator, BiclusterMixin): continue if name.startswith("_"): continue estimator = Estimator() # check this on class yield check_no_attributes_set_in_init, name, estimator for check in _yield_all_checks(name, estimator): set_checking_parameters(estimator) yield check, name, estimator
def test_non_meta_estimators(name, Estimator, check): # Common tests for non-meta estimators estimator = Estimator() set_checking_parameters(estimator) check(name, estimator)
def test_set_checking_parameters(): with pytest.warns(DeprecationWarning, match="removed in version 0.24"): set_checking_parameters(DummyClassifier())