Comments (17)
Could you show your code for pickling? Have you got an error?
from smt.
I did:
sm = models[model](**par)
sm.set_training_values(X_train, y_train)
sm.train()
with open("best_models.pickle", "wb") as handle:
pickle.dump(sm, handle)
I got this error:
PicklingError: Can't pickle <class 'function'>: attribute lookup function on builtins failed
from smt.
Ok. That was fixed recently for Kriging based surrogates at least (see #154). So you have to install SMT from GitHub.
from smt.
Ah ok, thank you very much.
What can I do for other models, such as RBF or IDW?
from smt.
I've just released SMT 0.3.3, you can try it with:
pip install -U smt
Regarding, IDW and RBF, do you get an error? I am not sure but I think it had worked for me.
from smt.
It gives me this error:
File "W:/17_Users/trainees/Battolla/manda\regression.py", line 647, in AutoInterpolation
pickle.dump(best_models, handle)File "stringsource", line 2, in smt.surrogate_models.rbfclib.PyRBF.reduce_cython
TypeError: no default reduce due to non-trivial cinit
I have no clue what is about
from smt.
My bad. Indeed it does not work for IDW and RBF and other surrogates using a Cython extensions. Those require special handling (see stackoverflow related question).
from smt.
But if I save KPLS, do I need to retrain the model or can I load directly to predict new points? Because I am not able to do that.
from smt.
from smt.
But if I save KPLS, do I need to retrain the model or can I load directly to predict new points? Because I am not able to do that.
What is going on? After the dump, you should be able to load the KPLS surrogate using pickle.load()
and retrieve the trained surrogate.
from smt.
Hello @relf ,
Is there an accepted method to saving trained surrogates that do use Cython? I followed the link you posted above, but I am still confused about how it is implemented. Specifically, I am trying to save an IDW model.
My bad. Indeed it does not work for IDW and RBF and other surrogates using a Cython extensions. Those require special handling (see stackoverflow related question).
My code is nearly the same as the OP, though I get a different error:
TypeError: no default __reduce__ due to non-trivial __cinit__
Thanks
from smt.
@ldallen-crrel No, we have not work specifically on surrogates dump, I've just referenced the link I found after a 2-minutes search. I've started to make pickling work for kriging-based ones but as I said Cython extensions require special handling. I've not planned to work on that, but it would be a great contribution to SMT. What do you mean by OP?
from smt.
Thank you for the reply. By OP, I only meant the original poster (ArioBattolla).
from smt.
Bumping this after some time passed. Has this been resolved? Or has anyone found a workaround? I still get the following error when saving some models (e.g. RBF): TypeError: no default __reduce__ due to non-trivial __cinit__
from smt.
Nothing has evolved on this point. You get an error as it is not implemented (hence the open status of this issue). As far as I am concerned, I do not work on this but I will be happy to integrate a PR on this topic.
from smt.
Bumping on this again, for future reference, note that even if they can not be pickled directly, RBF, IDW, RMTS (like QP and LS) training operation can be cached.
These surrogates have a data_dir
option which allows to specify a directory to cache relevant data for each method. Provided you initialize the method with the same training data, cached data is loaded back from the previous run without running training operation again.
from smt.
A section on this topic is added to the documentation.
from smt.
Related Issues (20)
- Installation error HOT 4
- Fixing seed of surrogates HOT 1
- Does SMT support parallel computing or GPU computing? HOT 1
- SMT version 1.3 or 2.0? HOT 2
- Can't Run Example EGO Code HOT 2
- Kriging surrogate model in case of multiple outputs HOT 5
- Sampling Method sometimes gets stuck HOT 2
- pyDOE2 non-functional with python 3.12, appears to be unsupported. HOT 5
- Question on drawing drawing sample from MFK GP posterior. HOT 3
- Any interest in putting this on conda-forge? HOT 3
- Zero predicted variance while prediction differs from ground truth HOT 1
- Adaptive sampling methods for Kriging models and its variants including multi-fidelity Kriging HOT 1
- AttributeError: 'DesignSpace' object has no attribute '_cs' HOT 4
- InactiveHyperparameterSetError encountered when solving the HierarchicalGoldstein problem. HOT 3
- 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
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.