Skip to content

[ENH] Add BaseBayesianRegressor class for Bayesian model interface#802

Open
arnavk23 wants to merge 3 commits intosktime:mainfrom
arnavk23:feature/issue-389-bayesian-interface
Open

[ENH] Add BaseBayesianRegressor class for Bayesian model interface#802
arnavk23 wants to merge 3 commits intosktime:mainfrom
arnavk23:feature/issue-389-bayesian-interface

Conversation

@arnavk23
Copy link
Contributor

@arnavk23 arnavk23 commented Mar 6, 2026

Reference Issues/PRs

Towards #389

What does this implement/fix? Explain your changes.

This PR implements the Bayesian model interface design proposed in issue #389. It introduces a BaseBayesianRegressor class that encapsulates PyMC backend logic for MCMC sampling and posterior predictive inference, making it easier to create new Bayesian estimators.

The base class handles all PyMC complexity, allowing subclasses to focus only on defining their probabilistic models via the _build_model() method.

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

Yes, adds arviz as an optional dependency for Bayesian posterior analysis and diagnostics.

What should a reviewer concentrate their feedback on?

  • API design and consistency with existing skpro patterns
  • Proper handling of PyMC model context and MCMC sampling

Did you add any tests for the change?

The existing tests for BayesianLinearRegressor should continue to work with the refactored implementation. Additional tests for the base class could be added in a follow-up PR.

Any other comments?

This implementation follows the detailed design specification from the issue #389. The base class provides a clean abstraction that will make it easier to implement additional Bayesian estimators in the future.

PR checklist

For all contributions

  • I've added myself to the list of contributors with any new badges I've earned :-)
    How to: add yourself to the all-contributors file in the skpro 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
  • 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

  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured dependency isolation, see the estimator dependencies guide.

arnavk23 added 2 commits March 6, 2026 13:20
- Create BaseBayesianRegressor that encapsulates PyMC backend logic
- Refactor BayesianLinearRegressor to inherit from BaseBayesianRegressor
- Implement standardized MCMC sampling, prediction, and parameter retrieval
- Add get_posterior_summary method for posterior analysis
- Update dependencies and imports

Closes sktime#389
- Add arviz to all_extras in pyproject.toml for Bayesian functionality
- Required for BaseBayesianRegressor and Bayesian estimators
@arnavk23 arnavk23 changed the title [ENH] Add BaseBayesianRegressor class for Bayesian model interface [ENH] Add BaseBayesianRegressor class for Bayesian model interface Mar 6, 2026
- Remove unused imports from BaseBayesianRegressor
- Remove unused training_data variable from BayesianLinearRegressor
- Fix code formatting and linting issues
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Thanks!

This seems to be primarily MC-based. I think a base Bayesian regressor should be able to accommodate non-MC-paradigms too.

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