modelcols() "world age problem" with "deserialized types"
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Reproduce the serialized-model case using BSON.jl or JLSO.jl, then call predict() inside a function and inspect the failure at src/terms.jl:491 in modelcols(). Compare the REPL and function contexts; done means the deserialized formula involving ^ no longer raises the world-age MethodError.
Written by the indexing model from the issue text.
Description
I tried to save a fitted model of type:
julia> typeof(mod)
StatsModels.TableRegressionModel{LinearModel{GLM.LmResp{Array{Float64,1}},GLM.DensePredChol{Float64,LinearAlgebra.Cholesky{Float64,Array{Float64,2}}}},Array{Float64,2}}
which has a modelframe as:
julia> mod.mf.f
FormulaTerm
Response:
v0(continuous)
Predictors:
1
x1(continuous)
x2(continuous)
(x1)->x1 ^ 2
(x2)->x2 ^ 2
(x1)->x1 ^ 3
(x2)->x2 ^ 3
(x1)->x1 ^ 4
(x2)->x2 ^ 4
x1(continuous) & x2(continuous)
into files using BSON.jl or JLSO.jl.
then, I load the file and call functions like predict() and everything is fine under REPL. However, they fail when I load the file and call predict() inside a function:
with the model saved via JLSO.save(;format = :julia_serialize):
ERROR: MethodError: no method matching (::Serialization.__deserialized_types__.var"#85#92")(::Float64)
The applicable method may be too new: running in world age 27958, while current world is 28007.
Closest candidates are:
#85(::Any) at none:0 (method too new to be called from this world context.)
Stacktrace:
[1] _broadcast_getindex_evalf at ./broadcast.jl:648 [inlined]
[2] _broadcast_getindex at ./broadcast.jl:621 [inlined]
[3] getindex at ./broadcast.jl:575 [inlined]
[4] copy at ./broadcast.jl:876 [inlined]
[5] materialize at ./broadcast.jl:837 [inlined]
[6] modelcols(::FunctionTerm{typeof(^),Serialization.__deserialized_types__.var"#85#92",(:zx1,)}, ::NamedTuple{(:zx1, :zx2, :zx3, :zx4),NTuple{4,Array{Float64,1}}}) at /Users/Thomas/.julia/packages/StatsModels/FJnLj/src/terms.jl:491
with the model saved via BSON.bson():
ERROR: MethodError: no method matching (::BSON.__deserialized_types__.var"#85#92")(::Float64)
The applicable method may be too new: running in world age 28011, while current world is 28060.
Closest candidates are:
#85(::Any) at none:0 (method too new to be called from this world context.)
Stacktrace:
[1] _broadcast_getindex_evalf at ./broadcast.jl:648 [inlined]
[2] _broadcast_getindex at ./broadcast.jl:621 [inlined]
[3] getindex at ./broadcast.jl:575 [inlined]
[4] copy at ./broadcast.jl:876 [inlined]
[5] materialize at ./broadcast.jl:837 [inlined]
[6] modelcols(::FunctionTerm{typeof(^),BSON.__deserialized_types__.var"#85#92",(:zx1,)}, ::NamedTuple{(:zx1, :zx2, :zx3, :zx4),NTuple{4,Array{Float64,1}}}) at /Users/Thomas/.julia/packages/StatsModels/FJnLj/src/terms.jl:491
seems like modelcols() has a "world age problem" dealing with ^ formulas, (e.g. @formula(y ~ x ^ 2)).
please kindly advise.
thanks.
- Dominant language
- Julia
- Stars
- 252
- Forks
- 36
- Avg merge
- 3h 14m
- Merged PRs (30d)
- 4
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaStats/StatsModels.jl
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
JuliaStats/StatsModels.jl#328 · 1 comment ·
-
Cell mean coding?Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
JuliaStats/StatsModels.jl#351 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
JuliaStats/StatsModels.jl#329 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
JuliaStats/StatsModels.jl#318 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
JuliaStats/StatsModels.jl#316 ·
All issues in JuliaStats/StatsModels.jl
Similar issues
-
Affine transformations of `JohnsonSU` could return a `JohnsonSU`Possibly taken @devmotion claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaStats/Distributions.jl#2117 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
TomerAberbach/profiler-md#970 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
grame-cncm/faust#1409 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
SciML/PETScDiffEq.jl#521 ·
Maintainers usually reply within 1 day