Aggregation

This file contains the implementation of different aggregation functions to combine the outputs of the base classifiers to give the final decision.

deslib.util.aggregation.average_combiner(classifier_ensemble, X)[source]

Ensemble combination using the Average rule.

Parameters:
classifier_ensemble : list of shape = [n_classifiers]

Containing the ensemble of classifiers used in the aggregation scheme.

X : array of shape (n_samples, n_features)

The input data.

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.average_rule(predictions)[source]

Apply the average fusion rule to the predicted vector of class supports (predictions).

Parameters:
predictions : np array of shape (n_samples, n_classifiers, n_classes)

Vector of class supports predicted by each base classifier for sample

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.majority_voting(classifier_ensemble, X)[source]

Apply the majority voting rule to predict the label of each sample in X.

Parameters:
classifier_ensemble : list of shape = [n_classifiers]

Containing the ensemble of classifiers used in the aggregation scheme.

X : array of shape (n_samples, n_features)

The input data.

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.majority_voting_rule(votes)[source]

Applies the majority voting rule to the estimated votes.

Parameters:
votes : array of shape (n_samples, n_classifiers),

The votes obtained by each classifier for each sample.

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.maximum_combiner(classifier_ensemble, X)[source]

Ensemble combination using the Maximum rule.

Parameters:
classifier_ensemble : list of shape = [n_classifiers]

Containing the ensemble of classifiers used in the aggregation scheme.

X : array of shape (n_samples, n_features)

The input data.

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.maximum_rule(predictions)[source]

Apply the product fusion rule to the predicted vector of class supports (predictions).

Parameters:
predictions : np array of shape (n_samples, n_classifiers, n_classes)

Vector of class supports predicted by each base classifier for sample

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.median_combiner(classifier_ensemble, X)[source]

Ensemble combination using the Median rule.

Parameters:
classifier_ensemble : list of shape = [n_classifiers]

Containing the ensemble of classifiers used in the aggregation scheme.

X : array of shape (n_samples, n_features)

The input data.

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.median_rule(predictions)[source]

Apply the product fusion rule to the predicted vector of class supports (predictions).

Parameters:
predictions : np array of shape (n_samples, n_classifiers, n_classes)

Vector of class supports predicted by each base classifier for sample

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.minimum_combiner(classifier_ensemble, X)[source]

Ensemble combination using the Minimum rule.

Parameters:
classifier_ensemble : list of shape = [n_classifiers]

Containing the ensemble of classifiers used in the aggregation scheme.

X : array of shape (n_samples, n_features)

The input data.

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.minimum_rule(predictions)[source]

Apply the product fusion rule to the predicted vector of class supports (predictions).

Parameters:
predictions : np array of shape (n_samples, n_classifiers, n_classes)

Vector of class supports predicted by each base classifier for sample

Returns:
list_proba : array of shape = [n_classifiers, n_samples, n_classes]

Probabilities predicted by each base classifier in the ensemble for all samples in X.

deslib.util.aggregation.predict_proba_ensemble(classifier_ensemble, X, estimator_features=None)[source]

Estimates the posterior probabilities of the give ensemble for each sample in X.

Parameters:
classifier_ensemble : list of shape = [n_classifiers]

Containing the ensemble of classifiers used in the aggregation scheme.

X : array of shape (n_samples, n_features)

The input data.

estimator_features : array of shape (n_classifiers, n_selected_features)

Indices containing the features used by each classifier.

Returns:
predicted_proba : array of shape (n_samples, n_classes)

Posterior probabilities estimates for each samples in X.

deslib.util.aggregation.product_combiner(classifier_ensemble, X)[source]

Ensemble combination using the Product rule.

Parameters:
classifier_ensemble : list of shape = [n_classifiers]

Containing the ensemble of classifiers used in the aggregation scheme.

X : array of shape (n_samples, n_features)

The input data.

Returns:
predicted_label : array of shape = [n_classifiers, n_samples, n_classes]

Probabilities predicted by each base classifier in the ensemble for all samples in X.

deslib.util.aggregation.product_rule(predictions)[source]

Apply the product fusion rule to the predicted vector of class supports (predictions).

Parameters:
predictions : array of shape (n_samples, n_classifiers, n_classes)

Vector of class supports predicted by each base classifier for sample

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.sum_votes_per_class(predictions, n_classes)[source]

Sum the number of votes for each class. Accepts masked arrays as input.

Parameters:
predictions : array of shape (n_samples, n_classifiers),

The votes obtained by each classifier for each sample. Can be a masked array.

n_classes : int

Number of classes.

Returns:
summed_votes : array of shape (n_samples, n_classes)

Summation of votes for each class

deslib.util.aggregation.weighted_majority_voting(classifier_ensemble, weights, X)[source]

Apply the weighted majority voting rule to predict the label of each sample in X. The size of the weights vector should be equal to the size of the ensemble.

Parameters:
classifier_ensemble : list of shape = [n_classifiers]

Containing the ensemble of classifiers used in the aggregation scheme.

weights : array of shape (n_samples, n_classifiers)

Weights associated to each base classifier for each sample

X : array of shape (n_samples, n_features)

The input data.

Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule

deslib.util.aggregation.weighted_majority_voting_rule(votes, weights, labels_set=None)[source]

Applies the weighted majority voting rule based on the votes obtained by each base classifier and their respective weights.

Parameters:
votes : array of shape (n_samples, n_classifiers),

The votes obtained by each classifier for each sample.

weights : array of shape (n_samples, n_classifiers)

Weights associated to each base classifier for each sample

labels_set : (Default=None) set with the possible classes in the problem.
Returns:
predicted_label : array of shape (n_samples)

The label of each query sample predicted using the majority voting rule