本文整理汇总了Python中sklearn.mixture.gaussian_mixture.GaussianMixture.predict方法的典型用法代码示例。如果您正苦于以下问题:Python GaussianMixture.predict方法的具体用法?Python GaussianMixture.predict怎么用?Python GaussianMixture.predict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.mixture.gaussian_mixture.GaussianMixture
的用法示例。
在下文中一共展示了GaussianMixture.predict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_gaussian_mixture_fit_predict_n_init
# 需要导入模块: from sklearn.mixture.gaussian_mixture import GaussianMixture [as 别名]
# 或者: from sklearn.mixture.gaussian_mixture.GaussianMixture import predict [as 别名]
def test_gaussian_mixture_fit_predict_n_init():
# Check that fit_predict is equivalent to fit.predict, when n_init > 1
X = np.random.RandomState(0).randn(1000, 5)
gm = GaussianMixture(n_components=5, n_init=5, random_state=0)
y_pred1 = gm.fit_predict(X)
y_pred2 = gm.predict(X)
assert_array_equal(y_pred1, y_pred2)
示例2: test_gaussian_mixture_predict_predict_proba
# 需要导入模块: from sklearn.mixture.gaussian_mixture import GaussianMixture [as 别名]
# 或者: from sklearn.mixture.gaussian_mixture.GaussianMixture import predict [as 别名]
def test_gaussian_mixture_predict_predict_proba():
rng = np.random.RandomState(0)
rand_data = RandomData(rng)
for covar_type in COVARIANCE_TYPE:
X = rand_data.X[covar_type]
Y = rand_data.Y
g = GaussianMixture(n_components=rand_data.n_components,
random_state=rng, weights_init=rand_data.weights,
means_init=rand_data.means,
precisions_init=rand_data.precisions[covar_type],
covariance_type=covar_type)
# Check a warning message arrive if we don't do fit
assert_raise_message(NotFittedError,
"This GaussianMixture instance is not fitted "
"yet. Call 'fit' with appropriate arguments "
"before using this method.", g.predict, X)
g.fit(X)
Y_pred = g.predict(X)
Y_pred_proba = g.predict_proba(X).argmax(axis=1)
assert_array_equal(Y_pred, Y_pred_proba)
assert_greater(adjusted_rand_score(Y, Y_pred), .95)