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] add at least one usage example to docstrings of estimators #4264

Open
Tracked by #3686
fkiraly opened this issue Feb 23, 2023 · 12 comments
Open
Tracked by #3686

[ENH] add at least one usage example to docstrings of estimators #4264

fkiraly opened this issue Feb 23, 2023 · 12 comments
Labels
documentation Documentation & tutorials enhancement Adding new functionality good first issue Good for newcomers

Comments

@fkiraly
Copy link
Collaborator

fkiraly commented Feb 23, 2023

Each estimator should have an example in its docstring.

This example should cover basic usage, and possiblly advanced cases.

The recipe for adding examples is:

  • add an example section in numpydoc stype
  • use as template for a simple example: NaiveForecaster
  • use as template for complex/multiple examples: ForecastingGridSearchCV (search in code base)
  • if the estimator relies on a soft dependency, ensure to use doctest skip to avoid import if the dependency is not present. Use as template for an example with soft dependency: ARIMA

To pick this up, post an estimator here that you are working on, to avoid double work, and make a PR.

@fkiraly fkiraly added documentation Documentation & tutorials enhancement Adding new functionality good first issue Good for newcomers labels Feb 23, 2023
@fkiraly fkiraly changed the title [ENH] add at least one example to docstrings of estimators [ENH] add at least one usage example to docstrings of estimators Feb 23, 2023
@KishManani
Copy link
Contributor

Hi @fkiraly! Happy to help adding some/more examples in the doc strings of estimators. Do you have a list already of some of the likely most used estimators that could benefit with an example?

@fkiraly
Copy link
Collaborator Author

fkiraly commented Feb 27, 2023

There are currently 90 (out of 237) objects in sktime without example, code to generate them:

from sktime.registry import all_estimators

ests = all_estimators()
[x[1] for x in ests if "Example" not in x[1].__doc__ ]

(to subset to types, use the scitype arg of all_estimators)

@fkiraly
Copy link
Collaborator Author

fkiraly commented Feb 27, 2023

The most "important" ones that I see in the list are (subjectively chosen):

  • ForecastingRandomizedSearchCV
  • DontUpdate, UpdateEvery, UpdateRefitsEvery
  • YToX
  • TimeBinner
  • Id
  • TSFreshClassifier
  • TimeSeriesForestRegressor
  • DummyClassifier
  • TruncationTransformer

@JonathanBechtel
Copy link
Contributor

@fkiraly After PR #4272 gets accepted I'll work on one for TimeSeriesForestRegressor and ForecastingRandomizedSearchCV

fkiraly pushed a commit that referenced this issue Mar 18, 2023
Adds to #4264

This fixes a small pet peeve of mine with the current documentation, which is that the actual import for the technique is often not listed in the example, so you can't just copy and paste from the API reference to see how it works.  This inconvenience is compounded by the fact that the actual imports you need to use are often irregular and can't be easily inferred from the way different methods are listed in the API docs.  So you often have to go on a bit of a chase just to figure out how to import something.
fkiraly pushed a commit that referenced this issue Mar 29, 2023
)

Adds to #4264, also references #4324

Distance calculation docstrings currently do not import the actual method from sktime, which makes it inconvenient to use the examples for quick use.  This PR adds the import statement for each distance calculation in the docstring.
fkiraly pushed a commit that referenced this issue Jun 25, 2023
Adds to #4264. 

Added usage examples to `k_means` and `k_medoids`.
fkiraly pushed a commit that referenced this issue Jun 27, 2023
…nd Dummy Regressor (#4775)

Additions to #4264 

Added examples to docstrings in _tsf.py and _dummy.py. Fixed a typo in
docstring for ResNetRegressor example.
@Verogli
Copy link
Contributor

Verogli commented Jul 22, 2023

I am adding examples to docstrings for DBScan.

@fkiraly
Copy link
Collaborator Author

fkiraly commented Jul 22, 2023

FYI @Verogli, there's an example for DBScan in the EuroPython tutorial - this notebook: https://github.com/sktime/sktime-tutorial-europython-2023/blob/main/notebooks/05_panel_tasks.ipynb

although the result isn't "nice" in the sense of the clulster split being very clear.

@Verogli
Copy link
Contributor

Verogli commented Jul 22, 2023

Thank you. I will look into that.

@meraldoantonio
Copy link
Contributor

Hi! It's my first time contributing. I plan to add an example for CNNRegressor following the example from KNeighborsTimeSeriesRegressor. I imagine I'll need to include doctest skip for this?

@fkiraly
Copy link
Collaborator Author

fkiraly commented Mar 9, 2024

Nice! Yes, the doctest should be skipped due to the soft dependency (alternatively, you can make the execution condtional on the soft dependency being present, that's a newer feature in doctest).

fkiraly pushed a commit that referenced this issue Mar 13, 2024
#### Reference Issues/PRs
Adds to #4264 

#### What does this implement/fix? Explain your changes.
Added one usage example to `CNNRegressor`.
@YashKhare20
Copy link
Contributor

Hi all! It's my first time contributing. I've added an example for DummyClassifier following the example from DummyRegressor. I've included doctest skip due to the soft dependency, hope that is fine.

@fkiraly
Copy link
Collaborator Author

fkiraly commented Mar 17, 2024

Great addition, thanks, @YashKhare20!

Minor note, I think DummyRegressor does not have a soft dependency? So the doctest skips wouldn't be necessary.

fkiraly pushed a commit that referenced this issue Mar 19, 2024
#### What does this implement/fix? Explain your changes.

Added examples to docstrings in sktime.regression.deep_learning.mlp.py
for MLPRegressor.
@SamruddhiNavale
Copy link
Contributor

Hello Team! I've added an example for WhiteNoiseAugmenter. Please let me know your review/feedback.
Thank You!

fkiraly pushed a commit that referenced this issue Mar 24, 2024
Added examples to docstrings in ```DummyClassifier```
ksharma6 added a commit to ksharma6/sktime that referenced this issue Mar 25, 2024
fkiraly pushed a commit that referenced this issue Apr 2, 2024
Adds to #4264 and partly addresses #4400

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

I added import statements to the `InvertAugmenter` example in the docstrings to improve copy-paste experience of a user.
fkiraly pushed a commit that referenced this issue Apr 26, 2024
#### Reference Issues/PRs
Adds to #4264

#### What does this implement/fix? Explain your changes.
Added examples to docstrings in `WhiteNoiseAugmenter`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation & tutorials enhancement Adding new functionality good first issue Good for newcomers
Projects
Documentation Overhaul
Awaiting triage
Development

No branches or pull requests

7 participants