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

1st attempt to implement AbstractTrees-interface #34

Merged
merged 1 commit into from
Aug 4, 2022

Conversation

roland-KA
Copy link
Contributor

@roland-KA roland-KA commented Aug 3, 2022

Hi @sylvaticus, you are right. As you mentioned in JuliaAI/DecisionTree.jl#147, it's probably the best way to solve my problems by creating a PR on a separate branch, which I've done now.

I've added (a quick & dirty) implementation of the AbstractTrees-interface in the file abstract_trees.jl in the Trees-submodule.

As this file needs AbstractTrees.jl, I've added a using AbstractTrees to Trees.jl (as well as an include("abstract_trees.jl")).

With the introduction of this interface, BetaML needs to export three new identifiers: InfoNode, InfoLeaf, wrap. I've placed the corresponding export-clause in Api.jl, which seemed to me the right place.

But here the problems start. Running BetaML.jl with these changes just leads to the following warnings:

WARNING: could not import Api.InfoLeaf into Utils
WARNING: could not import Api.InfoNode into Utils
WARNING: could not import Api.wrap into Utils

WARNING: could not import Api.InfoLeaf into Stats
WARNING: could not import Api.InfoNode into Stats

WARNING: could not import Api.InfoLeaf into Nn
WARNING: could not import Api.InfoNode into Nn
WARNING: could not import Api.wrap into Nn
WARNING: could not import Api.InfoLeaf into Perceptron
WARNING: could not import Api.InfoNode into Perceptron
WARNING: could not import Api.wrap into Perceptron
WARNING: could not import Api.InfoLeaf into Trees
WARNING: could not import Api.InfoNode into Trees
WARNING: could not import Api.wrap into Trees
WARNING: could not import Api.InfoLeaf into Clustering
WARNING: could not import Api.InfoNode into Clustering
WARNING: could not import Api.wrap into Clustering
WARNING: could not import Api.InfoLeaf into Imputation
WARNING: could not import Api.InfoNode into Imputation
WARNING: could not import Api.wrap into Imputation
WARNING: could not import Api.InfoLeaf into BetaML
WARNING: could not import Api.InfoNode into BetaML
WARNING: could not import Api.wrap into BetaML

Can you tell me, what would be the correct way to make these changes?

@sylvaticus
Copy link
Owner

Thank you very much.
I'll have a look on thiis, but just give me a few days .. I'm on holidays in another coutry with limited internet acces and kids to overlook...

@sylvaticus sylvaticus merged commit dbf4d47 into sylvaticus:master Aug 4, 2022
@sylvaticus
Copy link
Owner

Hello, after some changes I have merged this into master.
I have moved everything back to the (renamed) AbstractTrees.jl file, as this is specific to DecisionTrees, not something "generic" to most models (what I put in API).

I am not sure this is intended to work as you wish (I haven't followed the whole thread )

I have added to /test/Trees.test.jl the following lines:

using AbstractTrees
import AbstractTrees: printnode
wrappedNode = wrap(myTree)
printnode(stdout,wrappedNode)

This result in :

DecisionNode{Float64}(Is col 2 >= 3.0 ?, DecisionNode{String}(Is col 1 == Yellow ?, Leaf{String}(Dict("Lemon" => 0.5, "Apple" => 0.5), 3), Leaf{String}(Dict("Apple" => 1.0), 3), 2, 0.6666666666666666), Leaf{String}(Dict("Grape" => 1.0), 2), 1, 0.6)
Is col 2 >= 3.0 ?Is col 1 == Yellow ?
DecisionNode{Float64}(Is col 2 >= 3.0 ?, DecisionNode{String}(Is col 1 == Yellow ?, Leaf{String}(Dict("Lemon" => 0.5, "Apple" => 0.5), 3), Leaf{String}(Dict("Apple" => 1.0), 3), 2, 0.6666666666666666), Leaf{String}(Dict("Grape" => 1.0), 2), 1, 0.6)

I guess this depends on my already having defined a function to show the individual question... is this what you need to get the node graphically displayed on plots ?

Could you please add more testing or adjustments based on current BetaML Master ? I admit I am not a GIT guru, so I am not sure how to then rebase stuff or make advanced stuff with git/github...

@roland-KA roland-KA deleted the abstract-tree branch August 4, 2022 18:03
@roland-KA
Copy link
Contributor Author

Hi @sylvaticus thank you very much for your help! So the first obstacles have been overcome 👍😊.

In the next step I will add test code as well as some documentation and perhaps the implementation needs also some refinement. As soon as I'm ready, you will hear from me with another PR.

but just give me a few days .. I'm on holidays
And then: No hurry, enjoy your holiday! 😎

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

Successfully merging this pull request may close these issues.

2 participants