当前位置: 首页>>代码示例>>Python>>正文


Python GaussianMixture.set_params方法代码示例

本文整理汇总了Python中sklearn.mixture.gaussian_mixture.GaussianMixture.set_params方法的典型用法代码示例。如果您正苦于以下问题:Python GaussianMixture.set_params方法的具体用法?Python GaussianMixture.set_params怎么用?Python GaussianMixture.set_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.mixture.gaussian_mixture.GaussianMixture的用法示例。


在下文中一共展示了GaussianMixture.set_params方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_regularisation

# 需要导入模块: from sklearn.mixture.gaussian_mixture import GaussianMixture [as 别名]
# 或者: from sklearn.mixture.gaussian_mixture.GaussianMixture import set_params [as 别名]
def test_regularisation():
    # We train the GaussianMixture on degenerate data by defining two clusters
    # of a 0 covariance.
    rng = np.random.RandomState(0)
    n_samples, n_features = 10, 5

    X = np.vstack((np.ones((n_samples // 2, n_features)),
                   np.zeros((n_samples // 2, n_features))))

    for covar_type in COVARIANCE_TYPE:
        gmm = GaussianMixture(n_components=n_samples, reg_covar=0,
                              covariance_type=covar_type, random_state=rng)

        with warnings.catch_warnings():
            warnings.simplefilter("ignore", RuntimeWarning)
            assert_raise_message(ValueError,
                                 "The algorithm has diverged because of too "
                                 "few samples per components. "
                                 "Try to decrease the number of components, "
                                 "or increase reg_covar.", gmm.fit, X)

            gmm.set_params(reg_covar=1e-6).fit(X)
开发者ID:LANRRI,项目名称:scikit-learn,代码行数:24,代码来源:test_gaussian_mixture.py

示例2: test_regularisation

# 需要导入模块: from sklearn.mixture.gaussian_mixture import GaussianMixture [as 别名]
# 或者: from sklearn.mixture.gaussian_mixture.GaussianMixture import set_params [as 别名]
def test_regularisation():
    # We train the GaussianMixture on degenerate data by defining two clusters
    # of a 0 covariance.
    rng = np.random.RandomState(0)
    n_samples, n_features = 10, 5

    X = np.vstack((np.ones((n_samples // 2, n_features)),
                   np.zeros((n_samples // 2, n_features))))

    for covar_type in COVARIANCE_TYPE:
        gmm = GaussianMixture(n_components=n_samples, reg_covar=0,
                              covariance_type=covar_type, random_state=rng)

        with warnings.catch_warnings():
            warnings.simplefilter("ignore", RuntimeWarning)
            assert_raise_message(ValueError,
                                 "Fitting the mixture model failed because "
                                 "some components have ill-defined empirical "
                                 "covariance (for instance caused by "
                                 "singleton or collapsed samples). Try to "
                                 "decrease the number of components, or "
                                 "increase reg_covar.", gmm.fit, X)

            gmm.set_params(reg_covar=1e-6).fit(X)
开发者ID:jerry-dumblauskas,项目名称:scikit-learn,代码行数:26,代码来源:test_gaussian_mixture.py


注:本文中的sklearn.mixture.gaussian_mixture.GaussianMixture.set_params方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。