Issue
I'm using scikit learn to fit a Gaussian process regressor to some data. Ideally I want to do this for data with multiple targets, however the prediction doesn't seem return the std for multiple targets. As an example here I train a Gaussian process on 3 target statistics and predict at 100 sampled positions
gpr = GaussianProcessRegressor(kernel=kernel)
gpr.fit(x.reshape(-1,1), y_obs)
y,y_err=gpr.predict(x_sample.reshape(-1,1),return_std=True)
Where the training data has shape x.shape=(20,)
and y_obs.shape=(20,3)
. The predicted mean and errors (y,y_sample)
then do not have the same shape.
print(y.shape)
print(y_err.shape)
returns
(100,3)
(100,)
The mean, y
, is the shape I expect as I requested the 3 targets at 100 sampled positions. However y_err
doesn't seem be predicted for each target statistic.
This doesn't seem to be working as the documentation describes as both the mean and std should have shape (n_samples,) or (n_samples, n_targets)
Is this a bug, or am I missing something?
Solution
As far as I know, this is a bug (see https://github.com/scikit-learn/scikit-learn/pull/22199 and other related issues), fixed not so long ago. Sklearn 1.1.0 and up should return the proper shape. (However, multitarget GPR seems to be problematic in general so you may potentially encounter other issues still.)
Answered By - dx2-66
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.