SimpleArgmaxAverage

class proglearn.SimpleArgmaxAverage(classes=[])[source]

A class for a decider that uses the average vote for classification.

Parameters

classes : list, default=[]

List of final output classification labels of type obj.

Attributes

transformer_id_to_transformers_

(dict) A dictionary with keys of type obj corresponding to transformer ids and values of type obj corresponding to a transformer. This dictionary maps transformers to a particular transformer id.

transformer_id_to_voters_

(dict) A dictionary with keys of type obj corresponding to transformer ids and values of type obj corresponding to a voter class. This dictionary maps voter classes to a particular transformer id.

Methods Summary

SimpleArgmaxAverage.fit(X, y, ...)

Function for fitting.

SimpleArgmaxAverage.get_params([deep])

Get parameters for this estimator.

SimpleArgmaxAverage.predict(X[, transformer_ids])

Predicts the most likely class per input example.

SimpleArgmaxAverage.predict_proba(X[, ...])

Predicts posterior probabilities per input example.

SimpleArgmaxAverage.score(X, y[, sample_weight])

Return the mean accuracy on the given test data and labels.

SimpleArgmaxAverage.set_params(**params)

Set the parameters of this estimator.


SimpleArgmaxAverage.fit(X, y, transformer_id_to_transformers, transformer_id_to_voters)[source]

Function for fitting. Stores attributes (classes, transformer_id_to_transformers, and transformer_id_to_voters) of a ClassificationDecider.

Returns

self : SimpleArgmaxAverage

The object itself.

Raises

ValueError

When the labels have not been provided and the classes are empty.

SimpleArgmaxAverage.get_params(deep=True)

Get parameters for this estimator.

Parameters

deep : bool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

params : dict

Parameter names mapped to their values.

SimpleArgmaxAverage.predict(X, transformer_ids=None)[source]

Predicts the most likely class per input example.

Uses the predict_proba method to get the mean vote per id. Returns the class with the highest vote.

Parameters

X : ndarray

Input data matrix.

transformer_ids : list, default=None

A list with all transformer ids. Defaults to None if no transformer ids are given.

Returns

y_hat : ndarray of shape [n_samples]

predicted class label per example

Raises

NotFittedError

When the model is not fitted.

SimpleArgmaxAverage.predict_proba(X, transformer_ids=None)[source]

Predicts posterior probabilities per input example.

Loops through each transformer and bag of transformers. Performs a transformation of the input data with the transformer. Gets a voter to map the transformed input data into a posterior distribution. Gets the mean vote per bagging component and append it to a vote per transformer id. Returns the aggregate average vote.

Parameters

X : ndarray

Input data matrix.

transformer_ids : list, default=None

A list with specific transformer ids that will be used for inference. Defaults to using all transformers if no transformer ids are given.

Returns

y_proba_hat : ndarray of shape [n_samples, n_classes]

posteriors per example

Raises

NotFittedError

When the model is not fitted.

SimpleArgmaxAverage.score(X, y, sample_weight=None)

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters

X : array-like of shape (n_samples, n_features)

Test samples.

y : array-like of shape (n_samples,) or (n_samples, n_outputs)

True labels for X.

sample_weight : array-like of shape (n_samples,), default=None

Sample weights.

Returns

score : float

Mean accuracy of self.predict(X) wrt. y.

SimpleArgmaxAverage.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

**params : dict

Estimator parameters.

Returns

self : estimator instance

Estimator instance.