TreeClassificationVoter

class proglearn.TreeClassificationVoter(kappa=inf, classes=[])[source]

A class used to vote on data transformed under a tree, which inherits from the BaseClassificationVoter class in base.py.

Parameters

kappa : float

coefficient for finite sample correction If set to default, no finite sample correction is performed.

classes : list, default=[]

list of all possible output label values

Attributes

missing_label_indices_

(list) a (potentially empty) list of label values that exist in the classes parameter but are missing in the latest fit function call

uniform_posterior_

(ndarray of shape (n_classes,)) the uniform posterior associated with the

Methods Summary

TreeClassificationVoter.fit(X, y)

Fits transformed data X given corresponding class labels y.

TreeClassificationVoter.get_params([deep])

Get parameters for this estimator.

TreeClassificationVoter.predict(X)

Returns the predicted class labels for data X.

TreeClassificationVoter.predict_proba(X)

Returns the posterior probabilities of each class for data X.

TreeClassificationVoter.score(X, y[, ...])

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

TreeClassificationVoter.set_params(**params)

Set the parameters of this estimator.


TreeClassificationVoter.fit(X, y)[source]

Fits transformed data X given corresponding class labels y.

Parameters

X : array of shape [n_samples, n_features]

the transformed input data

y : array of shape [n_samples]

the class labels

Returns

self : TreeClassificationVoter

The object itself.

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

TreeClassificationVoter.predict(X)[source]

Returns the predicted class labels for data X.

Parameters

X : array of shape [n_samples, n_features]

the transformed input data

Returns

y_hat : ndarray of shape [n_samples]

predicted class label per example

Raises

NotFittedError

When the model is not fitted.

TreeClassificationVoter.predict_proba(X)[source]

Returns the posterior probabilities of each class for data X.

Parameters

X : array of shape [n_samples, n_features]

the transformed input data

Returns

y_proba_hat : ndarray of shape [n_samples, n_classes]

posteriors per example

Raises

NotFittedError

When the model is not fitted.

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

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