Learn R Programming

⚠️There's a newer version (0.1.7) of this package.Take me there.

utiml: Utilities for Multi-label Learning

The utiml package is a framework to support multi-label processing, like Mulan on Weka.

The main methods available on this package are organized in the groups:

  • Classification methods
  • Evaluation methods
  • Pre-process utilities
  • Sampling methods
  • Threshold methods

Instalation

The installation process is similar to other packages available on CRAN:

install.packages("utiml")

This will also install mldr. To run the examples in this document, you also need to install the packages:

# Base classifiers (SVM and Random Forest)
install.packages(c("e1071", "randomForest"))

Install via github (development version)

devtools::install_github("rivolli/utiml")

Multi-label Classification

Running Binary Relevance Method

library(utiml)

# Create two partitions (train and test) of toyml multi-label dataset
ds <- create_holdout_partition(toyml, c(train=0.65, test=0.35))

# Create a Binary Relevance Model using e1071::svm method
brmodel <- br(ds$train, "SVM", seed=123)

# Predict
prediction <- predict(brmodel, ds$test)

# Show the predictions
head(as.bipartition(prediction))
head(as.ranking(prediction))

# Apply a threshold
newpred <- rcut_threshold(prediction, 2)

# Evaluate the models
result <- multilabel_evaluate(ds$tes, prediction, "bipartition")
thresres <- multilabel_evaluate(ds$tes, newpred, "bipartition")

# Print the result
print(round(cbind(Default=result, RCUT=thresres), 3))

Running Ensemble of Classifier Chains

library(utiml)

# Create three partitions (train, val, test) of emotions dataset
partitions <- c(train = 0.6, val = 0.2, test = 0.2)
ds <- create_holdout_partition(emotions, partitions, method="iterative")

# Create an Ensemble of Classifier Chains using Random Forest (randomForest package)
eccmodel <- ecc(ds$train, "RF", m=3, cores=parallel::detectCores(), seed=123)

# Predict
val <- predict(eccmodel, ds$val, cores=parallel::detectCores())
test <- predict(eccmodel, ds$test, cores=parallel::detectCores())

# Apply a threshold
thresholds <- scut_threshold(val, ds$val, cores=parallel::detectCores())
new.val <- fixed_threshold(val, thresholds)
new.test <- fixed_threshold(test, thresholds)

# Evaluate the models
measures <- c("subset-accuracy", "F1", "hamming-loss", "macro-based") 

result <- cbind(
  Test = multilabel_evaluate(ds$tes, test, measures),
  TestWithThreshold = multilabel_evaluate(ds$tes, new.test, measures),
  Validation = multilabel_evaluate(ds$val, val, measures),
  ValidationWithThreshold = multilabel_evaluate(ds$val, new.val, measures)
)

print(round(result, 3))

More examples and details are available on functions documentations and vignettes, please refer to the documentation.

How to cite?

