quantificationlib.estimators.ensembles module¶
Estimators for an Ensemble of Quantifiers
- class EnsembleOfClassifiers(base_estimator=None, n_jobs=None, verbose=0)[source]¶
Bases:
BaseEstimator
,ClassifierMixin
Ensemble of Classifiers
This kind of objects train the set of classifiers for an ensemble of quantifiers
- Parameters:
base_estimator (estimator object (default=None)) – An estimator object implementing fit and one of predict or predict_proba. It is the base estimator used to learn the set of classifiers
n_jobs (int or None, optional (default=None)) – The number of jobs to use for the computation.
None
means 1 unless in ajoblib.parallel_backend
context.-1
means using all processorsverbose (int, optional, (default=0)) – The verbosity level. The default value, zero, means silent mode
- base_estimator¶
The base estimator used to build ensemble
- Type:
estimator object
- n_jobs¶
The number of jobs to use for the computation.
- Type:
int or None,
- verbose¶
The verbosity level. The default value, zero, means silent mode
- Type:
int
- classes_¶
Class labels
- Type:
ndarray, shape (n_classes, )
- n_estimators_¶
Number of estimators
- Type:
int,
- estimators_¶
List of estimators
- Type:
ndarray, shape(n_ensembles, )
References
Pérez-Gállego, P., Quevedo, J. R., & del Coz, J. J. (2017). Using ensembles for problems with characterizable changes in data distribution: A case study on quantification. Information Fusion, 34, 87-100.
Pérez-Gállego, P., Castano, A., Quevedo, J. R., & del Coz, J. J. (2019). Dynamic ensemble selection for quantification tasks. Information Fusion, 45, 1-15.
- fit(X, y, indexes)[source]¶
Fits the set of estimators for the training set (X, y) using the bags contained in indexes
- Parameters:
X ((sparse) array-like, shape (n_examples, n_features)) – Data
y ((sparse) array-like, shape (n_examples, )) – True classes
indexes (array-like, shape (n_ensembles, bag_size)) – i-th row contains the indexes of the examples in (X, y) that must be used to train i-th estimator
- Raises:
ValueError – When base_estimator is None
- predict(X)[source]¶
Predict the class for each testing example applying each estimator
- Parameters:
X ((sparse) array-like, shape (n_examples, n_features)) – Data
- Returns:
preds – The predicted class for each example with each estimator
- Return type:
array-like, shape(n_examples, n_estimators)
- Raises:
NotFittedError – When the estimators are not fitted yet
- predict_proba(X)[source]¶
Predict the class probabilities for each example `
- Parameters:
X ((sparse) array-like, shape (n_examples, n_features)) – Data
- Returns:
preds – The posterior probability for each example and for each class with each estimator
- Return type:
array-like, shape(n_examples, n_estimators)
- Raises:
NotFittedError – When the estimators are not fitted yet
- set_fit_request(*, indexes='$UNCHANGED$')¶
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline
. Otherwise it has no effect.- Parameters:
indexes (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
indexes
parameter infit
.self (EnsembleOfClassifiers) –
- Returns:
self – The updated object.
- Return type:
object
- set_score_request(*, sample_weight='$UNCHANGED$')¶
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline
. Otherwise it has no effect.- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weight
parameter inscore
.self (EnsembleOfClassifiers) –
- Returns:
self – The updated object.
- Return type:
object