How can I save surrogate model in Julia and use it in Python


In my project, I would like to save surrogate model in Julia and use it in Python. HDF5 is the best file format? If yes, How can I read the surrogate model and use it in Python? Thanks!

It’s unclear what you mean by “saving a surrogate model” here — a surrogate model generally refers to an algorithm/code, not just data. (For example, radial basis functions, neural networks, polynomial fits, etcetera.) Unless you have code in Julia Python implementing the model, then transferring the data (e.g. polynomial coefficients) won’t help you.

If you are able to export your model as functional mockup unit (FMU) you can easily import it in Python: GitHub - ThummeTo/FMIExport.jl: FMIExport.jl is a free-to-use software library for the Julia programming language which allows for the export of FMUs ( from any Julia-Code. FMIExport.jl is completely integrated into FMI.jl.

@stevengj yes, the surrogate model is created by Surrogates.jl, and now I saved the model in JLD2 format which can’t read by python

Use pyjulia or something of the sort to call Julia from Python.

1 Like