pyKriging icon indicating copy to clipboard operation
pyKriging copied to clipboard

1-d infill error estimate

Open achase90 opened this issue 9 years ago • 5 comments

I think there might be a bug in the kriging or MSE estimate if the problem is compressed to 2-D (ie, one input and one output). If you run the x*sin(x) test function with only a few points (2-4) and plot the error estimate, it doesn't look correct.

Is the smoothness factor "p" getting optimized on as well as the theta values? If not, that might cause this issue. I believe this bug also exists in the Matlab code, so that won't be a great resource to compare against.

achase90 avatar Jun 10 '16 01:06 achase90

I'll take a look. 1-d arrays weren't really tested during development. I need to add some checks to make sure that the array is at least 2-d. The p factor is optimised in this code. Could you post a quick script to recreate the issue you're seeing with x*sin(x)?

capaulson avatar Jun 14 '16 20:06 capaulson

I've noticed something similar in working with 1-d arrays - please see the code below and resultant output.

import pyKriging
from pyKriging.krige import kriging

MAXVAL = 32
CONVERSION = 0.9687491103216275

X = np.array([[0.01], [1], [2], [8], [16], [32]]) / MAXVAL
y = np.array([
    4.97292791842937,   
    4.84888042822178,   
    4.843428519136497,  
    4.885980222410153,  
    4.952942447020513,  
    5.06074067099633,   
]) * CONVERSION

k = kriging(X, y)
k.train(optimizer='pso')
k.snapshot()

from matplotlib import pyplot as pl
pl.scatter(X * MAXVAL, y, c='black', s=20)
xs = [x / 1000. * MAXVAL for x in xrange(1000)]
k_predictions = [k.predict([x / MAXVAL]) for x in xs]
pl.plot(xs, k_predictions,)
errors = [k.predict_var([x / MAXVAL]) for x in xs]
pl.fill(
    xs + xs[::-1], 
    [pred + err for pred, err in zip(k_predictions, errors)] +
    [pred - err for pred, err in zip(k_predictions, errors)][::-1],
    alpha=.25,
    fc='black'
)
pl.show()

This results in:

Any assistance would be greatly appreciated.

hchasestevens avatar Jun 24 '16 17:06 hchasestevens

Hi, thanks for the example. I'm looking into this now. It seems to be an error in how the predictions are generated. More to come soon.

Best, Chris

capaulson avatar Jun 24 '16 21:06 capaulson

Did you ever figure out what was going on with this?

achase90 avatar Jan 05 '18 07:01 achase90

Hi @capaulson , just wondering if you ever determined the cause of the issue here. Thanks!

hchasestevens avatar Aug 17 '18 14:08 hchasestevens