-
Notifications
You must be signed in to change notification settings - Fork 752
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
Add new samplers #2913
Add new samplers #2913
Conversation
src/gluonts/transform/sampler.py
Outdated
@@ -142,6 +162,37 @@ def __call__(self, ts: np.ndarray) -> np.ndarray: | |||
return indices + a | |||
|
|||
|
|||
class ExpectedNumInstanceWithMinSampler(ExpectedNumInstanceSampler): |
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 see two ways to escape the naming dilemma here:
- Make
min_instances: int = 0
(note the default0
) an attribute ofExpectedNumInstanceSampler
and add the logic directly there. Then there's no name to be invented. However, strictly speaking when one setsmin_instances > 0
then this is not really samplingnum_instances
on average. - Make this logic a wrapper around some other sampler:
sampler = AtLeast(1, ExpectedNumInstanceSampler)
. The logic is factored a bit better maybe that way, just not as straightforward to instantiate.
Again, no strong opinions, it's just that this names is now a mouthful. @jaheba to the rescue.
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.
@abdulfatir let's go for option 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.
Done.
I think we can just extend the current class with |
|
||
Parameters | ||
---------- | ||
N |
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.
Why is this uppercase?
Issue #, if available:
Description of changes:
This PR adds two new samplers:
NInstanceSampler
andExpectedNumInstanceWithMinSampler
.NInstanceSampler
: sample exactlyN
time points per time series.ExpectedNumInstanceWithMinSampler
: same asExpectedNumInstanceSampler
but ensures at a minimum number of time points are sampled per time series.Thanks to @lostella for code and suggestions.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Please tag this pr with at least one of these labels to make our release process faster: BREAKING, new feature, bug fix, other change, dev setup