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: 44 sklearn compatible interface (with fkiraly) #66

Merged
merged 50 commits into from
Feb 16, 2024

Conversation

astrogilda
Copy link
Owner

@astrogilda astrogilda commented Feb 7, 2024

Implements #44


Update by @fkiraly:

  • merges configs and classes for public interface - configs are still used internally, but not exposed to hte user
  • makes all kwargs parameters explicit
  • completes docstrings with a description of all valid kwargs

@astrogilda astrogilda self-assigned this Feb 7, 2024
@astrogilda astrogilda linked an issue Feb 7, 2024 that may be closed by this pull request
3 tasks
@fkiraly
Copy link
Collaborator

fkiraly commented Feb 7, 2024

Tests are failing because you always need to import the config classes in base_bootstrap.py, but you only import them for type checking. (the imports are under an "if" condition)

Are you running tests locally?

@astrogilda
Copy link
Owner Author

astrogilda commented Feb 7, 2024 via email

@fkiraly
Copy link
Collaborator

fkiraly commented Feb 7, 2024

well, they tested them alright

anyway, more tests are passing now, and the properties no longer seem a problem!

So we are now properly running the tests!
Some findings:

  • BaseTimeSeriesBootstrap should super.__init__ (and every class with an __init__ should)

@fkiraly
Copy link
Collaborator

fkiraly commented Feb 7, 2024

question: do we want to allow __init__ kwargs? If yes, we have to override the standard tests. It is safer to remove kwargs in class constructors, but it will probably not cause too many problems if we leave them.

on the other hand, adding args could keep downwards compatibility:

if isinstance(args[0], TimeSeriesBootstrapConfig):
    self.set_params(**args[0].get_params())

but this is maybe complicating it too much?

@astrogilda
Copy link
Owner Author

astrogilda commented Feb 7, 2024 via email

@fkiraly
Copy link
Collaborator

fkiraly commented Feb 7, 2024

overriding test_constructor by inheritance in TestAllBootstraps.

It's a larger test, so I'd feel a bit uneasy about it, unless we catch only that exception specifically.

@astrogilda
Copy link
Owner Author

astrogilda commented Feb 7, 2024 via email

@fkiraly
Copy link
Collaborator

fkiraly commented Feb 7, 2024

Okay, I can take a look.

I'd say, let's keep with the plan for now?

@astrogilda
Copy link
Owner Author

astrogilda commented Feb 7, 2024 via email

@fkiraly
Copy link
Collaborator

fkiraly commented Feb 7, 2024

I thought you said if one wants to
retain kwargs then the tests need to be changed?

Yes, but that wasn't your ticket - so to avoid clashing PR, I'm happy to make the change in tests (if we decide so), and you continue working on the API change?
The new tests ought to change in the new test PR anyway.

My confusion comes from you saying

Okay, I can take a look.

which seems like you want to work on the test classes?

@astrogilda
Copy link
Owner Author

astrogilda commented Feb 7, 2024 via email

@fkiraly fkiraly changed the title 44 sklearn compatible interface feat: 44 sklearn compatible interface Feb 15, 2024
@fkiraly fkiraly added the enhancement New feature or request label Feb 15, 2024
@fkiraly
Copy link
Collaborator

fkiraly commented Feb 15, 2024

really strange sporadic errors on specific os-version combinations. The association with the os-version combination seems stable.

I would suspect this an actual error rather than one introduced in the interface rework, but of course it could be the latter to.

@fkiraly
Copy link
Collaborator

fkiraly commented Feb 15, 2024

MRE for the failure:

import numpy as np
from tsbootstrap.block_bootstrap import BaseBlockBootstrap

bootstrap_type = "stationary"
n_bootstraps=1
rng=None
X=np.array([[0., 0.],
       [0., 0.],
       [0., 0.],
       [0., 0.],
       [0., 0.],
       [0., 0.],
       [0., 0.],
       [0., 0.],
       [0., 0.]])

block_length = np.random.randint(1, int(0.8 * X.shape[0]) - 1)
bootstrap = BaseBlockBootstrap(
    bootstrap_type=bootstrap_type,
    block_length=block_length,
    n_bootstraps=n_bootstraps,
    rng=rng,
)

list(bootstrap.bootstrap(X))

@fkiraly
Copy link
Collaborator

fkiraly commented Feb 15, 2024

Is this maybe a masked bug on main? The code on main does not seem to enter BlockGenerator, while the code on this branch does.

@fkiraly fkiraly changed the title feat: 44 sklearn compatible interface feat: 44 sklearn compatible interface (with fkiraly) Feb 16, 2024
@fkiraly fkiraly merged commit cf83d83 into main Feb 16, 2024
34 checks passed
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.

sklearn compatible interface
2 participants