data
은 1 차원 데이터 배열입니다.단일 특징 데이터에 가우스 혼합 모델을 맞추는 올바른 방법은 무엇입니까?
data = [0.0, 7000.0, 0.0, 7000.0, -400.0, 0.0, 7000.0, -400.0, -7400.0, 7000.0, -400.0, -7000.0, -7000.0, 0.0, 0.0, 0.0, -7000.0, 7000.0, 7000.0, 7000.0, 0.0, -7000.0, 6600.0, -7400.0, -400.0, 6600.0, -400.0, -400.0, 6600.0, 6600.0, 6600.0, 7000.0, 6600.0, -7000.0, 0.0, 0.0, -7000.0, -7400.0, 6600.0, -400.0, 7000.0, -7000.0, -7000.0, 0.0, 0.0, -400.0, -7000.0, -7000.0, 7000.0, 7000.0, 0.0, -7000.0, 0.0, 0.0, 6600.0, 6600.0, 6600.0, -7400.0, -400.0, -2000.0, -7000.0, -400.0, -7400.0, 7000.0, 0.0, -7000.0, -7000.0, 0.0, -400.0, -7400.0, -7400.0, 0.0, 0.0, 0.0, -400.0, -400.0, -400.0, -400.0, 6600.0, 0.0, -400.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -400.0, -400.0, 0.0, 0.0, -400.0, -400.0, 0.0, -400.0, 0.0, -400.0]
나는이 데이터에 일부 가우시안을 맞추고 싶습니다. 내가
import numpy as np
from sklearn import mixture
x = np.array(data)
clf = mixture.GaussianMixture(n_components=2, covariance_type='full')
clf.fit(x)
을 실행하면
나는 나는이 살 수 ... 오류를
ValueError: Expected n_samples >= n_components but got n_components = 2, n_samples = 1
하고 확인을
DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
를 얻을. 경고는 나에게 무엇을해야하는지 알려줍니다. 내가
x = np.array(data).reshape(-1,1)
clf = mixture.GaussianMixture(n_components=2, covariance_type='full')
clf.fit(x)
를 실행하는 경우 그러나, 나는 오류 내가 잘못 뭐하는 거지
ValueError: Expected the input data X have 1 features, but got 32000 features
거야? 올바른 방법은 무엇입니까?
편집 : 난 그냥 오류 메시지를 잘못 해석 것을 깨달았다
. fit()
은 오류가 아니지만 score_samples()
입니다.
나는 나중에 가우시안들에게 음모를 꾸미려고 노력하고있다.
x = np.linspace(-8000,8000,32000)
y = clf.score_samples(x)
plt.plot(x, y)
plt.show()
그래서 x
이 문제 인 것 같습니다. 그러나 x.reshape(-1,1)
도 도움이되지 않습니다. x.reshape(1,-1)
.
당신이 (-1 일) 그것을 다른 방법을 바꿀 시도? –
예, 이미 시도했습니다. 내 의견을 존 Moutafis 대답을 참조하십시오. –
(-1,1), scikit 0.18 –