Skip to content

Commit

Permalink
[DOC] extension templates: instruction preamble (#521)
Browse files Browse the repository at this point in the history
This PR adds an instruction preamble to each current extension template
on how to use them.
  • Loading branch information
fkiraly authored Jan 25, 2025
1 parent af584ad commit 162ed79
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 3 deletions.
41 changes: 40 additions & 1 deletion extension_templates/distributions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
"""Extension template for probability distributions - simple pattern."""
"""Extension template for probability distributions - simple pattern.
Purpose of this implementation template:
quick implementation of new estimators following the template
NOT a concrete class to import! This is NOT a base class or concrete class!
This is to be used as a "fill-in" coding template.
How to use this implementation template to implement a new distribution:
- make a copy of the template in a suitable location, give it a descriptive name.
- work through all the "todo" comments below
- fill in code for mandatory methods, and optionally for optional methods
- do not write to reserved attributes: index, columns, head, tail, loc, iloc, at, iat,
shape, ndim, _bc_params, _tags, _tags_dynamic, _config, _config_dynamic
- you can add more private methods, but do not override BaseEstimator's private methods
an easy way to be safe is to prefix your methods with "_custom"
- change docstrings for functions and the file
- ensure interface compatibility by skpro.utils.estimator_checks.check_estimator
- once complete: use as a local library, or contribute to skpro via PR
- more details:
https://www.sktime.net/en/stable/developer_guide/add_estimators.html
Mandatory methods to implement: at least one, better both of
sampling - sample(self, n_samples=None)
ppf - _ppf(self, p)
Optional methods to implement:
mean - _mean(self)
variance - _var(self)
pdf - _pdf(self, x)
log_pdf - _log_pdf(self, x)
pmf - _pmf(self, x)
log_pmf - _log_pmf(self, x)
cdf - _cdf(self, x)
ppf - _ppf(self, p)
energy_self - _energy_self(self)
energy_x - _energy_x(self, x)
Testing - required for test framework and check_estimator usage:
get default parameters for test instance(s) - get_test_params()
"""
# todo: write an informative docstring for the file or module, remove the above
# todo: add an appropriate copyright notice for your estimator
# estimators contributed to skpro should have the copyright notice at the top
Expand Down
37 changes: 36 additions & 1 deletion extension_templates/regression.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
"""Extension template for regressors."""
"""Extension template for regressors.
Purpose of this implementation template:
quick implementation of new estimators following the template
NOT a concrete class to import! This is NOT a base class or concrete class!
This is to be used as a "fill-in" coding template.
How to use this implementation template to implement a new distribution:
- make a copy of the template in a suitable location, give it a descriptive name.
- work through all the "todo" comments below
- fill in code for mandatory methods, and optionally for optional methods
- do not write to reserved attributes: is_fitted, _is_fitted, _X_metadata, _y_metadata,
_tags, _tags_dynamic, _config, _config_dynamic
- you can add more private methods, but do not override BaseEstimator's private methods
an easy way to be safe is to prefix your methods with "_custom"
- change docstrings for functions and the file
- ensure interface compatibility by skpro.utils.estimator_checks.check_estimator
- once complete: use as a local library, or contribute to skpro via PR
- more details:
https://www.sktime.net/en/stable/developer_guide/add_estimators.html
Mandatory methods to implement:
fitting - _fit(self, X, y)
At least one of the following probabilistic prediction methods:
predicting quantiles - _predict_quantiles(self, X, alpha=None)
OR predicting intervals - _predict_interval(self, X, coverage=None)
OR predicting distribution - _predict_proba(self, X)
Optional methods to implement:
predicting variance - _predict_var(self, X, cov=False)
updating - _update(self, X, y)
Testing - required for test framework and check_estimator usage:
get default parameters for test instance(s) - get_test_params()
"""
# todo: write an informative docstring for the file or module, remove the above
# todo: add an appropriate copyright notice for your estimator
# estimators contributed to skpro should have the copyright notice at the top
Expand Down
39 changes: 38 additions & 1 deletion extension_templates/survival.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
"""Extension template for time-to-event predictors aka survival predictors."""
"""Extension template for time-to-event predictors aka survival predictors.
Purpose of this implementation template:
quick implementation of new estimators following the template
NOT a concrete class to import! This is NOT a base class or concrete class!
This is to be used as a "fill-in" coding template.
How to use this implementation template to implement a new distribution:
- make a copy of the template in a suitable location, give it a descriptive name.
- work through all the "todo" comments below
- fill in code for mandatory methods, and optionally for optional methods
- do not write to reserved attributes: is_fitted, _is_fitted, _X_metadata, _y_metadata,
_tags, _tags_dynamic, _config, _config_dynamic
- you can add more private methods, but do not override BaseEstimator's private methods
an easy way to be safe is to prefix your methods with "_custom"
- change docstrings for functions and the file
- ensure interface compatibility by skpro.utils.estimator_checks.check_estimator
- once complete: use as a local library, or contribute to skpro via PR
- more details:
https://www.sktime.net/en/stable/developer_guide/add_estimators.html
Mandatory methods to implement:
fitting - _fit(self, X, y, C=None)
The method must handle the case C=None, as well as the case where C is a pd.DataFrame.
At least one of the following probabilistic prediction methods:
predicting quantiles - _predict_quantiles(self, X, alpha=None)
OR predicting intervals - _predict_interval(self, X, coverage=None)
OR predicting distribution - _predict_proba(self, X)
Optional methods to implement:
predicting variance - _predict_var(self, X, cov=False)
updating - _update(self, X, y)
Testing - required for test framework and check_estimator usage:
get default parameters for test instance(s) - get_test_params()
"""
# todo: write an informative docstring for the file or module, remove the above
# todo: add an appropriate copyright notice for your estimator
# estimators contributed to skpro should have the copyright notice at the top
Expand Down

0 comments on commit 162ed79

Please sign in to comment.