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

[DOC] Writing the set_output docs page to document functionality #427

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/source/set_output.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. _set_output:

==========
skpro ``set_output`` API for Regression Models
==========

The following example will demonstrate how to use the ``set_output`` API
to configure the output container of your probabilistic predictions. Currently
for regression estimators, the following predict functions are supported:
``predict_quantile``, ``predict_interval``, ``predict_var``, and ``predict``.

Available ``mtypes`` include ``pd.DataFrame`` from the ``pandas`` library
and ``pl.DataFrame`` from the ``polars`` library.

We first load an sklearn dataset and import an skpro regression estimator.

.. code-block :: python

#import our dataset
from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split

#import our estimator
from sklearn.linear_model import LinearRegression
from skpro.regression.residual import ResidualDouble

X, y = load_diabetes(return_X_y=True, as_frame=True)
X = X.iloc[:75]
y = y.iloc[:75]
y = pd.DataFrame(y)
X_train, X_test, y_train, _ = train_test_split(
X, y, test_size=0.33, random_state=42
)

estimator = ResidualDouble(LinearRegression())

Next, we will call the ``set_output`` method built into the estimator.

.. code-block :: python

estimator.set_output(transform = "polars")

After we fit the model, we can then call the ``predict`` function and the
output will automatically be converted into a polars DataFrame

.. code-block :: python

estimator.fit(X_train, y_train)

estimator.predict(X_test)

*output polars dataframe here*