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

Global Split Criteria for Decision Trees #1612

Open
danielnowakassis opened this issue Sep 9, 2024 · 0 comments
Open

Global Split Criteria for Decision Trees #1612

danielnowakassis opened this issue Sep 9, 2024 · 0 comments

Comments

@danielnowakassis
Copy link
Contributor

In #1610, we noted that at each time a split attempt occurs in Decision Trees, an instance of the Split Criterion Object is created.

This is not necessary and a globally instantiated Split Criterion Object would enhance the memory usage of LAST.

In river/tree/nodes/last_nodes.py

# change this in future PR's by acessing the tree parameter in the leaf
self.split_criterion = (
    split_criterion  # if None, the change detector will have binary inputs
)
def learn_one(self, x, y, *, w=1, tree=None):
        self.update_stats(y, w)
        if self.is_active():
            if self.split_criterion is None:
                mc_pred = self.prediction(x)
                detector_input = max(mc_pred, key=mc_pred.get) != y
                self.change_detector.update(detector_input)
            else:
                detector_input = self.split_criterion.current_merit(self.stats)
                self.change_detector.update(detector_input)
            self.update_splitters(x, y, w, tree.nominal_attributes)

would become :

def learn_one(self, x, y, *, w=1, tree=None):
        self.update_stats(y, w)
        if self.is_active():
            if tree.track_error:
                mc_pred = self.prediction(x)
                detector_input = max(mc_pred, key=mc_pred.get) != y
                self.change_detector.update(detector_input)
            else:
                detector_input = tree.current_merit(self.stats)
                self.change_detector.update(detector_input)
            self.update_splitters(x, y, w, tree.nominal_attributes)
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

1 participant