@article{RJ-2018-041,
  author = {Adriano Rivolli and Andre C. P. L. F. de Carvalho},
  title = {{The utiml Package: Multi-label Classification in R}},
  year = {2018},
  journal = {{The R Journal}},
  doi = {10.32614/RJ-2018-041},
  url = {https://doi.org/10.32614/RJ-2018-041},
  pages = {24--37},
  volume = {10},
  number = {2}
}

Copy Link

Version

Install

install.packages('utiml')

Monthly Downloads

193

Version

0.1.6

License

GPL | file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Adriano Rivolli

Last Published

February 7th, 2020

Functions in utiml (0.1.6)

as.matrix.mlconfmat

Convert a multi-label Confusion Matrix to matrix
br

Binary Relevance for multi-label Classification
dbr

Dependent Binary Relevance (DBR) for multi-label Classification
baseline

Baseline reference for multilabel classification
ebr

Ensemble of Binary Relevance for multi-label Classification
fixed_threshold

Apply a fixed threshold in the results
foodtruck

Foodtruck multi-label dataset.
merge_mlconfmat

Join a list of multi-label confusion matrix
pcut_threshold

Proportional Thresholding (PCut)
mldata

Fix the mldr dataset to use factors
brplus

BR+ or BRplus for multi-label Classification
as.matrix.mlresult

Convert a mlresult to matrix
+.mlconfmat

Join two multi-label confusion matrix
cc

Classifier Chains for multi-label Classification
is.probability

Test if a mlresult contains score values as default
multilabel_prediction

Create a mlresult object
normalize_mldata

Normalize numerical attributes
lcard_threshold

Threshold based on cardinality
mcut_threshold

Maximum Cut Thresholding (MCut)
mbr

Meta-BR or 2BR for multi-label Classification
predict.CCmodel

Predict Method for Classifier Chains
as.probability

Convert a mlresult to a probability matrix
clr

Calibrated Label Ranking (CLR) for multi-label Classification
create_random_subset

Create a random subset of a dataset
homer

Hierarchy Of Multilabel classifiER (HOMER)
is.bipartition

Test if a mlresult contains crisp values as default
create_subset

Create a subset of a dataset
as.mlresult

Convert a matrix prediction in a multi label prediction
predict.CLRmodel

Predict Method for CLR
predict.BASELINEmodel

Predict Method for BASELINE
predict.ECCmodel

Predict Method for Ensemble of Classifier Chains
mlknn

Multi-label KNN (ML-KNN) for multi-label Classification
ppt

Pruned Problem Transformation for multi-label Classification
predict.EBRmodel

Predict Method for Ensemble of Binary Relevance
predict.MLKNNmodel

Predict Method for ML-KNN
mlpredict

Prediction transformation problems
predict.NSmodel

Predict Method for Nested Stacking
print.EBRmodel

Print EBR model
predict.MBRmodel

Predict Method for Meta-BR/2BR
print.ECCmodel

Print ECC model
predict.LPmodel

Predict Method for Label Powerset
as.ranking

Convert a mlresult to a ranking matrix
predict.ESLmodel

Predict Method for Ensemble of Single Label
predict.PSmodel

Predict Method for Pruned Set Transformation
predict.PPTmodel

Predict Method for Pruned Problem Transformation
predict.EPSmodel

Predict Method for Ensemble of Pruned Set Transformation
print.CCmodel

Print CC model
print.CLRmodel

Print CLR model
print.MBRmodel

Print MBR model
print.DBRmodel

Print DBR model
print.CTRLmodel

Print CTRL model
ctrl

CTRL model for multi-label Classification
cv

Multi-label cross-validation
compute_multilabel_predictions

Compute the multi-label ensemble predictions based on some vote schema
print.MLKNNmodel

Print MLKNN model
print.NSmodel

Print NS model
remove_unique_attributes

Remove unique attributes
print.mlresult

Print the mlresult
print.randomModel

Print Random model
scut_threshold

SCut Score-based method
remove_unlabeled_instances

Remove examples without labels
[.mlresult

Filter a Multi-Label Result
print.EPSmodel

Print EPS model
print.PPTmodel

Print PPT model
print.RPCmodel

Print RPC model
print.ESLmodel

Print ESL model
print.majorityModel

Print Majority model
esl

Ensemble of Single Label
print.kFoldPartition

Print a kFoldPartition object
rpc

Ranking by Pairwise Comparison (RPC) for multi-label Classification
replace_nominal_attributes

Replace nominal attributes Replace the nominal attributes by binary attributes.
print.mlconfmat

Print a Multi-label Confusion Matrix
mltrain

Build transformation models
fill_sparse_mldata

Fill sparse dataset with 0 or '' values
multilabel_confusion_matrix

Compute the confusion matrix for a multi-label prediction
ns

Nested Stacking for multi-label Classification
eps

Ensemble of Pruned Set for multi-label Classification
ecc

Ensemble of Classifier Chains for multi-label Classification
lift

LIFT for multi-label Classification
partition_fold

Create the multi-label dataset from folds
lp

Label Powerset for multi-label Classification
rdbr

Recursive Dependent Binary Relevance (RDBR) for multi-label Classification
multilabel_evaluate

Evaluate multi-label predictions
remove_attributes

Remove attributes from the dataset
predict.RDBRmodel

Predict Method for RDBR
predict.BRPmodel

Predict Method for BR+ (brplus)
predict.RPCmodel

Predict Method for RPC
predict.HOMERmodel

Predict Method for HOMER
predict.LIFTmodel

Predict Method for LIFT
predict.BRmodel

Predict Method for Binary Relevance
print.PSmodel

Print PS model
print.PruDentmodel

Print PruDent model
multilabel_measures

Return the name of all measures
ps

Pruned Set for multi-label Classification
remove_labels

Remove labels from the dataset
prudent

PruDent classifier for multi-label Classification
remove_skewness_labels

Remove unusual or very common labels
subset_correction

Subset Correction of a predicted result
summary.mltransformation

Summary method for mltransformation
predict.CTRLmodel

Predict Method for CTRL
print.LIFTmodel

Print LIFT model
print.BRmodel

Print BR model
print.LPmodel

Print LP model
predict.DBRmodel

Predict Method for DBR
predict.PruDentmodel

Predict Method for PruDent
print.BRPmodel

Print BRP model
predict.RAkELmodel

Predict Method for RAkEL
rakel

Random k-labelsets for multilabel classification
print.RAkELmodel

Print RAkEL model
print.RDBRmodel

Print RDBR model
rcut_threshold

Rank Cut (RCut) threshold method
toyml

Toy multi-label dataset.
utiml

utiml: Utilities for Multi-Label Learning
as.bipartition

Convert a mlresult to a bipartition matrix
create_holdout_partition

Create a holdout partition based on the specified algorithm
create_kfold_partition

Create the k-folds partition based on the specified algorithm