Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/MLJDecisionTreeInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ end

function get_encoding(classes_seen)
a_cat_element = classes_seen[1]
return Dict(c => MMI.int(c) for c in MMI.classes(a_cat_element))
return Dict(MMI.int(c) => c for c in MMI.classes(a_cat_element))
end

MMI.fitted_params(::DecisionTreeClassifier, fitresult) =
Expand Down Expand Up @@ -538,9 +538,9 @@ To interpret the internal class labelling:
```
julia> fitted_params(mach).encoding
Dict{CategoricalArrays.CategoricalValue{String, UInt32}, UInt32} with 3 entries:
"virginica" => 0x00000003
"setosa" => 0x00000001
"versicolor" => 0x00000002
0x00000003 => "virginica"
0x00000001 => "setosa"
0x00000002 => "versicolor"
```

See also
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ yyhat = predict_mode(baretree, fitresult, MLJBase.selectrows(X, 1:3))
fp = fitted_params(baretree, fitresult)
@test Set([:tree, :encoding, :features]) == Set(keys(fp))
@test fp.features == report.features
enc = fp.encoding
@test Set(values(enc)) == Set(["virginica", "setosa", "versicolor"])
@test enc[MLJBase.int(y[end])] == "virginica"

using Random: seed!
seed!(0)
Expand Down