Lxinyuelxy / multi-label-learn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multi-label-learn

mlleran is a python library for multi-label classification bulti on scikit-learn and numpy.

Implementation

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

Installation

pip install mllearn

Note: Support Python3 only.

Data Format

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.

Example Usage

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)

About

License:MIT License


Languages

Language:Python 100.0%