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

[ENH] Migrating Estimators from sktime-dl #3351

Open
20 of 27 tasks
AurumnPegasus opened this issue Aug 26, 2022 · 17 comments
Open
20 of 27 tasks

[ENH] Migrating Estimators from sktime-dl #3351

AurumnPegasus opened this issue Aug 26, 2022 · 17 comments
Assignees
Labels
enhancement Adding new functionality good first issue Good for newcomers module:classification classification module: time series classification module:regression regression module: time series regression

Comments

@AurumnPegasus
Copy link
Contributor

AurumnPegasus commented Aug 26, 2022

Is your feature request related to a problem? Please describe.
Related to the task of migrating estimators from sktime-dl to sktime. The main goal of doing so is to have all networks/models in a single package, following similar structure and quality.

Steps for Migration

Choose one of the Classifiers or Regressors from the list below, and create an issue for it.
There are 2 key components to a DL Estimator, the Network (creates the actual code of neural network) and the Estimator (Is a layer of abstraction to make the user's life easier).
Lets say I want to create CNNClassifier (steps are similar for any other DL Regressor or Classifier, whereever there are differences, I will mention them)

  1. Our first task would be to check if the network has already been implemented or not. Networks are often common for multiple estimators (for eg, CNNClassifier and CNNRegressor use the same CNNNetwork). So, I would check if a file named cnn.py exists in sktime/sktime/networks. If it does, that means that the network has already been made, and you can skip to the step to create the classifier.
  2. If the network has not been created, we need to create one. Create a file called cnn.py in sktime/sktime/networks. This file will contain our CNNNetwork. You will have to migrate the network from sktime-dl to sktime. To do so, you will need to go to sktime-dl/networks and look for _cnn.py
  3. Migrate this code from sktime-dl to sktime. An example of this migration is that the original code of _cnn.py from sktime dl has been migrated as cnn.py in sktime. The code, for most part, remains the same, with different documentation at most. There are a few cases where the migration is not as straightforward, and it would be described in the end.
  4. Ensure all the tests pass for the Network you created! Run the pytest, and then run the check_estimator tests as mentioned in the developer guide. Once all the tests pass, you have successfully migrated your Network.
  5. Now, to create an estimator, lets create a new file called cnn.py at sktime/sktime/classification/deep_learning/. You will be migrating the CNNClassifier here. You will have to migrate the network from sktime-dl to sktime. To do so, go to sktime-dl/classification and look for _cnn.py.
  6. Migrate this code from sktime-dl to sktime. An example of this migration is that the original code of _cnn.py from sktime-dl has been migrated as cnn.py in sktime. The code and core logic, for most part, remains the same. There are minor differences in _fit method you will need to take care of. For other cases where the migration is not as straightforward are described in the end.
  7. Ensure all the tests pass for the Estimator you created! (the steps here are the same as step 4, but for Classifier/Regressor instead of Network)

Special Cases

Adding Soft Dependancy
  1. In cases where the particular network/estimator requires an additional dependency, (for example, CNTCNetwork requires keras_self_attention), you have to add them as a soft dependancy
  2. Firstly, go to pyproject.toml, and check in the all_extras list whether the dependency you want to add (lets say keras_self_attention), already exists within it or not. IF it does, it means that it already is a soft dependancy, and you can skip the steps required to add it as a soft dep.
  3. To add a dependency as soft dependency, follow the instructions mentioned in the dev guide. You mostly will have to add it in the all_extras list of pyproject.toml.
  4. Next, we need to go to the classes where we need to use the soft dep, and add a check for _check_soft_dependencies. An example for how it is done is there in CNTCNetwork

DL Classifiers:

DL Regressors:

@AurumnPegasus AurumnPegasus added the enhancement Adding new functionality label Aug 26, 2022
@fkiraly
Copy link
Collaborator

fkiraly commented Aug 26, 2022

quick question about the recipe: do we always need to create a separate network? Or are there a few common ones? E.g., for regression/classification? Should the regressor/classifier not use the same network?

@AurumnPegasus
Copy link
Contributor Author

Yup, made those changes. Will add more instructions as well

@nilesh05apr
Copy link
Contributor

I want to work on the implementation of ResNet Classifier and regressor, but i could not understand the migration steps. @fkiraly @AurumnPegasus can you please help me.

@AurumnPegasus
Copy link
Contributor Author

Hey @nilesh05apr ,
Maybe the steps are not clear enough, I will work on it to improve it. In the meanwhile:

Firstly, create an issue for the estimator you want to work on. Then,
There are 2 main components to a DL estimator: the Network, and the Classifier (or Regressor).
For ResNet, as you can see in this issue itself, the Network has not been migrated yet.

So firstly, go to the network code in sktime-dl. This is the code you need to migrate to sktime. Create a file in sktime/sktime/networks/ called as resnet.py.
Within that, migrate the code from the code base to resnet.py according to examples provided above (like in #3232 )
Once the main network has been created, you can create the respective estimators from it.

To create the Classifier, go to classifier code in sktime-dl. This is the code you need to migrate to sktime. Create a file in sktime/sktime/classification/deep_learning called resnet.py. Within that, migrate the code from the code base to resnet.py according to examples provided above (line in #3232 ).

You can import the documentation following the way it has been written in either MLPClassifier or CNNClassifier/CNNRegressor.

I hope it helps! Let me know if you get stuck somehwere.

@nilesh05apr
Copy link
Contributor

Thanks @AurumnPegasus for the clarification, it's much clear now. I have started working on it.

@nilesh05apr
Copy link
Contributor

@AurumnPegasus @fkiraly i have made a pr will resnet implemented can you please review it and also assign me this issue. i will migrate all the estimators from this sktime_dl to sktime.

@AurumnPegasus
Copy link
Contributor Author

AurumnPegasus commented Aug 31, 2022

@fkiraly I have updated the wordings and migration instructions, hope they are better. I will add the code and examples for special cases in some time (since we have not really agreed to a couple of cases yet).
Also, would request you to add the good first issue label to this.

@nilesh05apr
Copy link
Contributor

@AurumnPegasus can you please link steps to test the changes locally.

@AurumnPegasus
Copy link
Contributor Author

Hey @nilesh05apr ,
Ensure that you have all the developer requirements installed, follow the instructions mentioned here

Once that is done, to test the estimators (lets say you want to test ResNetClassifier)
Firstly, run all the pytests (you can do it via vscode as well) via the general bash command:
pytest ./sktime/classification/

Then, run the check_estimators test as mentioned here

Hope it helps!

@achieveordie
Copy link
Collaborator

I'll work on TapNet Classifier Migration. Do add #3372 to the list.

@achieveordie
Copy link
Collaborator

Hey, taking up one regressor model as well. Kindly add #3474 to the list.

@TonyBagnall TonyBagnall added module:classification classification module: time series classification module:regression regression module: time series regression labels Oct 4, 2022
fkiraly pushed a commit that referenced this issue Dec 11, 2022
Part of #3351. See also #3365 

Migrates `ResNetClassifier` from `sktime-dl` to `sktime`
@ArushikaBansal
Copy link
Contributor

Hi there!!!
This is Arushika, I am quite new to open source.
I have been wanting to implement RNN regressor but (as per the steps you specified), I will need a "_rnn.py" file in sktime-dl/networks but as it turns out there is no network of that sort
So what am I supposed to do in this case
Should I myself write a _rnn.py file????

@achieveordie
Copy link
Collaborator

Hey @ArushikaBansal, thanks for taking this up. In the specific case of RNNRegressor it looks like the underlying Network model would be relatively small. That may be why the original author wrote it in a single file. But if we were to port this into sktime, we'd want it a separate Network file since we want to keep the API design consistent.

You can use this file to create both the network and the estimator so it shouldn't be much of trouble. In case you face any difficulty, feel free to ask me or any other core dev you want to ask.

(Do keep in mind to use one of the already ported estimators as a reference, that will make things easier.)

@ArushikaBansal
Copy link
Contributor

Thankyou sir for the help!!!!!
I will try doing the same.

@ArushikaBansal
Copy link
Contributor

I made the required changes please review them
.

fkiraly pushed a commit that referenced this issue Apr 16, 2023
…`) (#3003)

Towards #3351

Migrates `InceptionTime` classifier, network and the corresponding jupyter notebook from `sktime-dl`, with minor changes to work within `sktime`.
fkiraly pushed a commit that referenced this issue Apr 29, 2023
…#4185)

migrates simple RNN regressor from sktime-dl, see
#3351
achieveordie added a commit that referenced this issue May 23, 2023
<!--
Thanks for contributing a pull request! Please ensure you have taken a
look
at our contribution guide:
https://github.com/sktime/sktime/blob/main/CONTRIBUTING.md
-->

#### Reference Issues/PRs
<!--
Example: Fixes #1234. See also #3456.

Please use keywords (e.g., Fixes) to create link to the issues or pull
requests
you resolved, so that they will automatically be closed when your pull
request
is merged. See
https://github.com/blog/1506-closing-issues-via-pull-requests
-->
Fixes #3294 
Part of #3351

#### What does this implement/fix? Explain your changes.
<!--
A clear and concise description of what you have implemented.
-->
Add `MACNNNetwork` and `MACNNClassifier`.

#### Does your contribution introduce a new dependency? If yes, which
one?

<!--
If your contribution does add a new hard dependency, we may suggest to
initially develop your contribution in a separate companion package in
https://github.com/sktime/ to keep external dependencies of the core
sktime package to a minimum.
-->
None

#### What should a reviewer concentrate their feedback on?

<!-- This section is particularly useful if you have a pull request that
is still in development. You can guide the reviews to focus on the parts
that are ready for their comments. We suggest using bullets (indicated
by * or -) and filled checkboxes [x] here -->

#### Did you add any tests for the change?

<!-- This section is useful if you have added a test in addition to the
existing ones. This will ensure that further changes to these files
won't introduce the same kind of bug. It is considered good practice to
add tests with newly added code to enforce the fact that the code
actually works. This will reduce the chance of introducing logical bugs.
-->

#### Any other comments?
<!--
Please be aware that we are a loose team of volunteers so patience is
necessary; assistance handling other issues is very welcome. We value
all user contributions, no matter how minor they are. If we are slow to
review, either the pull request needs some benchmarking, tinkering,
convincing, etc. or more likely the reviewers are simply busy. In either
case, we ask for your understanding during the review process.
-->

#### PR checklist
<!--
Please go through the checklist below. Please feel free to remove points
if they are not applicable.
-->

##### For all contributions
- [ ] I've added myself to the [list of
contributors](https://github.com/sktime/sktime/blob/main/CONTRIBUTORS.md)
with any new badges I've earned :-)
How to: add yourself to the [all-contributors
file](https://github.com/sktime/sktime/blob/main/.all-contributorsrc) in
the `sktime` root directory (not the `CONTRIBUTORS.md`). Common badges:
`code` - fixing a bug, or adding code logic. `doc` - writing or
improving documentation or docstrings. `bug` - reporting or diagnosing a
bug (get this plus `code` if you also fixed the bug in the
PR).`maintenance` - CI, test framework, release.
See here for [full badge
reference](https://allcontributors.org/docs/en/emoji-key)
- [ ] Optionally, I've added myself and possibly others to the
[CODEOWNERS](https://github.com/sktime/sktime/blob/main/CODEOWNERS) file
- do this if you want to become the owner or maintainer of an estimator
you added.
See here for further details on the [algorithm maintainer
role](https://www.sktime.net/en/latest/get_involved/governance.html#algorithm-maintainers).
- [x] The PR title starts with either [ENH], [MNT], [DOC], or [BUG].
[BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving
code, [DOC] - writing or improving documentation or docstrings.

##### For new estimators
- [x] I've added the estimator to the API reference - in
`docs/source/api_reference/taskname.rst`, follow the pattern.
- [x] I've added one or more illustrative usage examples to the
docstring, in a pydocstyle compliant `Examples` section.
- [x] If the estimator relies on a soft dependency, I've set the
`python_dependencies` tag and ensured
dependency isolation, see the [estimator dependencies
guide](https://www.sktime.net/en/latest/developer_guide/dependencies.html#adding-a-soft-dependency).


<!--
Thanks for contributing!
-->
fkiraly pushed a commit that referenced this issue Jul 14, 2023
…4637)

Fixes #3295
Part of #3351

Migrates `MCDCNNClassifier`, `MCDCNNRegressor` and `MCDCNNNetwork`
@fkiraly fkiraly removed this from To do in Workstream: benchmarking Aug 4, 2023
@fkiraly
Copy link
Collaborator

fkiraly commented Jan 24, 2024

FYI, for all contributors to sktime-dl estimators.

  • we are wrapping up migration of remaining sktime-dl estimators to sktime
  • sktime has adopted an estimator level package management approach, with owners and dependencies specified via scikit-base tags

Issues will also be migrated to sktime, and a migration of unreviewed pull requests of bugfixes would also be appreciated.

Pinging:

PR contributors:

Issue owers:

Algorithm maintainers and core contributors:
(you have been added to "maintainers" tags)

fkiraly pushed a commit that referenced this issue Feb 26, 2024
#### Reference Issues/PRs
Part of #3351. See also
#3365

#### What does this implement/fix? Explain your changes.
Migrated FCN, MLP and LSTMFCN regressors to sktime from sktime-dl
fkiraly pushed a commit that referenced this issue Mar 2, 2024
#6038)

#### Reference Issues/PRs
Part of #3351. See also
#3365

#### What does this implement/fix? Explain your changes.
Migrated CNTC, InceptionTime, and MACNN regressors to sktime from
sktime-dl
fnhirwa pushed a commit to fnhirwa/sktime that referenced this issue Mar 6, 2024
sktime#6038)

#### Reference Issues/PRs
Part of sktime#3351. See also
sktime#3365

#### What does this implement/fix? Explain your changes.
Migrated CNTC, InceptionTime, and MACNN regressors to sktime from
sktime-dl
@fnhirwa
Copy link
Contributor

fnhirwa commented Jul 2, 2024

@fkiraly could you assign this issue to me as I am going to work on it to ensure that all estimators are migrated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding new functionality good first issue Good for newcomers module:classification classification module: time series classification module:regression regression module: time series regression
Projects
Status: In Progress
Development

No branches or pull requests

7 participants