kindred.MultiLabelClassifier

class kindred.MultiLabelClassifier(classifier, **kwargs)[source]

Wrapper for a set of classifiers that can behave as a multi-label classifier. Multi-label means that each data point can have multiple labels (or belong to multiple classes). This is particularly relevant in text mining where two words can belong to multiple relations. This class just creates a classifier for each label and runs then together, concatenating the results into a nice matrix form

Methods

__init__(classifier, **kwargs)[source]

Create a classifier that can handle multiple labels using multiple instance of the supplied classifier class. Any additional parameters are passed onto the classifier.

Parameters:classifier (class with fit/predict) – The type of classifier to use
fit(X, Y)[source]

Fit multiple classifiers for the number of labels provided

Parameters:
  • X (matrix) – Training matrix (with n_samples rows and n_features columns)
  • Y (matrix) – Target matrix (with n_samples rows and n_labels columns)
has_predict_proba()[source]

Returns whether the underlying classifier has the predict_proba method

Returns:Whether classifier has predict_proba method
Return type:bool
predict(X)[source]

Predict for multiple labels and return a matrix with predicted labels

Parameters:X (matrix) – Testing matrix (with n_samples rows and n_features columns)
Returns:Predicted binary matrix (with n_samples rows and n_labels columns)
Return type:matrix
predict_proba(X)[source]

Predict for multiple labels and return a matrix with predicted labels. Returns for the probability for the positive class (for each label column) only.

Parameters:X (matrix) – Testing matrix (with n_samples rows and n_features columns)
Returns:Predicted probability matrix (with n_samples rows and n_labels columns)
Return type:matrix