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

Allow parallel prediction for UpliftRandomForestClassifier #477

Conversation

heiderich
Copy link
Contributor

Proposed changes

Previous to this PR UpliftRandomForestClassifier was using joblib to fit the UpliftTreeClassifiers in parallel if n_jobs was not equal to 1. With this PR predictions are also computed in parallel (one job per tree).

Types of changes

What types of changes does your code introduce to CausalML?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

@jeongyoonlee jeongyoonlee self-requested a review February 14, 2022 15:09
@jeongyoonlee jeongyoonlee added the enhancement New feature or request label Feb 14, 2022
Copy link
Collaborator

@jeongyoonlee jeongyoonlee left a comment

Choose a reason for hiding this comment

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

Thanks @heiderich! Looks good to me. I left one minor change request.

causalml/inference/tree/uplift.pyx Outdated Show resolved Hide resolved
computation for UpliftRandomForestClassifier
of UpliftRandomForestClassifier
of UpliftRandomForestClassifier. It is passed as `prefer`
to joblib.Parallel in the `fit` and `predict` methods.
@heiderich heiderich force-pushed the parallel_predict_UpliftRandomForestClassifier branch from e1ba553 to b84f114 Compare February 14, 2022 18:38
@jeongyoonlee jeongyoonlee self-requested a review February 14, 2022 18:47
Copy link
Collaborator

@jeongyoonlee jeongyoonlee left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@@ -1256,7 +1260,8 @@ class UpliftRandomForestClassifier:
n_reg=10,
evaluationFunction='KL',
normalization=True,
n_jobs=-1):
n_jobs=-1,
joblib_prefer: str = "threads"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: We're going to use black as a formatter as discussed in #474. You can use it integrated in your IDE or run its command line tool to ensure that the code style follows PEP-8. e.g. no white space around = when used in input arguments.

Since we already have a separate PR, you don't need to update the style here.

@jeongyoonlee jeongyoonlee merged commit 92767c3 into uber:master Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants