-
Notifications
You must be signed in to change notification settings - Fork 4
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
Temporal shenanigans #286
Temporal shenanigans #286
Conversation
🦙 MegaLinter status:
|
Descriptor | Linter | Files | Fixed | Errors | Elapsed time |
---|---|---|---|---|---|
black | 30 | 1 | 1.03s | ||
✅ PYTHON | pylint | 30 | 0 | 4.71s |
See detailed report in MegaLinter reports
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #286 +/- ##
==========================================
- Coverage 95.62% 95.55% -0.07%
==========================================
Files 22 23 +1
Lines 1530 1666 +136
==========================================
+ Hits 1463 1592 +129
- Misses 67 74 +7
Continue to review full report in Codecov by Sentry.
|
…alTestingFramework into temporal-shenanigans
…alTestingFramework into temporal-shenanigans
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmafoster1 Looks good so far. Seems like a really seamless integration. I'm currently not on my laptop so I'll do further tests later this evening / tomorrow.
Also, it might be worth requesting a review from @christopher-wild if he has some time.
def total_time(self): | ||
""" | ||
Calculate the total duration of the treatment strategy. | ||
""" | ||
return (len(self.capabilities) + 1) * self.timesteps_per_intervention |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmafoster1 Out of curiosity, why is the total time defined as (n+1)*dt
instead of n*dt
? Do you assume the treatment strategy starts at t=dt
instead of t=0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@f-allian, yes exactly. This is slightly geared towards the water case study, where there is a grace period of dt before the first intervention takes place, and another period of dt after the last intervention before we can observe the final outcome. A slightly more general solution might be to have an extra grace_period
parameter and then have the total time be len(capabilities) * timesteps_per_intervention + grace_period
, but I'll keep it as it is for now.
|
||
def test_repr(self): | ||
cap = Capability("v", 1, 0, 1) | ||
self.assertEqual(str(cap), "(v, 1, 0-1)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmafoster1 Should this be "(v, 1, 0, 1)"
instead of "(v, 1, 0-1)"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the 0-1
notation for stringing capabilities would be easier to read, then you know that the last element represents the duration of the capability. Otherwise, I'd be constantly forgetting what the last three elements represented!
@@ -77,7 +79,7 @@ class TestLogisticRegressionEstimator(unittest.TestCase): | |||
|
|||
@classmethod | |||
def setUpClass(cls) -> None: | |||
cls.scarf_df = pd.read_csv("tests/data/scarf_data.csv") | |||
cls.scarf_df = pd.read_csv("tests/resources/data/scarf_data.csv") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmafoster1 Why did this change to test/resources/data
? Do we have other subfolders in tests/resources
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a folder called tests/data
and one called tests/resources/data
, both containing test data, so I thought I'd condense everything into one folder.
Thanks @f-allian. @christopher-wild, I've requested a review, but please don't feel obliged if you are too busy |
try: | ||
results.append(self.test_case.execute_test(estimator, None)) | ||
except LinAlgError: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would logging any warnings here be helpful? Is it okay if it fails to append results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added in the warnings, but it's very OK to continue. What's happening here is that we're resampling the data and recalculating the estimate. If you don't have a lot of data, some of those samples may fail to converge, or fail in other ways to produce an estimate. This indicates that you don't have enough data, so I've now added "number of successes" as a third dimension to causal test adequacy.
If everyone's happy with this, please could one of you approve it so I can get it merged in? |
Ah sorry missed this! You can click re-request review next to ours name in the top right to send a notification if we do take too long |
Thanks @christopher-wild. Doing that feels very passive aggressive, though! 🙃 |
Haha I get what you mean but it's what it's there for 😁! |
Added in temporal causal estimation with treatment sequences.