-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TLDR Example Fails #204
Comments
julia> trees(bst)
10-element Vector{XGBoost.Node}:
Error showing value of type Vector{XGBoost.Node}:
ERROR: MethodError: no method matching print_tree(::typeof(Term.Trees.print_node), ::typeof(Term.Trees.print_key), ::IOBuffer, ::OrderedCollections.OrderedDict{…}; charset::AbstractTrees.TreeCharSet, printkeys::Bool, prefix::String, title_style::String)
Closest candidates are:
print_tree(::Function, ::Function, ::IO, ::Any; maxdepth, indicate_truncation, charset, printkeys, depth, prefix, printnode_kw) got unsupported keyword argument "title_style"
@ AbstractTrees ~/.julia/packages/AbstractTrees/Ftf8W/src/printing.jl:194
print_tree(::Function, ::IO, ::Any; kw...)
@ AbstractTrees ~/.julia/packages/AbstractTrees/Ftf8W/src/printing.jl:276
print_tree(::Any; kw...)
@ AbstractTrees ~/.julia/packages/AbstractTrees/Ftf8W/src/printing.jl:278
...
Stacktrace:
[1] kwerr(::@NamedTuple{…}, ::Function, ::Function, ::Function, ::IOBuffer, ::OrderedCollections.OrderedDict{…})
@ Base ./error.jl:165
[2] (::Term.Trees.var"#4#5"{AbstractTrees.TreeCharSet, Bool, typeof(Term.Trees.print_node), typeof(Term.Trees.print_key), String, @Kwargs{title_style::String}})(io::IOBuffer)
@ Term.Trees ~/.julia/packages/Term/u4VQK/src/trees.jl:147
[3] sprint(::Function; context::Nothing, sizehint::Int64)
@ Base ./strings/io.jl:114
[4] sprint
@ ./strings/io.jl:107 [inlined]
[5] Term.Trees.Tree(tree::OrderedCollections.OrderedDict{…}; guides::Symbol, theme::Term.Theme, printkeys::Bool, print_node_function::Function, print_key_function::Function, title::String, prefix::String, kwargs::@Kwargs{…})
@ Term.Trees ~/.julia/packages/Term/u4VQK/src/trees.jl:146
[6] Term.Trees.Tree(node::XGBoost.Node; title::String, title_style::String, kwargs::@Kwargs{})
@ XGBoostTermExt ~/.julia/packages/XGBoost/nqMqQ/ext/XGBoostTermExt.jl:71
[7] Tree
@ ~/.julia/packages/XGBoost/nqMqQ/ext/XGBoostTermExt.jl:65 [inlined]
[8] Panel(node::XGBoost.Node; width::Int64, kw::@Kwargs{})
@ XGBoostTermExt ~/.julia/packages/XGBoost/nqMqQ/ext/XGBoostTermExt.jl:81
[9] Panel
@ ~/.julia/packages/XGBoost/nqMqQ/ext/XGBoostTermExt.jl:74 [inlined]
[10] show
@ ~/.julia/packages/XGBoost/nqMqQ/ext/XGBoostTermExt.jl:93 [inlined]
[11] show(io::IOContext{IOBuffer}, m::String, x::XGBoost.Node)
@ Base.Multimedia ./multimedia.jl:123
[12] sprint(::Function, ::String, ::Vararg{Any}; context::IOContext{Base.TTY}, sizehint::Int64)
@ Base ./strings/io.jl:112
[13] sprint
@ ./strings/io.jl:107 [inlined]
[14] print_matrix_row(io::IOContext{Base.TTY}, X::AbstractVecOrMat, A::Vector{Tuple{Int64, Int64}}, i::Int64, cols::Vector{Int64}, sep::String, idxlast::Int64)
@ Base ./arrayshow.jl:108
[15] _print_matrix(io::IOContext{…}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{…}, colsA::UnitRange{…})
@ Base ./arrayshow.jl:213
[16] print_matrix(io::IOContext{Base.TTY}, X::Vector{XGBoost.Node}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64)
@ Base ./arrayshow.jl:171
[17] print_matrix
@ ./arrayshow.jl:171 [inlined]
[18] print_array
@ ./arrayshow.jl:358 [inlined]
[19] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, X::Vector{XGBoost.Node})
@ Base ./arrayshow.jl:399
[20] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:273
[21] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:569
[22] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:259
[23] display
@ ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:278 [inlined]
[24] display(x::Any)
@ Base.Multimedia ./multimedia.jl:340
[25] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:0
[26] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:284
[27] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:569
[28] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:282
[29] (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:911
[30] #invokelatest#2
@ ./essentials.jl:892 [inlined]
[31] invokelatest
@ ./essentials.jl:889 [inlined]
[32] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
@ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2656
[33] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1312
[34] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
@ REPL ~/.julia/juliaup/julia-1.10.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:386
Some type information was truncated. Use `show(err)` to see complete types. |
Looks like failure from Term.jl dependencyNote that using DataFrames, XGBoost
# ...etc
# expected
julia> importancereport(bst)
ERROR: MethodError: no method matching importancereport(::Booster)
julia> importance(bst)
# OrderedCollections.OrderedDict{String, Vector{Float32}} with 2 entries:
# "a" => [0.709936]
# "b" => [0.644888]
julia> trees(bst)
# 10-element Vector{XGBoost.Node}:
# XGBoost.Node(split_feature=b)
# XGBoost.Node(split_feature=b)
# XGBoost.Node(split_feature=b)
# XGBoost.Node(split_feature=b)
# XGBoost.Node(split_feature=b)
# XGBoost.Node(split_feature=b)
# XGBoost.Node(split_feature=b)
# XGBoost.Node(split_feature=a)
# XGBoost.Node(split_feature=b)
# XGBoost.Node(split_feature=a)
julia> for i in propertynames(ts[1])
@printf "%-20s %12s\n" i getproperty(ts[1], i)
end
id 0
depth 0
split b
split_condition 1.22669697
yes 1
no 2
nmissing 2
gain 4.72399569
cover 100.0
leaf nothing
children XGBoost.Node[XGBoost.Node(split_feature=a), XGBoost.Node(split_feature=b)] |
It really dinged my confidence when the Hello World for this package failed, and I messed around with versions trying to find an environment where it works -- wasted time. I suggest either:
Or maybe someone experienced can see an easy fix! Let me know I'm happy to PR either of the above. |
This is either an error in Term.jl in that it's passing keyword arguments to We probably should remove the term tree visualizations as that doesn't really seem like something we'll want to maintain and it was perhaps a bit overenthusiastic to put it there in the first place. |
Makes sense, something fragile about this dependency reminiscent of a 🔥 julia discourse not long ago. Is Visualization features don't need to be in scope, although the explainability of tree models is one of the big benefits. Package users can manage that outside of this package, maybe just a good how-to example in the docs is a good tradeoff. I'm eager to help on this, esp. having been useless in helping on Parquet2.jl. I expect to be using this package a lot. Edit: a little guidance on general direction to go and I'd be able to make a PR |
This wrapper defines a If you want to remove all of the Other solutions are also welcome, but yeah I think in retrospect adding this kind of fluff to this simple wrapper package was not the greatest idea. There is also the fraught issue of whether it would be a breaking change. I always think display stuff should not be considered part of the API and therefore not breaking, but we don't make it clear, it might have to be, so I guess it just is what it is. |
I vote for non-breaking. |
Sorry I've been reading through the package and just learned about package extensions. Tell me if I have this right:
So I'd say
First thing I'd like to do is add a hint to the MethodError for instancereport following this example, that would have helped me a lot as a first time user. |
I think you have the first part of it right, but not the cause of the problem. The method error happens because Term.jl is passing the keyword arguments to its constructors to Of course it's possible to fix this but I'm not even sure what the intended behavior is, so I'm not sure whether this is a case of Term.jl misusing That said, whether you are inclined to fix this issue and restore the original behavior, or just remove the Term display for tree nodes, I'd vote to merge either case. |
I'm new to all the packages referenced here, sorry I can't diagnose.
Environment:
I tried out the TLDR example in the docs:
So far so good
The text was updated successfully, but these errors were encountered: