高斯分布-sklearn.mixture.GaussianMixture()

参考:https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html#sklearn.mixture.GaussianMixture

API:class sklearn.mixture.GaussianMixture(n_components=1covariance_type=’full’tol=0.001reg_covar=1e-06max_iter=100n_init=1init_params=’kmeans’weights_init=Nonemeans_init=Noneprecisions_init=Nonerandom_state=Nonewarm_start=Falseverbose=0verbose_interval=10)

参数:

n_components :混合元素(聚类)的数量,默认为1

covariance_type:描述要使用的协方差参数类型的字符串,必选一个(‘full’ , ‘tied’, ‘diag’, ‘spherical’),默认为full。

    full:每个混合元素有它公用的协方差矩阵;tied:每个混合元素共享同一个公共的协方差矩阵;

    diag:每个混合元素有它自己的对角矩阵;spherical:每个混合元素都有自己单独的方差值

tol:float类型, 默认值: 0.001.收敛阈值,当平均增益低于这个值时迭代停止。

reg_covar:float类型, 协方差对角线上的非负正则化参数,默认值: 1e-6  接近于0.

max_iter:最大迭代次数,默认为100

n_init:执行初始化操作数量,保持最好的结果,默认为1

init_params :可选 {‘kmeans’, ‘random’}, 默认值为 ‘kmeans’.初始化权重、均值及精度的方法,作用:用随机方法还是用kmeans方法初始化

weights_init:初始化权重列表,如果没有给定,那么使用init_params参数给定的方法来进行创建,默认为None
means_init:初始化均值列表,如果没有给定,那么使用init_params参数给定的方法来进行创建,默认为None
precisions_init: 初始化精度列表,如果没有给定,那么使用init_params参数给定的方法来进行创建,默认为None,它的形状依靠协方差类型,

 
协方差类型初始化精度形状
'spherical'(n_components,)
'tied'(n_features, n_features)
'diag'(n_components, n_features)
'full'(n_components, n_features, n_features)

random_state : 类型int, 随机数种子,默认为None. 

warn_stat:布尔类型,默认为False,当该值为true的时候,最后一次的学习结果作为下一次调用的初始化参数,在类似问题被多次训练的时候,可以加快收敛速度。在这种情况下‘n_init’可以忽略,并且在第一次调用时只发生一个初始化。

verbose : int类型, 默认为0.作用:可以冗余输出,如果为1,它会打印正确的初始化结果和每一次迭代步骤。如果大于1,则打印日志概率和每一步所需的时间。

verbose_interval : int类型, 默认为 10.作用:下一次打印之前的迭代发生次数

 

属性:

weights_ : array-like, shape (n_components,),每个混合元素权重

means_ : array-like, shape (n_components, n_features),每个混合元素均值

covariances_ : array-like,每个混合元素的协方差,它的形状依靠协方差类型,

协方差类型协方差形状
'spherical'(n_components,)
'tied'(n_features, n_features)
'diag'(n_components, n_features)
'full'(n_components, n_features, n_features)

precisions_ : array-like,每个混合元素精度矩阵,精度矩阵是协方差矩阵的逆。协方差矩阵是对称正定的,因此高斯混合可以用精度矩阵等价地参数化。存储精度矩阵而不是协方差矩阵使得在测试时间计算新样本的对数似然更有效。它的形状依靠协方差类型,

协方差类型精度形状
'spherical'(n_components,)
'tied'(n_features, n_features)
'diag'(n_components, n_features)
'full'(n_components, n_features, n_features)

precisions_cholesky_ : array-like (同上)

converged_ : bool类型,在fit()中达到收敛时为true,否则为false。

lower_bound_ : float类型,EM最佳拟合的对数似然(与模型相关的训练数据)的下限值。

 

方法:

aic(self, X)

Akaike information criterion for the current model on the input X.

在当前模型上输入X的Akaike信息准则

bic(self, X)

Bayesian information criterion for the current model on the input X.

在当前模型上输入X的贝叶斯信息准则。

fit(self, X[, y])

Estimate model parameters with the EM algorithm.

用EM算法估计模型参数。

fit_predict(self, X[, y])

Estimate model parameters using X and predict the labels for X.

用X估计模型参数,并预测X的标签。

get_params(self[, deep])

Get parameters for this estimator.

获取这个算法的参数

predict(self, X)

Predict the labels for the data samples in X using trained model.

使用训练模型预测X中数据样本的标签。

predict_proba(self, X)

Predict posterior probability of each component given the data.

在给定数据的情况下,预测每个分量的后验概率。

sample(self[, n_samples])

Generate random samples from the fitted Gaussian distribution.

从拟合的高斯分布生成随机样本。

score(self, X[, y])

Compute the per-sample average log-likelihood of the given data X.

计算给定数据X的每个样本平均log似然函数

score_samples(self, X)

Compute the weighted log probabilities for each sample.

计算每个样本的加权log概率。

set_params(self, \*\*params)

Set the parameters of this estimator.

为算法设置参数

__init__(selfn_components=1covariance_type=’full’tol=0.001reg_covar=1e-06max_iter=100n_init=1init_params=’kmeans’weights_init=Nonemeans_init=Noneprecisions_init=Nonerandom_state=Nonewarm_start=Falseverbose=0verbose_interval=10)

 

 

 

 

  • 6
    点赞
  • 51
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值