Giter Site home page Giter Site logo

Comments (9)

capaulson avatar capaulson commented on August 18, 2024 1

Hi Michael,

Sorry that the examples aren't clear. I've included a bare-bones example below that attempts to show how to use pyKriging. The X array represents an array of vectors where observations are made, while the y array holds the corresponding scalar for each observed point. Once a Kriging model is initialized with the observed data, you need to train the model (k.train()). Training the model establishes the hyperparameters for the model. Once trained, you can query the model (k.predict()) or plot the result.

Does this help?

Best,
Chris

import numpy as np 
from pyKriging import kriging
X = np.array([[ 0.75,  0.15],
       [ 0.55,  0.95],
       [ 0.15,  0.25],
       [ 0.25,  0.85],
       [ 0.05,  0.65],
       [ 0.35,  0.45],
       [ 0.45,  0.05],
       [ 0.85,  0.75],
       [ 0.65,  0.55],
       [ 0.95,  0.35]])

y = np.array( [0.865, 0.325, 0.085, 0.065 ,0.125, 0.325, 0.925, 1.145, 1.325, 0.9025] )

k = kriging(X, y)
k.train()
print k.predict([.25,.25])
k.plot()

from pykriging.

hal98x avatar hal98x commented on August 18, 2024

Thanks for getting back too me, I have been using pykrige for awhile and there are some performance issues with the newest version, so now I am back testing your library. The example ran perfectly and so I tried extending it to my data. I followed the example with my 2225 measurements and I get the following exception

File "C:\Users\mwallace\AppData\Local\Continuum\Anaconda2\lib\site-packages\pyKriging\krige.py", line 145, in updateModel
raise Exception("bad params")

Exception: bad params

Also do you have any doc on the inputs to k.plot and kriging?

from pykriging.

capaulson avatar capaulson commented on August 18, 2024

Hmmm... If I had to guess (without seeing the data), you have two identical points or two points that are very close to each other. This causes issues in matrix calculations. Could you share data?

from pykriging.

hal98x avatar hal98x commented on August 18, 2024

I removed all the points that where less than a meter apart from each other and then executed the code again. No luck still get bad params error. Attached is a csv with the 3 columns of data.

pyKrigging_test.txt

setup grid

xmin=np.min(x)
xmax=np.max(x)
ymin=np.min(y)
ymax=np.max(y)

dx=(xmax-xmin)
dy=(ymax-ymin)
gridy = np.arange(0, dy, dy/100.0)
gridx = np.arange(0, dx, dx/100.0)

grid=np.vstack((gridx,gridy)).T

from example in this thread

k = kriging(pos, z)
k.train()
znew=k.predict(grid)
k.plot()

Sincerely,

Michael Wallace

from pykriging.

capaulson avatar capaulson commented on August 18, 2024

Michael,

Thank you for sharing the data. This issue was fairly obvious. I believe it should be addressed by this commit:

03e02c4

I'm running the model right now, but it is taking a while. I'll report back once I get it trained to verify that it worked.

Best,
Chris

from pykriging.

capaulson avatar capaulson commented on August 18, 2024

Michael,

I wanted to follow up with results. To save time on training, I reduced the point count to 500 randomly selected points. The included plot shows the results. The upper left is a contour plot of the prediction, upper right is the predicted MSE, the lower plot is a 3D plot of the prediction model.
pykriging_issue_7

from pykriging.

capaulson avatar capaulson commented on August 18, 2024

This is the Kriging model with all the data:
pykriging_issue_7

from pykriging.

hal98x avatar hal98x commented on August 18, 2024

Thanks this is great and looks really good and its in the same color scale I use daily.

I figured out how to update my system and then I tried running the code. Performance on my computer is slow even when I decimate the data. I was unable to get past the training step (no error) just killed the process because it had been running for too long (over an hour for the big set). It is interesting though to compare the decimated to undecimated data. It says I don't need that dense of data to get a decent interpretation.

Your observation about overlapping points was also helpful because it gave me a way to filter all the data for overlap instead of just clusters. I think I need to use a compiled library like gslib, surfer win32com events, qgis or sage possibly.

I think I will use pyKrigging for another application where there is less and sparser data. Thanks capaulson for the help and being responsive.

Sincerely,

Michael Wallace

from pykriging.

WhitCrow avatar WhitCrow commented on August 18, 2024

why not have more detailed documentation!

from pykriging.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.