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.

Copy Link

Version

Install

install.packages('utiml')

Monthly Downloads

193

Version

0.1.4

License

GPL | file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Adriano Rivolli

Last Published

April 20th, 2018

Functions in utiml (0.1.4)

as.matrix.mlresult

Convert a mlresult to matrix
dbr

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

Ensemble of Binary Relevance for multi-label Classification
fixed_threshold

Apply a fixed threshold in the results
foodtruck

Foodtruck multi-label dataset.
mbr

Meta-BR or 2BR for multi-label Classification
mcut_threshold

Maximum Cut Thresholding (MCut)
brplus

BR+ or BRplus for multi-label Classification
cc

Classifier Chains for multi-label Classification
multilabel_prediction

Create a mlresult object
normalize_mldata

Normalize numerical attributes
predict.CTRLmodel

Predict Method for CTRL
predict.DBRmodel

Predict Method for DBR
ctrl

CTRL model for multi-label Classification
cv

Multi-label cross-validation
is.probability

Test if a mlresult contains score values as default
lcard_threshold

Threshold based on cardinality
predict.LPmodel

Predict Method for Label Powerset
mlknn

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

Pruned Problem Transformation for multi-label Classification
mlpredict

Prediction transformation problems
predict.MBRmodel

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

Print CC model
predict.BASELINEmodel

Predict Method for BASELINE
predict.EPSmodel

Predict Method for Ensemble of Pruned Set Transformation
as.probability

Convert a mlresult to a probability matrix
as.ranking

Convert a mlresult to a ranking matrix
create_kfold_partition

Create the k-folds partition based on the specified algorithm
print.CLRmodel

Print CLR model
create_holdout_partition

Create a holdout partition based on the specified algorithm
print.PPTmodel

Print PPT model
print.RAkELmodel

Print RAkEL model
homer

Hierarchy Of Multilabel classifiER (HOMER)
print.NSmodel

Print NS model
print.RDBRmodel

Print RDBR model
is.bipartition

Test if a mlresult contains crisp values as default
mltrain

Build transformation models
predict.ESLmodel

Predict Method for Ensemble of Single Label
multilabel_confusion_matrix

Compute the confusion matrix for a multi-label prediction
pcut_threshold

Proportional Thresholding (PCut)
predict.PruDentmodel

Predict Method for PruDent
+.mlconfmat

Join two multi-label confusion matrix
predict.RAkELmodel

Predict Method for RAkEL
remove_unique_attributes

Remove unique attributes
print.EBRmodel

Print EBR model
remove_unlabeled_instances

Remove examples without labels
subset_correction

Subset Correction of a predicted result
print.ECCmodel

Print ECC model
predict.EBRmodel

Predict Method for Ensemble of Binary Relevance
print.EPSmodel

Print EPS model
print.ESLmodel

Print ESL model
summary.mltransformation

Summary method for mltransformation
predict.ECCmodel

Predict Method for Ensemble of Classifier Chains
as.bipartition

Convert a mlresult to a bipartition matrix
as.matrix.mlconfmat

Convert a multi-label Confusion Matrix to matrix
clr

Calibrated Label Ranking (CLR) for multi-label Classification
predict.PPTmodel

Predict Method for Pruned Problem Transformation
compute_multilabel_predictions

Compute the multi-label ensemble predictions based on some vote schema
ecc

Ensemble of Classifier Chains for multi-label Classification
print.RPCmodel

Print RPC model
predict.PSmodel

Predict Method for Pruned Set Transformation
print.kFoldPartition

Print a kFoldPartition object
rcut_threshold

Rank Cut (RCut) threshold method
rakel

Random k-labelsets for multilabel classification
print.CTRLmodel

Print CTRL model
eps

Ensemble of Pruned Set for multi-label Classification
lift

LIFT for multi-label Classification
lp

Label Powerset for multi-label Classification
print.DBRmodel

Print DBR model
multilabel_evaluate

Evaluate multi-label predictions
print.PSmodel

Print PS model
print.PruDentmodel

Print PruDent model
multilabel_measures

Return the name of all measures
predict.BRmodel

Predict Method for Binary Relevance
predict.BRPmodel

Predict Method for BR+ (brplus)
print.majorityModel

Print Majority model
print.mlconfmat

Print a Multi-label Confusion Matrix
predict.MLKNNmodel

Predict Method for ML-KNN
predict.NSmodel

Predict Method for Nested Stacking
rdbr

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

Baseline reference for multilabel classification
br

Binary Relevance for multi-label Classification
remove_attributes

Remove attributes from the dataset
predict.RDBRmodel

Predict Method for RDBR
scut_threshold

SCut Score-based method
create_random_subset

Create a random subset of a dataset
create_subset

Create a subset of a dataset
[.mlresult

Filter a Multi-Label Result
esl

Ensemble of Single Label
fill_sparse_mldata

Fill sparse dataset with 0 or '' values
predict.RPCmodel

Predict Method for RPC
print.LIFTmodel

Print LIFT model
print.LPmodel

Print LP model
prudent

PruDent classifier for multi-label Classification
ps

Pruned Set for multi-label Classification
merge_mlconfmat

Join a list of multi-label confusion matrix
mldata

Fix the mldr dataset to use factors
remove_labels

Remove labels from the dataset
remove_skewness_labels

Remove unusual or very common labels
ns

Nested Stacking for multi-label Classification
partition_fold

Create the multi-label dataset from folds
predict.CCmodel

Predict Method for Classifier Chains
predict.CLRmodel

Predict Method for CLR
predict.HOMERmodel

Predict Method for HOMER
predict.LIFTmodel

Predict Method for LIFT
print.BRPmodel

Print BRP model
print.BRmodel

Print BR model
print.MBRmodel

Print MBR model
print.MLKNNmodel

Print MLKNN model
print.mlresult

Print the mlresult
print.randomModel

Print Random model
replace_nominal_attributes

Replace nominal attributes Replace the nominal attributes by binary attributes.
rpc

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

utiml: Utilities for Multi-Label Learning
toyml

Toy multi-label dataset.
as.mlresult

Convert a matrix prediction in a multi label prediction