Hello Community,
How can I save and load the model generated by surrogates.jl?
Hello Community,
How can I save and load the model generated by surrogates.jl?
IIRC JLD2 works.
Thanks!
@ChrisRackauckas
After some tests, I think JLD2 or BSON can’t serialize the Julia function, and the Surrogates.jl returns Julia function as result. For example, RandomForestSurrogate returns the model (::RandomForestSurrogate{Vector{Float64}, Vector{Float64}, XGBoost.Booster, Float64, Float64, Int64}) (generic function with 2 methods)
.
When I load the model, it throws the error:
UndefVarError: XGBoost not defined
Stacktrace:
[1] (::BSON.var"#31#32")(m::Module, f::String)
@ BSON ~/.julia/packages/BSON/rOaki/src/extensions.jl:21
[2] BottomRF
@ ./reduce.jl:81 [inlined]
[3] _foldl_impl(op::Base.BottomRF{BSON.var"#31#32"}, init::Module, itr::Vector{Any})
@ Base ./reduce.jl:58
[4] foldl_impl
@ ./reduce.jl:48 [inlined]
[5] mapfoldl_impl
@ ./reduce.jl:44 [inlined]
[6] _mapreduce_dim
@ ./reducedim.jl:327 [inlined]
[7] #mapreduce#725
@ ./reducedim.jl:322 [inlined]
[8] #reduce#727
@ ./reducedim.jl:371 [inlined]
[9] resolve(fs::Vector{Any}, init::Module)
@ BSON ~/.julia/packages/BSON/rOaki/src/extensions.jl:21
[10] (::BSON.var"#35#36")(d::Dict{Symbol, Any}, init::Module)
@ BSON ~/.julia/packages/BSON/rOaki/src/extensions.jl:64
[11] _raise_recursive(d::Dict{Symbol, Any}, cache::IdDict{Any, Any}, init::Module)
@ BSON ~/.julia/packages/BSON/rOaki/src/read.jl:80
I am from python to Julia, and confused that is there any fit
method in Surrogates.jl ?
Open an issue.