mlleran is a python library for multi-label classification bulti on scikit-learn and numpy.
The implementation is based on the paper A Review on Multi-Label Learning Algorithms, and the implementated algorithms include:
Problem Transformation
- Binary Relevance
- Classifier Chains
- Calibrated Label Ranking
- Random k-Labelsets
Algorithm Adaptation
- Multi-Label k-Nearest Neighbor
- Multi-Label Decision Tree
- Ranking Support Vector Machine
- Collective Multi-Label Classifier
pip install mllearn
Note: Support Python3 only.
All data type should be ndarray
, especially y should be the binary format. For example, if your dataset totally have 5 labels and one of your samples has only first and last labels, then the corresponding output should be [1, 0, 0, 0, 1]
.
samples, features = X_train.shape
samples, labels = y_train.shape
samples_test, features = X_test.shape
samples_test, labels = y_test.shape
You can also find multi-label dataset provided by Mulan here.
This library includes 2 parts, algorithms and metrics.
from mllearn.problem_transform import BinaryRelevance
classif = BinaryRelevance()
classif.fit(X_train, y_train)
predictions = classif.predict(X_test)
from mllearn.metrics import subset_acc
acc = subset_acc(y_test, predictions)