2016-10-22 9 views
-1

私はpython 2.7とsklearn 1.8を使用しました。私のpythonコードでエラーが発生しました "ValueError:サンプルの数が一致しない入力変数が見つかりました:[16、8760]"

次に、1dアレイを使用して2dアレイを作成しました。そのような

x=np.array([a,b,c,d...]) 

(A、B、C、D ..ある1Dアレイ)も

y=np.array(arr) 

ARR 1Dアレイ

model = GaussianNB() 
model.fit(x,y) 

その私このエラー

を与えます
File "E:/python/read2.py", line 73, in <module> 
    model.fit(x,y) 
    File "C:\Python27\lib\site-packages\sklearn\naive_bayes.py", line 182, in fit 
    X, y = check_X_y(X, y) 
    File "C:\Python27\lib\site-packages\sklearn\utils\validation.py", line 531, in check_X_y 
    check_consistent_length(X, y) 
    File "C:\Python27\lib\site-packages\sklearn\utils\validation.py", line 181, in check_consistent_length 
    " samples: %r" % [int(l) for l in lengths]) 
ValueError: Found input variables with inconsistent numbers of samples: [16, 8760] 

x.shape =>(16,8760) ys HAPE =>(8760)

が助けを必要としてください。..

+0

2つの入力の必要な形状について、「フィット」のヘルプは何を言っていますか? 'x'と' y'の形を理解していますか? – hpaulj

答えて

0

から:http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html#sklearn.naive_bayes.GaussianNB.fit

X : array-like, shape (n_samples, n_features) 
Training vectors, where n_samples is the number of samples and n_features is the number of features. 
y : array-like, shape (n_samples,) 

自分の価値観:

x.shape => (16, 8760) y.shape => (8760,) 

8760個のサンプル、16個の機能のように見えますか?その場合はx.Tが動作する可能性があります。

+0

あなたの応答をありがとう、はい私はそれを読んで、私はxの形が間違っていることを知っている私はなぜ私がxを作成したか説明しています。 –

関連する問題