Comments (4)
The following code works for me:
import numpy as np
import matplotlib.pyplot as plt
from smt.surrogate_models import KRG
from smt.applications.mixed_integer import MixedIntegerKrigingModel
from smt.utils.design_space import DesignSpace, IntegerVariable
import pickle
xt = np.array([0.0, 2.0, 3.0])
yt = np.array([0.0, 1.5, 0.9])
design_space = DesignSpace(
[
IntegerVariable(0, 4),
]
)
sm = MixedIntegerKrigingModel(
surrogate=KRG(design_space=design_space, theta0=[1e-2])
)
sm.set_training_values(xt, yt)
sm.train()
num = 500
x = np.linspace(0.0, 4.0, num)
y = sm.predict_values(x)
# estimated variance
s2 = sm.predict_variances(x)
filename = "kriging.pkl"
with open(filename, "wb") as f:
pickle.dump(sm, f)
sm2 = None
filename = "kriging.pkl"
with open(filename, "rb") as f:
sm2 = pickle.load(f)
y_2 = sm2.predict_values(x)
# estimated variance
s2_2 = sm2.predict_variances(x)
np.testing.assert_almost_equal(y, y_2)
np.testing.assert_almost_equal(s2, s2_2)
Could you try it? (Please copy/paste the error message if any)
I guess you may have saved and loaded with different SMT installation.
from smt.
Thank you for the fast response, I will give your code a try and report back later today.
You are right, the model was generated and saved using version 2.1.0. There was no issue loading and using the model with version 2.0.1 and the above described error was returned when using version 2.2.1.
from smt.
The self._cs
attribute was introduced in #474 in SMT 2.2, it makes a model pickled with previous versions incompatible (sorry for that!). So I guess either you generate your model again with SMT 2.2+ or you just keep SMT 2.1 or... you patch like you did.
from smt.
Closing. Hope you found your way.
from smt.
Related Issues (20)
- data-driven Multi-Fidelity Kriging HOT 1
- ValueError by passing an int instead of a float HOT 3
- SMT 2.5 is not available on conda-forge HOT 2
- Error from SMT --> ValueError: setting an array element with a sequence. HOT 4
- Question on new syntax to train GENN (JENN) models HOT 6
- Meta: add "Discussions" to GitHub repo? HOT 1
- Saving models without using pickle? HOT 1
- Number of parameters can be handled by KPLSK HOT 3
- Deprecation warning HOT 1
- Document mapping between function arguments and equations HOT 2
- Hessian computation/Compatibility with dual numbers HOT 4
- SIGBUS (Misaligned Address Error) HOT 1
- negative axis 1 index
- Training two samples take ~480 seconds HOT 3
- OOB access in RMTB HOT 1
- SGP Gradients unsupported HOT 1
- Relevance of the warning `R is too ill conditioned...` HOT 1
- ConfigSpace vs Numpy 2.0 compatibility HOT 1
- Document parameters to improve accuracy of SGP
- Recommendation for surrogate optimization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smt.