sklearndf.pipeline.SupervisedLearnerPipelineDF#

class sklearndf.pipeline.SupervisedLearnerPipelineDF(*, preprocessing=None)[source]#

A data frame enabled pipeline with an optional preprocessing step and a mandatory supervised learner step.

Bases

LearnerPipelineDF [~T_FinalSupervisedLearnerDF], SupervisedLearnerDF

Generic types

~T_FinalSupervisedLearnerDF(bound= SupervisedLearnerDF)

Metaclasses

ABCMeta

Parameters

preprocessing (Optional[TransformerDF]) – the preprocessing step in the pipeline (default: None)

Method summary

clone

Make an unfitted clone of this estimator.

fit

Fit this pipeline using the given inputs.

get_params

Get the parameters for this estimator.

predict

Predict outputs for the given inputs.

preprocess

Preprocess the given feature values using this pipeline's preprocessing step.

score

Score this learner using the given inputs and outputs.

set_params

Set the parameters of this estimator.

to_expression

Render this object as an expression.

Attribute summary

COL_FEATURE

Name assigned to an Index or a Series with the names of the features used to fit a EstimatorDF.

feature_names_in_

The pandas column index with the names of the features used to fit this estimator.

final_estimator

The final estimator following the preprocessing step.

final_estimator_name

The name of the estimator step parameter.

is_fitted

True if this object is fitted, False otherwise.

n_features_in_

The number of features used to fit this estimator.

n_outputs_

The number of outputs used to fit this estimator.

native_estimator

The native estimator underlying this estimator.

output_names_

The name(s) of the output(s) this supervised learner was fitted to.

preprocessing

The preprocessing step.

preprocessing_name

The name of the preprocessing step parameter.

Definitions

clone()#

Make an unfitted clone of this estimator.

Return type

SupervisedLearnerPipelineDF

Returns

the unfitted clone

fit(X, y=None, *, sample_weight=None, **fit_params)#

Fit this pipeline using the given inputs.

Parameters
  • X (Union[DataFrame, Series]) – input data frame with observations as rows and features as columns

  • y (Union[Series, DataFrame, None]) – an optional series or data frame with one or more outputs

  • sample_weight (Optional[Series]) – sample weights for observations, to be passed to the final estimator (optional)

  • fit_params (Any) – additional keyword parameters as required by specific estimator implementations

Return type

SupervisedLearnerPipelineDF

Returns

self

get_params(deep=True)#

Get the parameters for this estimator.

Parameters

deep (bool) – if True, return the parameters for this estimator, and for any sub-estimators contained in this estimator

Return type

Mapping[str, Any]

Returns

a mapping of parameter names to their values

predict(X, **predict_params)#

Predict outputs for the given inputs.

The inputs must have the same features as the inputs used to fit this learner. The features can be provided in any order since they are identified by their column names.

Parameters
  • X (Union[Series, DataFrame]) – input data frame with observations as rows and features as columns

  • predict_params (Any) – optional keyword parameters as required by specific learner implementations

Return type

Union[Series, DataFrame]

Returns

predictions per observation as a series, or as a data frame in case of multiple outputs

preprocess(X)#

Preprocess the given feature values using this pipeline’s preprocessing step.

If the pipeline has no preprocessing step, return the input unchanged.

Parameters

X (DataFrame) – input data frame with observations as rows and features as columns

Return type

DataFrame

Returns

the preprocessed input data frame

score(X, y=None, sample_weight=None)[source]#

Score this learner using the given inputs and outputs.

Parameters
  • X (Union[Series, DataFrame]) – data frame with observations as rows and features as columns

  • y (Optional[Series]) – a series or data frame with the true outputs per observation

  • sample_weight (Optional[Any]) – optional series of scalar weights, for calculating the resulting score as the weighted mean of the scores for the individual predictions

Return type

float

Returns

the score

set_params(**params)#

Set the parameters of this estimator.

Valid parameter keys can be obtained by calling get_params().

Parameters

params (Any) – the estimator parameters to set

Return type

SupervisedLearnerPipelineDF

Returns

self

to_expression()#

Render this object as an expression.

Return type

Expression

Returns

the expression representing this object

property feature_names_in_: pandas.Index#

The pandas column index with the names of the features used to fit this estimator.

Raises

AttributeError – this estimator is not fitted

Return type

Index

abstract property final_estimator: T_FinalEstimatorDF#

The final estimator following the preprocessing step.

Return type

TypeVar(T_FinalEstimatorDF, bound= EstimatorDF)

abstract property final_estimator_name: str#

The name of the estimator step parameter.

Return type

str

property is_fitted: bool#

True if this object is fitted, False otherwise.

Return type

bool

property n_features_in_: int#

The number of features used to fit this estimator.

Raises

AttributeError – this estimator is not fitted

Return type

int

property n_outputs_: int#

The number of outputs used to fit this estimator.

Raises

AttributeError – this estimator is not fitted

Return type

int

property native_estimator: sklearn.base.BaseEstimator#

The native estimator underlying this estimator.

This can be another estimator that this estimator delegates to, otherwise the native estimator is self.

Return type

BaseEstimator

property output_names_: List[str]#

The name(s) of the output(s) this supervised learner was fitted to.

Raises

sklearn.exceptions.NotFittedError – this estimator is not fitted

Return type

List[str]

property preprocessing: Optional[sklearndf.TransformerDF]#

The preprocessing step.

Return type

Optional[TransformerDF]

property preprocessing_name: str#

The name of the preprocessing step parameter.

Return type

str