mc_scheme

In this module, multi-class schemes such as One-vs-One and One-vs-All are implemented.

Functions

mc_clf_no_params(bin_clfs) It calculates number of parameters for a multi-class model.

Classes

OneVsAllClassifier(estimator) Multi-class classification using One-vs-One scheme
OneVsOneClassifier(estimator) Multi-class classification using One-vs-One scheme
class mc_scheme.OneVsOneClassifier(estimator)[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.ClassifierMixin

Multi-class classification using One-vs-One scheme

The OneVsOneClassifier is scikit-learn compatible, which means scikit-learn tools such as cross_val_score and GridSearchCV can be used for an instance of OneVsOneClassifier

Parameters:

estimator : estimator object

An estimator object implementing fit and predict.

Attributes

clf_name (str) Name of the classifier.
bin_clf_ (list) Stores intances of each binary TSVM classifier.

Methods

fit(X, y) It fits the OVO-classfier model according to the given training data.
get_params([deep]) Get parameters for this estimator.
predict(X) Performs classification on samples in X using the OVO-classifier model.
score(X, y[, sample_weight]) Return the mean accuracy on the given test data and labels.
set_params(**params) Set the parameters of this estimator.
fit(X, y)[source]

It fits the OVO-classfier model according to the given training data.

Parameters:

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

Training feature vectors, where n_samples is the number of samples and n_features is the number of features.

y : array-like, shape(n_samples,)

Target values or class labels.

Returns:

self : object

predict(X)[source]

Performs classification on samples in X using the OVO-classifier model.

Parameters:

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

Feature vectors of test data.

Returns:

y_pred : array, shape (n_samples,)

Predicted class lables of test data.

class mc_scheme.OneVsAllClassifier(estimator)[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.ClassifierMixin

Multi-class classification using One-vs-One scheme

Parameters:

estimator : estimator object

An estimator object implementing fit and predict.

Attributes

clf_name (str) Name of the classifier.
bin_clf_ (list) Stores intances of each binary TSVM classifier.

Methods

fit(X, y)
Parameters:
get_params([deep]) Get parameters for this estimator.
predict(X) Performs classification on samples in X using the OVO-classifier model.
score(X, y[, sample_weight]) Return the mean accuracy on the given test data and labels.
set_params(**params) Set the parameters of this estimator.
fit(X, y)[source]
Parameters:

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

Training feature vectors, where n_samples is the number of samples and n_features is the number of features.

y : array-like, shape(n_samples,)

Target values or class labels.

Returns:

self : object

predict(X)[source]

Performs classification on samples in X using the OVO-classifier model.

Parameters:

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

Feature vectors of test data.

Returns:

test_labels : array, shape (n_samples,)

Predicted class lables of test data.

mc_scheme.mc_clf_no_params(bin_clfs)[source]

It calculates number of parameters for a multi-class model.

Parameters:

bin_clfs : list

Instances of binary TSVM-based estimators.

Returns:

int

Number of parameters of a multi-class model.