JuliaAI / JuliaAI/MLJTuning.jl

`learning_curve` throwing nested task error

Open
#155 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
70
Forks
12
PR merge metrics
No merged PRs in 30d

Description

X, y = make_blobs()

model = (@load RandomForestClassifier pkg=DecisionTree)()
mach = machine(model, X, y)

r = range(model, :n_trees, lower=10, upper=70, scale=:log10)
many_curves = learning_curve(mach,
                             range=r,
                             resampling=Holdout(),
                             measure=cross_entropy,
                             rng_name=:rng,
                             rngs=1)

Evaluating Learning curve with 1 rngs:   0%[>                 ]  ETA: N/A┌ Error: Problem fi
tting the machine Machine{RandomForestClassifier,…}.                              
└ @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/machines.jl:533
[ Info: Running type checks... 
[ Info: Type checks okay. 
┌ Error: Problem fitting the machine Machine{Resampler{Holdout},…}. 
└ @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/machines.jl:533
[ Info: Running type checks... 
[ Info: Type checks okay. 
┌ Error: Problem fitting the machine Machine{ProbabilisticTunedModel{Grid,…},…}. 
└ @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/machines.jl:533
[ Info: Running type checks... 
[ Info: Type checks okay. 
ERROR: TaskFailedException
Stacktrace:
  [1] wait
    @ ./task.jl:322 [inlined]
  [2] threading_run(func::Function)
    @ Base.Threads ./threadingconstructs.jl:34
  [3] macro expansion
    @ ./threadingconstructs.jl:93 [inlined]
  [4] build_forest(labels::Vector{UInt32}, features::Matrix{Float64}, n_subfeatures::Int64, 
n_trees::Int64, partial_sampling::Float64, max_depth::Int64, min_samples_leaf::Int64, min_samples_split::Int64, min_purity_increase::Float64; rng::Random.MersenneTwister)        
    @ DecisionTree ~/.julia/packages/DecisionTree/iWCbW/src/classification/main.jl:223
  [5] fit(m::MLJDecisionTreeInterface.RandomForestClassifier, verbosity::Int64, X::DataFrames.DataFrame, y::CategoricalVector{Int64, UInt32, Int64, CategoricalValue{Int64, UInt32}, Union{}})                           
    @ MLJDecisionTreeInterface ~/.julia/packages/MLJDecisionTreeInterface/RZmUr/src/MLJDecisionTreeInterface.jl:200                                                             
  [6] fit_only!(mach::Machine{MLJDecisionTreeInterface.RandomForestClassifier, true}; rows::
Vector{Int64}, verbosity::Int64, force::Bool)                                              
    @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/machines.jl:531
  [7] #fit!#103
    @ ~/.julia/packages/MLJBase/HZmTU/src/machines.jl:598 [inlined]
  [8] fit_and_extract_on_fold
    @ ~/.julia/packages/MLJBase/HZmTU/src/resampling.jl:1088 [inlined]
  [9] (::MLJBase.var"#276#277"{MLJBase.var"#fit_and_extract_on_fold#299"{Vector{Tuple{Vector{Int64}, Vector{Int64}}}, Nothing, Nothing, Int64, Vector{LogLoss{Float64}}, Vector{typeof(predict)}, Bool, Bool, CategoricalVector{Int64, UInt32, Int64, CategoricalValue{Int64, UInt32}, Union{}}, DataFrames.DataFrame}, Machine{MLJDecisionTreeInterface.RandomForestClassifier, true}, Int64, ProgressMeter.Progress})(k::Int64)
    @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/resampling.jl:932
 [10] mapreduce_first
    @ ./reduce.jl:392 [inlined]
 [11] _mapreduce(f::MLJBase.var"#276#277"{MLJBase.var"#fit_and_extract_on_fold#299"{Vector{Tuple{Vector{Int64}, Vector{Int64}}}, Nothing, Nothing, Int64, Vector{LogLoss{Float64}}, Vector{typeof(predict)}, Bool, Bool, CategoricalVector{Int64, UInt32, Int64, CategoricalValue{Int64, UInt32}, Union{}}, DataFrames.DataFrame}, Machine{MLJDecisionTreeInterface.RandomForestClassifier, true}, Int64, ProgressMeter.Progress}, op::typeof(vcat), #unused#::IndexLinear, 
A::UnitRange{Int64})                                                                       
    @ Base ./reduce.jl:403
 [12] _mapreduce_dim
    @ ./reducedim.jl:318 [inlined]
 [13] #mapreduce#672
    @ ./reducedim.jl:310 [inlined]
 [14] mapreduce
    @ ./reducedim.jl:310 [inlined]
 [15] _evaluate!(func::MLJBase.var"#fit_and_extract_on_fold#299"{Vector{Tuple{Vector{Int64}, Vector{Int64}}}, Nothing, Nothing, Int64, Vector{LogLoss{Float64}}, Vector{typeof(predict)}, Bool, Bool, CategoricalVector{Int64, UInt32, Int64, CategoricalValue{Int64, UInt32}, Union{}}, DataFrames.DataFrame}, mach::Machine{MLJDecisionTreeInterface.RandomForestClassifier, true}, #unused#::CPU1{Nothing}, nfolds::Int64, verbosity::Int64)
    @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/resampling.jl:931
 [16] evaluate!(mach::Machine{MLJDecisionTreeInterface.RandomForestClassifier, true}, resampling::Vector{Tuple{Vector{Int64}, Vector{Int64}}}, weights::Nothing, class_weights::Nothing, rows::Nothing, verbosity::Int64, repeats::Int64, measures::Vector{LogLoss{Float64}}, operations::Vector{typeof(predict)}, acceleration::CPU1{Nothing}, force::Bool)              
    @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/resampling.jl:1126
 [17] evaluate!(::Machine{MLJDecisionTreeInterface.RandomForestClassifier, true}, ::Holdout, ::Nothing, ::Nothing, ::Nothing, ::Int64, ::Int64, ::Vector{LogLoss{Float64}}, ::Vector{typeof(predict)}, ::CPU1{Nothing}, ::Bool)                                                 
    @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/resampling.jl:1193
 [18] fit(::Resampler{Holdout}, ::Int64, ::DataFrames.DataFrame, ::CategoricalVector{Int64, UInt32, Int64, CategoricalValue{Int64, UInt32}, Union{}})                           
    @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/resampling.jl:1337
 [19] fit_only!(mach::Machine{Resampler{Holdout}, false}; rows::Nothing, verbosity::Int64, force::Bool)                                                                                
    @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/machines.jl:531
 [20] #fit!#103
    @ ~/.julia/packages/MLJBase/HZmTU/src/machines.jl:598 [inlined]
 [21] event!(metamodel::MLJDecisionTreeInterface.RandomForestClassifier, resampling_machine::Machine{Resampler{Holdout}, false}, verbosity::Int64, tuning::Grid, history::Nothing, state
::NamedTuple{(:models, :fields, :parameter_scales, :models_delivered), Tuple{Vector{MLJDecisionTreeInterface.RandomForestClassifier}, Vector{Symbol}, Vector{Symbol}, Bool}})
    @ MLJTuning ~/.julia/packages/MLJTuning/efiDR/src/tuned_models.jl:395
 [22] #35
    @ ~/.julia/packages/MLJTuning/efiDR/src/tuned_models.jl:433 [inlined]
 [23] iterate
    @ ./generator.jl:47 [inlined]
 [24] _collect(c::Vector{MLJDecisionTreeInterface.RandomForestClassifier}, itr::Base.Generator{Vector{MLJDecisionTreeInterface.RandomForestClassifier}, MLJTuning.var"#35#36"{Machine{Resampler{Holdout}, false}, Int64, Grid, Nothing, NamedTuple{(:models, :fields, :parameter_scales, :models_delivered), Tuple{Vector{MLJDecisionTreeInterface.RandomForestClassifier}, Vector{Symbol}, Vector{Symbol}, Bool}}, ProgressMeter.Progress}}, #unused#::Base.EltypeUnknown, 
isz::Base.HasShape{1})                                                                     
    @ Base ./array.jl:695
 [25] collect_similar
    @ ./array.jl:606 [inlined]
 [26] map
    @ ./abstractarray.jl:2294 [inlined]
 [27] assemble_events!(metamodels::Vector{MLJDecisionTreeInterface.RandomForestClassifier}, 
resampling_machine::Machine{Resampler{Holdout}, false}, verbosity::Int64, tuning::Grid, history::Nothing, state::NamedTuple{(:models, :fields, :parameter_scales, :models_delivered), Tuple{Vector{MLJDecisionTreeInterface.RandomForestClassifier}, Vector{Symbol}, Vector{Symbol}, Bool}}, acceleration::CPU1{Nothing})
    @ MLJTuning ~/.julia/packages/MLJTuning/efiDR/src/tuned_models.jl:432
 [28] build!(history::Nothing, n::Int64, tuning::Grid, model::MLJDecisionTreeInterface.RandomForestClassifier, model_buffer::Channel{Any}, state::NamedTuple{(:models, :fields, :parameter_scales, :models_delivered), Tuple{Vector{MLJDecisionTreeInterface.RandomForestClassifier}, Vector{Symbol}, Vector{Symbol}, Bool}}, verbosity::Int64, acceleration::CPU1{Nothing}, resampling_machine::Machine{Resampler{Holdout}, false})                                     
    @ MLJTuning ~/.julia/packages/MLJTuning/efiDR/src/tuned_models.jl:625
 [29] fit(::MLJTuning.ProbabilisticTunedModel{Grid, MLJDecisionTreeInterface.RandomForestClassifier}, ::Int64, ::DataFrames.DataFrame, ::CategoricalVector{Int64, UInt32, Int64, CategoricalValue{Int64, UInt32}, Union{}})                           
    @ MLJTuning ~/.julia/packages/MLJTuning/efiDR/src/tuned_models.jl:704
 [30] fit_only!(mach::Machine{MLJTuning.ProbabilisticTunedModel{Grid, MLJDecisionTreeInterface.RandomForestClassifier}, true}; rows::Nothing, verbosity::Int64, force::Bool)
    @ MLJBase ~/.julia/packages/MLJBase/HZmTU/src/machines.jl:531
 [31] #fit!#103
    @ ~/.julia/packages/MLJBase/HZmTU/src/machines.jl:598 [inlined]
 [32] (::MLJTuning.var"#61#62"{Machine{MLJTuning.ProbabilisticTunedModel{Grid, MLJDecisionTreeInterface.RandomForestClassifier}, true}, Nothing, Symbol, Int64, ProgressMeter.Progress})
(rng::Random.MersenneTwister)                                                              
    @ MLJTuning ~/.julia/packages/MLJTuning/efiDR/src/learning_curves.jl:231
 [33] mapreduce_first
    @ ./reduce.jl:392 [inlined]
 [34] _mapreduce(f::MLJTuning.var"#61#62"{Machine{MLJTuning.ProbabilisticTunedModel{Grid, MLJDecisionTreeInterface.RandomForestClassifier}, true}, Nothing, Symbol, Int64, ProgressMeter.Progress}, op::typeof(MLJTuning._collate), #unused#::IndexLinear, A::Vector{Random.MersenneTwister})                                                                   
    @ Base ./reduce.jl:403
 [35] _mapreduce_dim
    @ ./reducedim.jl:318 [inlined]
 [36] #mapreduce#672
    @ ./reducedim.jl:310 [inlined]
 [37] mapreduce
    @ ./reducedim.jl:310 [inlined]
 [38] _tuning_results(rngs::Vector{Random.MersenneTwister}, acceleration::CPU1{Nothing}, tuned::Machine{MLJTuning.ProbabilisticTunedModel{Grid, MLJDecisionTreeInterface.RandomForestClassifier}, true}, rows::Nothing, rng_name::Symbol, verbosity::Int64)
    @ MLJTuning ~/.julia/packages/MLJTuning/efiDR/src/learning_curves.jl:229
 [39] learning_curve(::MLJDecisionTreeInterface.RandomForestClassifier, ::MLJBase.Source, ::
Vararg{MLJBase.Source, N} where N; resolution::Int64, resampling::Holdout, weights::Nothing, measures::Nothing, measure::LogLoss{Float64}, rows::Nothing, operation::Nothing, ranges::Nothing, range::MLJBase.NumericRange{Int64, MLJBase.Bounded, Symbol}, repeats::Int64, acceleration::CPU1{Nothing}, acceleration_grid::CPU1{Nothing}, verbosity::Int64, rngs::Int64, rng_name::Symbol, check_measure::Bool)                                                      
    @ MLJTuning ~/.julia/packages/MLJTuning/efiDR/src/learning_curves.jl:173
 [40] #learning_curve#58
    @ ~/.julia/packages/MLJTuning/efiDR/src/learning_curves.jl:92 [inlined]
 [41] top-level scope
    @ REPL[44]:1

    nested task error: AssertionError: length(ints) == 501
    Stacktrace:
      [1] mt_setfull!(r::Random.MersenneTwister, #unused#::Type{UInt64})
        @ Random /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/RNGs.jl:260
      [2] reserve1
        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/RNGs.jl:291 [inlined]
      [3] mt_pop!
        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/RNGs.jl:296 [inlined]
      [4] rand
        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/RNGs.jl:464 [inlined]
      [5] rand
        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/Random.jl:256 [inlined]
      [6] rand(rng::Random.MersenneTwister, sp::Random.SamplerRangeNDL{UInt64, Int64})
        @ Random /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/generation.jl:332
      [7] rand!
        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/Random.jl:271 [inlined]                              
      [8] rand!(rng::Random.MersenneTwister, A::Vector{Int64}, X::UnitRange{Int64})
        @ Random /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/Random.jl:266
      [9] rand
        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/Random.jl:279 [inlined]
     [10] rand
        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Random/src/Random.jl:282 [inlined]
     [11] macro expansion
        @ ~/.julia/packages/DecisionTree/iWCbW/src/classification/main.jl:224 [inlined]
     [12] (::DecisionTree.var"#62#threadsfor_fun#22"{Random.MersenneTwister, Vector{UInt32}, Matrix{Float64}, Int64, Int64, Int64, Float64, DecisionTree.var"#20#21"{Vector{Float64}}, Vector{Union{DecisionTree.Leaf{UInt32}, DecisionTree.Node{Float64, UInt32}}}, Int64, Int64, UnitRange{Int64}})(onethread::Bool)
        @ DecisionTree ./threadingconstructs.jl:81
     [13] (::DecisionTree.var"#62#threadsfor_fun#22"{Random.MersenneTwister, Vector{UInt32}, Matrix{Float64}, Int64, Int64, Int64, Float64, DecisionTree.var"#20#21"{Vector{Float64}}, Vector{Union{DecisionTree.Leaf{UInt32}, DecisionTree.Node{Float64, UInt32}}}, Int64, Int64, UnitRange{Int64}})()
        @ DecisionTree ./threadingconstructs.jl:48
(MachineLearningInJulia2020) pkg> status
      Status `~/Google Drive/Julia/MLJ/MachineLearningInJulia2020/Project.toml`
  [336ed68f] CSV v0.9.6
  [324d7699] CategoricalArrays v0.10.1
  [ed09eef8] ComputationalResources v0.3.2
  [a93c6f00] DataFrames v1.2.2
  [7806a523] DecisionTree v0.10.11
  [31c24e10] Distributions v0.25.18
  [f6006082] EvoTrees v0.8.4
  [98b081ad] Literate v2.9.3
  [add582a8] MLJ v0.16.9
  [a7f614a8] MLJBase v0.18.23
  [d354fa79] MLJClusteringInterface v0.1.4
  [094fc8d1] MLJFlux v0.2.5
  [6ee0df7b] MLJLinearModels v0.5.6
  [d491faf4] MLJModels v0.14.12
  [1b6a4a23] MLJMultivariateStatsInterface v0.2.2
  [5ae90465] MLJScikitLearnInterface v0.1.10
  [b8a86587] NearestNeighbors v0.4.9
  [a03496cd] PlotlyBase v0.8.18
  [91a5bcdd] Plots v1.22.4
  [321657f4] ScientificTypes v2.3.0
  [2913bbd2] StatsBase v0.33.10
  [bd369af6] Tables v1.6.0
  [b8865327] UnicodePlots v2.4.6
  [9a3f8284] Random

Julia 1.6.3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Julia example in the issue and read MLJTuning's learning_curves.jl, especially the learning_curve and _tuning_results paths shown in the stack trace. Trace the nested TaskFailedException through the DecisionTree and MLJBase calls; done means the example completes without the length(ints) == 501 assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.