コード例 #1
0
def test_estimator_checks(test_fn):
    clf1 = GaussianMixtureNB()
    clf2 = GaussianMixtureNB(n_components=2)
    clf3 = BayesianGaussianMixtureNB()
    clf4 = BayesianGaussianMixtureNB(n_components=2)
    test_fn(GaussianMixtureNB.__name__, clf1)
    test_fn(GaussianMixtureNB.__name__ + "_components_5", clf2)
    test_fn(BayesianGaussianMixtureNB.__name__, clf3)
    test_fn(BayesianGaussianMixtureNB.__name__ + "_components_5", clf4)
コード例 #2
0
def test_obvious_usecase(k):
    X = np.concatenate([
        np.random.normal(-10, 1, (100, 2)),
        np.random.normal(10, 1, (100, 2))
    ])
    y = np.concatenate([np.zeros(100), np.ones(100)])
    assert (GaussianMixtureNB(n_components=k).fit(X, y).predict(X) == y).all()
    assert (BayesianGaussianMixtureNB(n_components=k).fit(
        X, y).predict(X) == y).all()