Skip to content
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

DecisionTreeRegressor fails to predict #193

Closed
juliohm opened this issue Jul 30, 2019 · 3 comments
Closed

DecisionTreeRegressor fails to predict #193

juliohm opened this issue Jul 30, 2019 · 3 comments

Comments

@juliohm
Copy link
Contributor

juliohm commented Jul 30, 2019

Describe the bug
The DecisionTreeRegressor fails to make predictions.

To Reproduce

using MLJ
@load DecisionTreeRegressor

X = rand(100,2)
y = rand(100)

model = DecisionTreeRegressor()

theta = MLJ.fit(model, 0, X, y)
yhat = MLJ.predict(model, theta, X)

ERROR: MethodError: no method matching apply_tree(::Tuple{DecisionTree.Node{Float64,Float64},Nothing,Nothing}, ::Array{Float64,2})
Closest candidates are:
apply_tree(::Union{Leaf{T}, Node{S,T}}, ::Array{S,2}) where {S, T} at /home/juliohm/.julia/packages/DecisionTree/nfB7O/src/classification/main.jl:149
Stacktrace:
[1] predict(::DecisionTreeRegressor, ::Tuple{DecisionTree.Node{Float64,Float64},Nothing,Nothing}, ::Array{Float64,2}) at /home/juliohm/.julia/packages/MLJModels/GgPjI/src/DecisionTree.jl:268
[2] top-level scope at none:0

Expected behavior
I would expect it to work.

Additional context
No additional context.

Versions

Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 2

MLJ v0.2.5

@juliohm
Copy link
Contributor Author

juliohm commented Jul 30, 2019

@ayush-1506 @ayush1999 helped with the issue over slack. The fit method returns a tuple (fitresult, report, cache). So we need to call MLJ.predict(model, theta[1], X, y).

@juliohm juliohm closed this as completed Jul 30, 2019
@ayush-1506
Copy link
Collaborator

It's actually (fitresult, cache, report). (Though it doesn't matter in this case.)

@ablaom
Copy link
Member

ablaom commented Jul 30, 2019

X cannot be a matrix. it must be a table supporting the Tables.jl interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants