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

DecisionTreeFactor prune method #1151

Merged
merged 3 commits into from
Mar 27, 2022

Conversation

varunagrawal
Copy link
Collaborator

This PR adds a new prune method to DecisionTreeFactor which will allow for managing exponential growth.

Given a DecisionTreeFactor

DecisionTreeFactor:
 f[ (1,2), (2,2), (3,2), ]
 Choice(3)
 0 Choice(2)
 0 0 Choice(1)
 0 0 0 Leaf    1
 0 0 1 Leaf    2
 0 1 Choice(1)
 0 1 0 Leaf    3
 0 1 1 Leaf    4
 1 Choice(2)
 1 0 Choice(1)
 1 0 0 Leaf    5
 1 0 1 Leaf    6
 1 1 Choice(1)
 1 1 0 Leaf    7
 1 1 1 Leaf    8

if we set maxNrLeaves to 5, which means only keep the top 5 leaves, we get

DecisionTreeFactor:
 f[ (1,2), (2,2), (3,2), ]
 Choice(3)
 0 Choice(2)
 0 0 Leaf    0
 0 1 Choice(1)
 0 1 0 Leaf    0
 0 1 1 Leaf    4
 1 Choice(2)
 1 0 Choice(1)
 1 0 0 Leaf    5
 1 0 1 Leaf    6
 1 1 Choice(1)
 1 1 0 Leaf    7
 1 1 1 Leaf    8

as expected.

Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

gtsam/discrete/DecisionTreeFactor.cpp Outdated Show resolved Hide resolved
gtsam/discrete/DecisionTreeFactor.cpp Outdated Show resolved Hide resolved
@varunagrawal
Copy link
Collaborator Author

Done and done

@varunagrawal varunagrawal merged commit 0850e89 into develop Mar 27, 2022
@varunagrawal varunagrawal deleted the feature/decision-tree-factor-prune branch March 27, 2022 20:46
BoRueiHong pushed a commit to BoRueiHong/gtsam that referenced this pull request Mar 30, 2022
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