高斯混合模型(GMM)中有一部分适合我不理解它。我很乐意得到你的建议:
g = GMM(3, n_iter=1000, verbose=True, random_state=3)
g.fit(WORK)
np.random.seed(1)
X = g.sample(1000)
# fit models with 1-10 components
N = np.arange(1, 11)
models = [None for i in range(len(N))]
for i in range(len(N)):
models[i] = GMM(N[i]).fit(X)
答案 0 :(得分:0)
它正在生成一个拟合列表models
,假设混合物中分别有i = 1,2,...,10个组件,可能意图选择其中的最佳模型。
答案 1 :(得分:0)
有人可以指出为什么我们用WORK中的3个组件创建GMM, 然后从GMM中抽取样本以获得更好的模型
我会简化这个,
np.random.seed(1) #will ensure reproducibiity
# fit models with 1-10 components
N = np.arange(1, 11)
models = [None for i in range(len(N))]
#find the model with minimum aic score
min_aic = np.inf
model_index_with_min_aic = -1
for i in range(len(N)):
models[i] = GMM(N[i], n_iter=1000).fit(WORK)
aic = models[i[.aic(WORK)
if aic < min_aic:
model_index_with_min_aic = i
min_aic = aic
答案 2 :(得分:0)
GMM基本上,为每个火车样本创建一个“模型”,因此,如果您有10个火车样本,则每个样本可能还会获得10个模型。
如果要测试模型,则还需要调用GMM创建的每个模型,因此它就像[1:1] x N次