Skip to content

[DOC] Add model usage examples (v2) - #2408

Open
ramanbansal1 wants to merge 1 commit into
sktime:mainfrom
ramanbansal1:docs/v2-api-usage-examples
Open

[DOC] Add model usage examples (v2)#2408
ramanbansal1 wants to merge 1 commit into
sktime:mainfrom
ramanbansal1:docs/v2-api-usage-examples

Conversation

@ramanbansal1

@ramanbansal1 ramanbansal1 commented Sep 3, 2026

Copy link
Copy Markdown

Reference Issues/PRs

Related to: #2377

What does this implement/fix? Explain your changes.

This PR adds doctest-style usage examples to the v2 package classes for stable v2 models. The examples are minimal, CI-compliant docstrings that demonstrate the recommended high-
level package interface for the v2 API, helping users quickly adopt the new architecture.

• Added docstring usage examples for v2 package classes:

  • TFT_pkg_v2 (Temporal Fusion Transformer)
  • PatchTST_pkg_v2 (PatchTST)
  • DLinear_pkg_v2 (DLinear)
  • SCINet_pkg_v2 (SCINet)
  • SOFTS_pkg_v2 (SOFTS)
  • FreTS_pkg_v2 (FreTS)

• Each example contains:

  • Minimal synthetic dataset creation using the v2 TimeSeries API
  • Proper data module initialization (EncoderDecoderTimeSeriesDataModule or TslibDataModule)
  • Package-level model instantiation with model_cfg, trainer_cfg, and datamodule_cfg
  • Demonstration of the high-level fit/predict workflow
  • Doctest-compliant formatting with SKIP directives for Lightning-dependent operations

• Examples are CI-ready:

  • Use proper doctest prompts (>>> and ...) for doctest runner compatibility
  • Mark heavy operations (fit/predict) with  # doctest: +SKIP  to avoid Lightning dependency issues in CI
  • All lines ≤ 88 characters to comply with repository linting rules
  • Use type-safe assertions instead of numeric comparisons for robustness
  • Follow the exact v2 API structure (TimeSeries + DataModule patterns)

What should a reviewer concentrate their feedback on?

• Examples correctness:

  • Are the imports and model calls accurate for the current v2 codebase?
  • Do the examples correctly use the TimeSeries and DataModule v2 API?
  • Are the model_cfg parameters correct for each model?

• CI compliance:

  • Do the doctest examples parse correctly with  python -m doctest ?
  • Are the SKIP directives appropriately placed for Lightning-dependent operations?
  • Do line lengths comply with the 88-character limit?

• API consistency:

  • Do the examples demonstrate the recommended high-level package interface?
  • Are the data module parameters (max_encoder_length, context_length, etc.) correctly configured?
  • Are the loss functions and model parameters appropriate for each model type?

• Documentation quality:

  • Are the examples minimal yet complete enough to be copy-paste runnable?
  • Do they provide sufficient context for users to understand the v2 workflow?
  • Is the distinction between v1 and v2 API clear in the examples?

Did you add any tests for the change?

• No. These are documentation docstring examples only. The existing test suite for v2 models (test_all_estimators_v2.py ) includes doctest execution tests that will validate  these examples.

Any other comments?

• The v2 API is still experimental (users see warnings when importing TimeSeries and DataModule classes), but these examples follow the current stable v2 patterns.
• Examples use minimal synthetic data to avoid external dependencies and ensure they work in CI environments without Lightning.
• The package-level interface (model_cfg, trainer_cfg, datamodule_cfg) is the recommended way to use v2 models, as demonstrated in these examples.
• Future work could add similar examples to the corresponding model classes (_v2.py files) in addition to the package classes.

PR checklist

• [x] The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. ([DOC])
• [ ] Added/modified tests
• [ ] Used pre-commit hooks when committing to ensure that code is compliant with hooks. Install hooks with pre-commit install . To run hooks independent of commit, execute p
re-commit run --all-files

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@67c354f). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2408   +/-   ##
=======================================
  Coverage        ?   88.20%           
=======================================
  Files           ?      200           
  Lines           ?    11170           
  Branches        ?        0           
=======================================
  Hits            ?     9852           
  Misses          ?     1318           
  Partials        ?        0           
Flag Coverage Δ
cpu 88.20% <ø> (?)
pytest 88.20% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@phoeenniixx phoeenniixx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ramanbansal1!
But if you look at the issues #2407 and #2377, we are planning to make some changes to the API, so these examples will be overridden very soon.
That is why I would suggest working on v1 examples for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants