skpro.parametric package

Submodules

skpro.parametric.estimators module

class skpro.parametric.estimators.Constant(constant=None, name=None)[source]

Bases: sklearn.base.BaseEstimator

Constant estimator

Predicts predefinied constant

Parameters:
  • constant (float | callable(X, y) | string: 'mean(y)', 'std(y)' (default: None)) – Specifies the constant. A callable receives the training data during fit and should return a constant value. The string options provide a shortcut for mean/std extraction from the features.
  • name (string (optional)) – Optional description of the constant for the estimator string representation. Defaults to str(constant).
fit(X, y)[source]
get_params(deep=True)

Get parameters for this estimator.

Parameters:deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns:params – Parameter names mapped to their values.
Return type:mapping of string to any
predict(X)[source]
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:
Return type:self
class skpro.parametric.estimators.Minimum(base_estimator, minimum=0.3, relative=True)[source]

Bases: sklearn.base.BaseEstimator

Minimum estimator

Wrapping estimator that replaces predictions of the wrapped estimator that fall below a specified minimum threshold with the threshold itself.

Parameters:
  • estimator (subclass of sklearn.base.BaseEstimator) – Estimator which predicts shall be bounded by minimum threshold
  • minimum (float) – Minimum boundary for the estimator’s predictions. If relative=True the minimum represent a percentage value
  • relative (bool) – If true, minimum will be regarded as percentage value and the cut-off threshold will be determined dynamically during fitting as threshold = minimum * std(y)
  • Properties
  • ----------
  • estimator – Wrapped estimator
  • minimum – Minimum threshold
  • relative – If minimum is relative with regard to label variance
fit(X, y)[source]
get_params(deep=True)

Get parameters for this estimator.

Parameters:deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns:params – Parameter names mapped to their values.
Return type:mapping of string to any
predict(X)[source]
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:
Return type:self

skpro.parametric.parametric module

class skpro.parametric.parametric.EstimatorManager(parent)[source]

Bases: object

Helper class that simplifies the estimator management

Parameters:parent (subclass of sklearn.base.BaseEstimator) – Parent estimator object
fit(X, y)[source]
get(index)[source]
predict(name, X)[source]
register(name, estimator, selector=None)[source]

Registers an estimator

Parameters:
  • name (str) – Name of the estimator
  • estimator (Estimator object | string name of a registered estimator) – Instance of subclass of sklearn.base.BaseEstimator
  • selector (callable(estimator, X) (optional)) – Defines how a prediction should be retrieved from an estimator
Returns:

bool

Return type:

True on success

set_params(name, **params)[source]
class skpro.parametric.parametric.ParametricEstimator(point=None, std=None, point_std=None, shape='norm')[source]

Bases: skpro.base.ProbabilisticEstimator

Composite parametric prediction strategy.

Uses classical estimators to predict the defining parameters of continuous distributions.

Read more in the User Guide.

class Distribution(estimator, X, selection=slice(None, None, None), mode='elementwise')[source]

Bases: skpro.base.Distribution

X

Reference of the test features that are ought to correspond with the predictive distribution represented by the interface.

The interface methods (e.g. pdf) can use X to construct and exhibit the predictive distribution properties of the interface (e.g. construct the predicted pdf based on X)

Note that X automatically reflects the feature point for which the interface is ought to represent the distributional prediction. For given M x n features, X will thus represent an 1 x n vector that provides the bases for the predicted distribution. However, if the vectorvalued() decorator is applied X will represent the full M x n matrix for an efficient vectorized implementation.

Getter:Returns the test features based on the current subset selection
Setter:Sets the data reference
Type:array
cdf(x, *args, **kwargs)
lp2
mean(*args, **kwargs)

Mean prediction

Returns:
Return type:The mean prediction that corresponds to self.X
pdf(x, *args, **kwargs)
point
ppf(x)[source]

Percent point function (inverse of cdf — percentiles).

Parameters:q
Returns:
Return type:float
replicate(selection=None, mode=None)

Replicates the distribution object

Parameters:
  • selection (None | slice | int (optional)) – Subset point selection of the distribution copy
  • mode (str (optional)) – Interface mode (‘elementwise’ or ‘batch’)
Returns:

Return type:

skpro.base.ProbabilisticEstimator.Distribution

std
class ImplementsEnhancedInterface(name, bases, clsdict)

Bases: abc.ABCMeta

Meta-class for distribution interface

Enhances the distribution interface behind the scenes with automatic caching and syntactic sugar for element-wise access of the distributions

mro() → list

return a type’s method resolution order

register(subclass)

Register a virtual subclass of an ABC.

Returns the subclass, to allow usage as a class decorator.

fit(X, y)[source]

Fits the model

Parameters:
  • X (numpy array or sparse matrix of shape [n_samples,n_features]) – Training data
  • y (numpy array of shape [n_samples, n_targets]) – Target values. Will be cast to X’s dtype if necessary
Returns:

self

Return type:

returns an instance of self.

get_params(deep=True)

Get parameters for this estimator.

Parameters:deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns:params – Parameter names mapped to their values.
Return type:mapping of string to any
name()
predict(X)

Predicts using the model

Parameters:X ({array-like, sparse matrix}, shape = (n_samples, n_features)) – Samples.
Returns:Returns predicted distributions
Return type:Distribution interface representing n_samples predictions
score(X, y, sample=True, return_std=False)

Returns the log-loss score

Parameters:
  • X (np.array) – Features
  • y (np.array) – Labels
  • sample (boolean, default=True) – If true, loss will be averaged across the sample
  • return_std (boolean, default=False) – If true, the standard deviation of the loss sample will be returned
Returns:

Log-loss score

Return type:

mixed

set_params(**params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:
Return type:self

skpro.parametric.residuals module

class skpro.parametric.residuals.ResidualEstimator(residual_estimator, base_estimator='point', fit_transform='squared_error', predict_transform=None, filter_zero_variance=False)[source]

Bases: sklearn.base.BaseEstimator

Residual estimator

Predicts residuals of an estimator using a scikit-learn estimator.

Read more in the User Guide.

fit(X, y)[source]
get_params(deep=True)

Get parameters for this estimator.

Parameters:deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns:params – Parameter names mapped to their values.
Return type:mapping of string to any
predict(X)[source]
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:
Return type:self
skpro.parametric.residuals.abs_error_ft(y, y_pred)[source]
skpro.parametric.residuals.abs_error_pt(y_pred)
skpro.parametric.residuals.identity(y_pred)[source]
skpro.parametric.residuals.log_error_ft(y, y_pred)[source]
skpro.parametric.residuals.log_error_pt(y_pred)[source]
skpro.parametric.residuals.squared_error_ft(y, y_pred)[source]
skpro.parametric.residuals.squared_error_pt(y_pred)[source]

Module contents