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

hierarchical iterations #52

Merged
merged 2 commits into from
Oct 16, 2023
Merged

hierarchical iterations #52

merged 2 commits into from
Oct 16, 2023

Conversation

FelixWick
Copy link
Collaborator

In the first three iterations of the training, only selected feature groups are used, i.e., all other feature groups are excluded. From the fourth iteration onwards, all feature groups are used. The idea of such hierarchical iterations is to support the modeling of hierarchical or causal effects (e.g., mitigate confounding).

@FelixWick FelixWick self-assigned this Oct 9, 2023
@FelixWick FelixWick linked an issue Oct 9, 2023 that may be closed by this pull request
idea of such hierarchical iterations is to support the modeling of
hierarchical or causal effects (e.g., mitigate confounding).

If this argument is omitted, such no hierarchical iterations are run.
Copy link
Collaborator

Choose a reason for hiding this comment

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

A rather pedantic comment. This argument cannot be omitted (in the strict sense that it is not defined) because in the __init__ of CyclicBoostingBase, hierarchical_feature_groups is set to None and not =Optional[Union[str, int, Tuple, FeatureID]]. This means that hierarchical_feature_groups = Nonehas to be passed to the child classes ofCyclicBoostingBase`.

TL:DR, omitted makes it sound like this argument is Optional but is not. It is mandatory but has a default None. Perhaps "If this argument is not explicitly set, such no hierarchical iterations are run." is better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will change it, thanks.

@@ -887,8 +920,11 @@ def _check_stop_criteria(self, iterations: int, convergence_parameters: Converge
"analysis plots."
)

if iterations <= 3 and self.hierarchical_feature_groups is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather ignorant question, why is 3 the magical number of iterations here? Is it a good balance between two criteria?
If this is in fact a parameter one can tune, than 3 should be replaced by a constant, say "TRAINING_ITERATIONS_HIER_FEATURES" and the docstring above has to be adjusted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think 3 is a good value, but a parameter with default 3 might be better, yes. I will change it.

yhat = CB_est.predict(X.copy())

mad = np.nanmean(np.abs(y - yhat))
np.testing.assert_almost_equal(mad, 1.699, 3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can I read this slight improvement in MAD (compared to the previous test) as a result of feature hierarchization, or is the difference too small to attribute it to that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The improvement is small, yes, but I think it is thanks to the hierarchical training. Here it helps to describe the strong confounding of the price due to different products. I couldn't find a better example in our integration test.

@FelixWick FelixWick merged commit 550760c into main Oct 16, 2023
8 checks passed
@FelixWick FelixWick deleted the hierarchical_iterations branch October 16, 2023 20:05
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.

enable hierarchical groups in optimization
2 participants