facet.selection.base.CandidateEstimatorDF#

class facet.selection.base.CandidateEstimatorDF(candidate=None, candidate_name=None)[source]#

A trivial wrapper for classifiers, regressors and transformers, acting like a pipeline with a single step.

Used in conjunction with MultiEstimatorParameterSpace to evaluate multiple competing models: the candidate parameter determines the estimator to be used and is used to include multiple estimators as part of the parameter space that is searched during model tuning.

Bases

RegressorDF, TransformerDF, ClassifierDF

Metaclasses

ABCMeta

Parameters
  • candidate (Union[ClassifierDF, RegressorDF, TransformerDF, None]) – the current estimator candidate; usually not specified on class creation but set as a parameter during multi-estimator model selection

  • candidate_name (Optional[str]) – a name for the estimator candidate; usually not specified on class creation but set as a parameter during multi-estimator model selection

Method summary

clone

See sklearndf.EstimatorDF.clone()

decision_function

Compute the decision function for the given inputs.

fit

Fit this estimator using the given inputs.

fit_transform

See sklearndf.TransformerDF.fit_transform()

get_params

See sklearndf.EstimatorDF.get_params()

inverse_transform

Inverse-transform the given inputs.

predict

Predict outputs for the given inputs.

predict_log_proba

Predict class log-probabilities for the given inputs.

predict_proba

Predict class probabilities for the given inputs.

score

Score this learner using the given inputs and outputs.

set_output

See sklearn.utils.set_output()

set_params

See sklearndf.EstimatorDF.set_params()

to_expression

See sklearndf.EstimatorDF.to_expression()

transform

Transform the given inputs.

Attribute summary

COL_FEATURE

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

COL_FEATURE_ORIGINAL

Name assigned to a Series with the original feature names before transformation.

PARAM_CANDIDATE

name of the candidate parameter

PARAM_CANDIDATE_NAME

name of the candidate_name parameter

classes_

See sklearndf.ClassifierDF.classes_

feature_names_in_

See sklearndf.EstimatorDF.feature_names_in_

feature_names_original_

See sklearndf.TransformerDF.feature_names_original_

feature_names_out_

See sklearndf.TransformerDF.feature_names_out_

is_fitted

True if this object is fitted, False otherwise.

n_features_in_

See sklearndf.EstimatorDF.n_features_in_

n_outputs_

See sklearndf.EstimatorDF.n_outputs_

native_estimator

See sklearndf.EstimatorDF.native_estimator

output_names_

See sklearndf.SupervisedLearnerDF.output_names_

candidate

The currently selected estimator candidate.

candidate_name

The name of the candidate, used for more readable summary reports of model tuning results.

Definitions

clone()#

See sklearndf.EstimatorDF.clone()

decision_function(X, **predict_params)[source]#

Compute the decision function 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

a data frame with observations as rows and classes as columns, and values as the raw values predicted per observation and class; for multi-output classifiers, a list of one observation/class data frames per output

fit(X, y=None, **fit_params)[source]#

Fit this estimator using the given inputs.

Parameters
  • X (Union[Series, DataFrame]) – 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

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

Return type

CandidateEstimatorDF

Returns

self

fit_transform(X, y=None, **fit_params)#

See sklearndf.TransformerDF.fit_transform()

get_params(deep=True)#

See sklearndf.EstimatorDF.get_params()

inverse_transform(X)[source]#

Inverse-transform the given inputs.

The inputs must have the same features as the inputs used to fit this transformer. 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

Return type

DataFrame

Returns

the reverse-transformed inputs

predict(X, **predict_params)[source]#

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

predict_log_proba(X, **predict_params)[source]#

Predict class log-probabilities 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[DataFrame, List[DataFrame]]

Returns

a data frame with observations as rows and classes as columns, and values as log-probabilities per observation and class; for multi-output classifiers, a list of one observation/class data frames per output

predict_proba(X, **predict_params)[source]#

Predict class probabilities 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[DataFrame, List[DataFrame]]

Returns

a data frame with observations as rows and classes as columns, and values as probabilities per observation and class; for multi-output classifiers, a list of one observation/class data frames per output

score(X, y, 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 (Series) – a series or data frame with the true outputs per observation

  • sample_weight (Optional[Series]) – 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_output(*, transform=None)#

See sklearn.utils.set_output()

set_params(**params)#

See sklearndf.EstimatorDF.set_params()

to_expression()#

See sklearndf.EstimatorDF.to_expression()

transform(X)[source]#

Transform the given inputs.

The inputs must have the same features as the inputs used to fit this transformer. 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

Return type

DataFrame

Returns

the transformed inputs

PARAM_CANDIDATE = 'candidate'#

name of the candidate parameter

PARAM_CANDIDATE_NAME = 'candidate_name'#

name of the candidate_name parameter

candidate: Optional[Union[sklearndf.ClassifierDF, sklearndf.RegressorDF, sklearndf.TransformerDF]]#

The currently selected estimator candidate.

candidate_name: Optional[str]#

The name of the candidate, used for more readable summary reports of model tuning results.

property classes_: Union[numpy.ndarray[Any, numpy.dtype[Any]], List[numpy.ndarray[Any, numpy.dtype[Any]]]]#

See sklearndf.ClassifierDF.classes_

property feature_names_in_: pandas.Index#

See sklearndf.EstimatorDF.feature_names_in_

property feature_names_original_: pandas.Series#

See sklearndf.TransformerDF.feature_names_original_

property feature_names_out_: pandas.Index#

See sklearndf.TransformerDF.feature_names_out_

property is_fitted: bool#

True if this object is fitted, False otherwise.

Return type

bool

property n_features_in_: int#

See sklearndf.EstimatorDF.n_features_in_

property n_outputs_: int#

See sklearndf.EstimatorDF.n_outputs_

property native_estimator: sklearn.base.BaseEstimator#

See sklearndf.EstimatorDF.native_estimator

property output_names_: List[str]#

See sklearndf.SupervisedLearnerDF.output_names_