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

feat: add Delta Method Analysis #208

Merged
merged 16 commits into from
Dec 17, 2024
Merged

Conversation

LGonzalezGomez
Copy link
Collaborator

This PR adds Delta Method Analysis. It works with PowerAnalysis pipelines out-of-the-box.
Also added a couple of unit tests to ensure it is working appropiately.

It still needs to be hooked up with the Inference pipeline. Expected to do it at a later stage to split the PR.

@LGonzalezGomez LGonzalezGomez marked this pull request as ready for review December 15, 2024 18:37
Copy link
Owner

@david26694 david26694 left a comment

Choose a reason for hiding this comment

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

lgtm but suggesting a few minor changes. Also bump the library via the toml, please :)

cluster_experiments/power_config.py Show resolved Hide resolved
cluster_experiments/experiment_analysis.py Show resolved Hide resolved
cluster_experiments/experiment_analysis.py Outdated Show resolved Hide resolved
@@ -254,6 +255,7 @@ def _raise_error_if_missing(self, attr, other_attr):
"ttest_clustered": TTestClusteredAnalysis,
"paired_ttest_clustered": PairedTTestClusteredAnalysis,
"mlm": MLMExperimentAnalysis,
"delta": DeltaMethodAnalysis,
Copy link
Owner

Choose a reason for hiding this comment

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

also, you're adding it here but not adding the scale parameter in here. I think we need to add it if we want to init via config. I would also test init via config, I think it's missing

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 am not sure what you mean here. I get that it might be tricky to know that you have to pass an additional parameter or that the "scale" column has to appear somewhere. Is this what you are refering to?
If that is the case, do you have any recommendation on how to go around this? I am not sure I understand how to do it properly...

Copy link
Owner

Choose a reason for hiding this comment

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

It needs to work like this:

config = {
    "analysis": "delta",
    "perturbator": "constant",
    "splitter": "non_clustered",
    "n_simulations": 50,
    "scale_col": "y",
    "target_col": "x"
}
pw = PowerAnalysis.from_dict(config)
power = pw.power_analysis(df, average_effect=0.1)

I think we need to pass the scale_col in the from_config. Please have a read at the from_config in PowerAnalysis, ExperimentAnalysis, etc and if you don't know how it's working let me know

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was pretty clear, thanks!
I think that now it should be working. I had to do some changes and raise a couple of additional errors to save guard.
When time allows, could you check again and give more feedback?
Thanks!

README.md Outdated Show resolved Hide resolved
tests/analysis/test_analysis.py Show resolved Hide resolved
tests/analysis/test_analysis.py Show resolved Hide resolved
@david26694
Copy link
Owner

Also, create issues for:

  • Inference pipeline
  • Variance reudction

Copy link
Owner

@david26694 david26694 left a comment

Choose a reason for hiding this comment

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

One last thing and we can merge, can you add a test where you create a PowerAnalysis with delta from config?

@LGonzalezGomez LGonzalezGomez merged commit a669675 into main Dec 17, 2024
4 checks passed
@LGonzalezGomez LGonzalezGomez deleted the 142-vanilla-delta-method branch December 17, 2024 08:59
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