"estimator, check", [ pytest.param(estimator, check, id=f"{estimator}:{check.__name__}") for estimator in list(get_all_estimators()) + [ feature_extraction.TFIDF(), linear_model.LogisticRegression(), preprocessing.StandardScaler() | linear_model.LinearRegression(), preprocessing.StandardScaler() | linear_model.PAClassifier(), (preprocessing.StandardScaler() | multiclass.OneVsRestClassifier( linear_model.LogisticRegression())), (preprocessing.StandardScaler() | multiclass.OneVsRestClassifier(linear_model.PAClassifier())), naive_bayes.GaussianNB(), preprocessing.StandardScaler(), cluster.KMeans(n_clusters=5, seed=42), preprocessing.MinMaxScaler(), preprocessing.MinMaxScaler() + preprocessing.StandardScaler(), feature_extraction.PolynomialExtender(), (feature_extraction.PolynomialExtender() | preprocessing.StandardScaler() | linear_model.LinearRegression()), feature_selection.VarianceThreshold(), feature_selection.SelectKBest(similarity=stats.PearsonCorr()), ] for check in utils.estimator_checks.yield_checks(estimator) if check.__name__ not in estimator._unit_test_skips() ], ) def test_check_estimator(estimator, check): check(copy.deepcopy(estimator))
def _unit_test_params(cls): return {"similarity": stats.PearsonCorr()}
def _default_params(cls): return {'similarity': stats.PearsonCorr()}
n = stat.window_size X = [random.random() for _ in range(30)] for i, x in enumerate(X): stat.update(x) if i >= 1: assert math.isclose(stat.get(), func(tail(X[:i + 1], n)), abs_tol=1e-10) @pytest.mark.parametrize( 'stat, func', [(stats.Cov(), lambda x, y: np.cov(x, y)[0, 1]), (stats.PearsonCorr(), lambda x, y: sp_stats.pearsonr(x, y)[0])]) def test_bivariate(stat, func): # Shhh np.warnings.filterwarnings('ignore') X = [random.random() for _ in range(30)] Y = [random.random() * x for x in X] for i, (x, y) in enumerate(zip(X, Y)): stat.update(x, y) if i >= 1: assert math.isclose(stat.get(), func(X[:i + 1], Y[:i + 1]), abs_tol=1e-10)
def _unit_test_params(cls): yield {"similarity": stats.PearsonCorr()}