2012-11-13 47 views
0

我正在生成random.uniform(low=0.0, high=100.0, size=(150,150))數組。
我將其輸入到生成X,xy的函數中。sklearn.gaussian_process fit()不適用於大於100的數組大小

但是,如果隨機測試矩陣大於100,我會得到下面的錯誤。
我曾嘗試玩θ的值。

有沒有人有這個問題?這是一個錯誤?
我正在使用python2.6scikit-learn-0.10。我應該嘗試python3

歡迎任何建議或意見。

謝謝。

gp.fit(XKrn, yKrn) 
    File "/usr/lib/python2.6/scikit_learn-0.10_git-py2.6-linux-x86_64.egg/sklearn/gaussian_process/gaussian_process.py", line 258, in fit 
    raise ValueError("X and y must have the same number of rows.") 
ValueError: X and y must have the same number of rows. 

回答

3

ValueError: X and y must have the same number of rows.意味着在你的情況XKrn.shape[0]應等於yKrn.shape[0]。您在生成數據集的代碼中可能有錯誤。

這裏是一個工作示例:

In [1]: from sklearn.gaussian_process import GaussianProcess 

In [2]: import numpy as np 

In [3]: X, y = np.random.randn(150, 10), np.random.randn(150) 

In [4]: GaussianProcess().fit(X, y) 
Out[4]: 
GaussianProcess(beta0=None, 
     corr=<function squared_exponential at 0x10d42aaa0>, normalize=True, 
     nugget=array(2.220446049250313e-15), optimizer='fmin_cobyla', 
     random_start=1, 
     random_state=<mtrand.RandomState object at 0x10b4c8360>, 
     regr=<function constant at 0x10d42a488>, storage_mode='full', 
     theta0=array([[ 0.1]]), thetaL=None, thetaU=None, verbose=False) 

的Python 3不支持和scikit學習最新發布的版本是0.12.1在這個時候。

0

我原來的帖子被刪除了。謝謝,Flexo。

我有同樣的問題,我傳入的行數與我的X和y中相同。

就我而言,問題在於我傳遞了許多功能以適應輸出。高斯過程適合單個輸出特徵。

「行數」錯誤是誤導性的,並且源於我沒有正確使用該包的事實。爲了適應這樣的多個輸出功能,您需要每個功能的GP。