chemicalchecker.tool.targetmate.nonconformist.acp.BootstrapConformalClassifier
- class BootstrapConformalClassifier(predictor, n_models=10)[source]
Bases:
AggregatedCp
Bootstrap conformal classifier.
Combines multiple IcpClassifiers into a bootstrap conformal classifier.
Parameters
- predictorobject
Prototype conformal predictor (e.g. IcpClassifier or IcpRegressor) used for defining conformal predictors included in the aggregate model.
- aggregation_funccallable
Function used to aggregate the predictions of the underlying conformal predictors. Defaults to
numpy.mean
.- n_modelsint
Number of models to aggregate.
Attributes
- predictorobject
Prototype conformal predictor.
- predictorslist
List of underlying conformal predictors.
- samplerobject
Sampler object used to generate training and calibration examples.
- agg_funccallable
Function used to aggregate the predictions of the underlying conformal predictors
References
Examples
Methods
Fit underlying conformal predictors.
Get parameters for this estimator.
Predict the output values for a set of input patterns.
Set the parameters of this estimator.
- fit(x, y)
Fit underlying conformal predictors.
Parameters
- xnumpy array of shape [n_samples, n_features]
Inputs of examples for fitting the underlying conformal predictors.
- ynumpy array of shape [n_samples]
Outputs of examples for fitting the underlying conformal predictors.
Returns
None
- get_params(deep=True)
Get parameters for this estimator.
Parameters
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns
- paramsdict
Parameter names mapped to their values.
- predict(x, significance=None)[source]
Predict the output values for a set of input patterns.
Parameters
- xnumpy array of shape [n_samples, n_features]
Inputs of patters for which to predict output values.
- significancefloat or None
Significance level (maximum allowed error rate) of predictions. Should be a float between 0 and 1. If
None
, then the p-values are output rather than the predictions. Note:significance=None
is applicable to classification problems only.
Returns
- pnumpy array of shape [n_samples, n_classes] or [n_samples, 2]
For classification problems: If significance is
None
, then p contains the p-values for each sample-class pair; if significance is a float between 0 and 1, then p is a boolean array denoting which labels are included in the prediction sets.For regression problems: Prediction interval (minimum and maximum boundaries) for the set of test patterns.
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.Parameters
- **paramsdict
Estimator parameters.
Returns
- selfestimator instance
Estimator instance.