You are viewing documentation about an older version (1.0.9). View latest version

snowflake.ml.modeling.calibration.CalibratedClassifierCV

class snowflake.ml.modeling.calibration.CalibratedClassifierCV(*, estimator=None, method='sigmoid', cv=None, n_jobs=None, ensemble=True, base_estimator='deprecated', input_cols: Optional[Union[str, Iterable[str]]] = None, output_cols: Optional[Union[str, Iterable[str]]] = None, label_cols: Optional[Union[str, Iterable[str]]] = None, drop_input_cols: Optional[bool] = False, sample_weight_col: Optional[str] = None)

Bases: BaseTransformer

Probability calibration with isotonic regression or logistic regression For more details on this class, see sklearn.calibration.CalibratedClassifierCV

estimator: estimator instance, default=None

The classifier whose output need to be calibrated to provide more accurate predict_proba outputs. The default classifier is a LinearSVC.

method: {‘sigmoid’, ‘isotonic’}, default=’sigmoid’

The method to use for calibration. Can be ‘sigmoid’ which corresponds to Platt’s method (i.e. a logistic regression model) or ‘isotonic’ which is a non-parametric approach. It is not advised to use isotonic calibration with too few calibration samples (<<1000) since it tends to overfit.

cv: int, cross-validation generator, iterable or “prefit”, default=None

Determines the cross-validation splitting strategy. Possible inputs for cv are:

  • None, to use the default 5-fold cross-validation,

  • integer, to specify the number of folds.

  • CV splitter,

  • An iterable yielding (train, test) splits as arrays of indices.

For integer/None inputs, if y is binary or multiclass, StratifiedKFold is used. If y is neither binary nor multiclass, KFold is used.

Refer to the User Guide for the various cross-validation strategies that can be used here.

If “prefit” is passed, it is assumed that estimator has been fitted already and all data is used for calibration.

n_jobs: int, default=None

Number of jobs to run in parallel. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors.

Base estimator clones are fitted in parallel across cross-validation iterations. Therefore parallelism happens only when cv != “prefit”.

See Glossary for more details.

ensemble: bool, default=True

Determines how the calibrator is fitted when cv is not ‘prefit’. Ignored if cv=’prefit’.

If True, the estimator is fitted using training data, and calibrated using testing data, for each cv fold. The final estimator is an ensemble of n_cv fitted classifier and calibrator pairs, where n_cv is the number of cross-validation folds. The output is the average predicted probabilities of all pairs.

If False, cv is used to compute unbiased predictions, via cross_val_predict(), which are then used for calibration. At prediction time, the classifier used is the estimator trained on all the data. Note that this method is also internally implemented in sklearn.svm estimators with the probabilities=True parameter.

base_estimator: estimator instance

This parameter is deprecated. Use estimator instead.

input_cols: Optional[Union[str, List[str]]]

A string or list of strings representing column names that contain features. If this parameter is not specified, all columns in the input DataFrame except the columns specified by label_cols and sample-weight_col parameters are considered input columns.

label_cols: Optional[Union[str, List[str]]]

A string or list of strings representing column names that contain labels. This is a required param for estimators, as there is no way to infer these columns. If this parameter is not specified, then object is fitted without labels(Like a transformer).

output_cols: Optional[Union[str, List[str]]]

A string or list of strings representing column names that will store the output of predict and transform operations. The length of output_cols mus match the expected number of output columns from the specific estimator or transformer class used. If this parameter is not specified, output column names are derived by adding an OUTPUT_ prefix to the label column names. These inferred output column names work for estimator’s predict() method, but output_cols must be set explicitly for transformers.

sample_weight_col: Optional[str]

A string representing the column name containing the examples’ weights. This argument is only required when working with weighted datasets.

drop_input_cols: Optional[bool], default=False

If set, the response of predict(), transform() methods will not contain input columns.

Methods

fit(dataset)

Fit the calibrated model For more details on this function, see sklearn.calibration.CalibratedClassifierCV.fit

predict(dataset)

Predict the target of new samples For more details on this function, see sklearn.calibration.CalibratedClassifierCV.predict

predict_proba(dataset[, output_cols_prefix])

Calibrated probabilities of classification For more details on this function, see sklearn.calibration.CalibratedClassifierCV.predict_proba

score(dataset)

Return the mean accuracy on the given test data and labels For more details on this function, see sklearn.calibration.CalibratedClassifierCV.score

set_input_cols(input_cols)

Input columns setter.

to_sklearn()

Get sklearn.calibration.CalibratedClassifierCV object.

Attributes

model_signatures

Returns model signature of current class.