├── data ├── toyml.rda └── foodtruck.rda ├── tests ├── testthat.R ├── testfiles │ ├── flags-measures.csv │ ├── flags-expected.csv │ └── flags-bipartition.csv └── testthat │ ├── test_pairwiseclassifiers.R │ ├── test_othersclassifiers.R │ ├── test_cv.R │ ├── test_internal.R │ ├── test_base_learner.R │ └── test_powersetclassifiers.R ├── .gitignore ├── .Rbuildignore ├── .travis.yml ├── man ├── mldata.Rd ├── print.BRmodel.Rd ├── print.CCmodel.Rd ├── print.LPmodel.Rd ├── print.NSmodel.Rd ├── print.PSmodel.Rd ├── print.BRPmodel.Rd ├── print.CLRmodel.Rd ├── print.DBRmodel.Rd ├── print.EBRmodel.Rd ├── print.ECCmodel.Rd ├── print.EPSmodel.Rd ├── print.ESLmodel.Rd ├── print.MBRmodel.Rd ├── print.PPTmodel.Rd ├── print.RPCmodel.Rd ├── as.bipartition.Rd ├── as.matrix.mlresult.Rd ├── print.LIFTmodel.Rd ├── print.RDBRmodel.Rd ├── as.probability.Rd ├── is.bipartition.Rd ├── is.probability.Rd ├── plus-.mlconfmat.Rd ├── print.MLKNNmodel.Rd ├── print.RAkELmodel.Rd ├── print.randomModel.Rd ├── print.PruDentmodel.Rd ├── print.majorityModel.Rd ├── print.mlresult.Rd ├── print.mlconfmat.Rd ├── print.kFoldPartition.Rd ├── merge_mlconfmat.Rd ├── as.matrix.mlconfmat.Rd ├── summary.mltransformation.Rd ├── multilabel_measures.Rd ├── utiml_measure_names.Rd ├── as.ranking.Rd ├── sub-.mlresult.Rd ├── normalize_mldata.Rd ├── remove_unlabeled_instances.Rd ├── remove_unique_attributes.Rd ├── remove_skewness_labels.Rd ├── fill_sparse_mldata.Rd ├── predict.BASELINEmodel.Rd ├── foodtruck.Rd ├── remove_labels.Rd ├── create_random_subset.Rd ├── remove_attributes.Rd ├── create_subset.Rd ├── replace_nominal_attributes.Rd ├── predict.MLKNNmodel.Rd ├── predict.LPmodel.Rd ├── predict.PSmodel.Rd ├── multilabel_prediction.Rd ├── predict.PPTmodel.Rd ├── predict.HOMERmodel.Rd ├── predict.LIFTmodel.Rd ├── predict.CLRmodel.Rd ├── predict.RPCmodel.Rd ├── predict.RAkELmodel.Rd ├── predict.ESLmodel.Rd ├── partition_fold.Rd ├── predict.CCmodel.Rd ├── predict.MBRmodel.Rd ├── predict.PruDentmodel.Rd ├── predict.EPSmodel.Rd ├── predict.NSmodel.Rd ├── mcut_threshold.Rd ├── as.mlresult.Rd ├── rcut_threshold.Rd ├── predict.BRmodel.Rd ├── lcard_threshold.Rd ├── predict.ECCmodel.Rd ├── predict.EBRmodel.Rd ├── toyml.Rd ├── mlknn.Rd ├── pcut_threshold.Rd ├── subset_correction.Rd ├── lp.Rd ├── fixed_threshold.Rd ├── compute_multilabel_predictions.Rd ├── baseline.Rd ├── create_kfold_partition.Rd ├── rpc.Rd ├── br.Rd ├── predict.DBRmodel.Rd ├── lift.Rd ├── mlpredict.Rd ├── clr.Rd ├── ps.Rd ├── esl.Rd ├── multilabel_confusion_matrix.Rd ├── cv.Rd ├── ns.Rd ├── ppt.Rd ├── brplus.Rd ├── mltrain.Rd ├── homer.Rd ├── multilabel_evaluate.Rd ├── prudent.Rd ├── create_holdout_partition.Rd ├── dbr.Rd ├── rdbr.Rd ├── predict.RDBRmodel.Rd ├── scut_threshold.Rd ├── cc.Rd ├── rakel.Rd ├── eps.Rd ├── predict.BRPmodel.Rd └── ebr.Rd ├── R ├── zzz.R ├── mldr.R ├── data.R └── cross_validation.R ├── utiml.Rproj ├── cran-comments.md ├── DESCRIPTION ├── README.md └── NAMESPACE /data/toyml.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivolli/utiml/HEAD/data/toyml.rda -------------------------------------------------------------------------------- /data/foodtruck.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rivolli/utiml/HEAD/data/foodtruck.rda -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(utiml) 3 | 4 | test_check("utiml") 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | *.save 5 | packrat/lib*/ 6 | inst/doc 7 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^CRAN-RELEASE$ 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | ^README\.Rmd$ 5 | ^cran-comments\.md$ 6 | ^\.travis\.yml$ 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Sample .travis.yml for R projects 2 | 3 | language: r 4 | sudo: required 5 | 6 | # R dependencies 7 | r_packages: 8 | - mldr 9 | 10 | env: 11 | global: 12 | - _R_CHECK_FORCE_SUGGESTS_: false 13 | 14 | warnings_are_errors: true 15 | -------------------------------------------------------------------------------- /man/mldata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mldr.R 3 | \name{mldata} 4 | \alias{mldata} 5 | \title{Fix the mldr dataset to use factors} 6 | \usage{ 7 | mldata(mdata) 8 | } 9 | \arguments{ 10 | \item{mdata}{A mldr dataset.} 11 | } 12 | \value{ 13 | A mldr object 14 | } 15 | \description{ 16 | Fix the mldr dataset to use factors 17 | } 18 | \examples{ 19 | toyml <- mldata(toyml) 20 | } 21 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .onLoad <- function(libname, pkgname) { 2 | op <- options() 3 | op.utiml <- list( 4 | utiml.base.algorithm = "SVM", 5 | utiml.cores = 1, 6 | utiml.seed = NA, 7 | utiml.use.probs = TRUE, 8 | utiml.empty.prediction = FALSE, 9 | utiml.random = sample(1:10) #Random value 10 | ) 11 | toset <- !(names(op.utiml) %in% names(op)) 12 | if (any(toset)) options(op.utiml[toset]) 13 | 14 | invisible() 15 | } 16 | -------------------------------------------------------------------------------- /man/print.BRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_br.R 3 | \name{print.BRmodel} 4 | \alias{print.BRmodel} 5 | \title{Print BR model} 6 | \usage{ 7 | \method{print}{BRmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The br model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print BR model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.CCmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_cc.R 3 | \name{print.CCmodel} 4 | \alias{print.CCmodel} 5 | \title{Print CC model} 6 | \usage{ 7 | \method{print}{CCmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The cc model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print CC model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.LPmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_lp.R 3 | \name{print.LPmodel} 4 | \alias{print.LPmodel} 5 | \title{Print LP model} 6 | \usage{ 7 | \method{print}{LPmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The lp model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print LP model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.NSmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ns.R 3 | \name{print.NSmodel} 4 | \alias{print.NSmodel} 5 | \title{Print NS model} 6 | \usage{ 7 | \method{print}{NSmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The ns model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print NS model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.PSmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ps.R 3 | \name{print.PSmodel} 4 | \alias{print.PSmodel} 5 | \title{Print PS model} 6 | \usage{ 7 | \method{print}{PSmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The ps model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print PS model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.BRPmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_brplus.R 3 | \name{print.BRPmodel} 4 | \alias{print.BRPmodel} 5 | \title{Print BRP model} 6 | \usage{ 7 | \method{print}{BRPmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The brp model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print BRP model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.CLRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_clr.R 3 | \name{print.CLRmodel} 4 | \alias{print.CLRmodel} 5 | \title{Print CLR model} 6 | \usage{ 7 | \method{print}{CLRmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The br model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print CLR model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.DBRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_dbr.R 3 | \name{print.DBRmodel} 4 | \alias{print.DBRmodel} 5 | \title{Print DBR model} 6 | \usage{ 7 | \method{print}{DBRmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The dbr model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print DBR model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.EBRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ebr.R 3 | \name{print.EBRmodel} 4 | \alias{print.EBRmodel} 5 | \title{Print EBR model} 6 | \usage{ 7 | \method{print}{EBRmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The ebr model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print EBR model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.ECCmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ecc.R 3 | \name{print.ECCmodel} 4 | \alias{print.ECCmodel} 5 | \title{Print ECC model} 6 | \usage{ 7 | \method{print}{ECCmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The ecc model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print ECC model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.EPSmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_eps.R 3 | \name{print.EPSmodel} 4 | \alias{print.EPSmodel} 5 | \title{Print EPS model} 6 | \usage{ 7 | \method{print}{EPSmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The ps model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print EPS model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.ESLmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_esl.R 3 | \name{print.ESLmodel} 4 | \alias{print.ESLmodel} 5 | \title{Print ESL model} 6 | \usage{ 7 | \method{print}{ESLmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The esl model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print ESL model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.MBRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_mbr.R 3 | \name{print.MBRmodel} 4 | \alias{print.MBRmodel} 5 | \title{Print MBR model} 6 | \usage{ 7 | \method{print}{MBRmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The mbr model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print MBR model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.PPTmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ppt.R 3 | \name{print.PPTmodel} 4 | \alias{print.PPTmodel} 5 | \title{Print PPT model} 6 | \usage{ 7 | \method{print}{PPTmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The ppt model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print PPT model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.RPCmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_rpc.R 3 | \name{print.RPCmodel} 4 | \alias{print.RPCmodel} 5 | \title{Print RPC model} 6 | \usage{ 7 | \method{print}{RPCmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The br model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print RPC model 19 | } 20 | -------------------------------------------------------------------------------- /man/as.bipartition.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{as.bipartition} 4 | \alias{as.bipartition} 5 | \title{Convert a mlresult to a bipartition matrix} 6 | \usage{ 7 | as.bipartition(mlresult) 8 | } 9 | \arguments{ 10 | \item{mlresult}{The mlresult object} 11 | } 12 | \value{ 13 | matrix with bipartition values 14 | } 15 | \description{ 16 | Convert a mlresult to a bipartition matrix 17 | } 18 | -------------------------------------------------------------------------------- /man/as.matrix.mlresult.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{as.matrix.mlresult} 4 | \alias{as.matrix.mlresult} 5 | \title{Convert a mlresult to matrix} 6 | \usage{ 7 | \method{as.matrix}{mlresult}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The mlresult object} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | matrix 16 | } 17 | \description{ 18 | Convert a mlresult to matrix 19 | } 20 | -------------------------------------------------------------------------------- /man/print.LIFTmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_lift.R 3 | \name{print.LIFTmodel} 4 | \alias{print.LIFTmodel} 5 | \title{Print LIFT model} 6 | \usage{ 7 | \method{print}{LIFTmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The lift model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print LIFT model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.RDBRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_rdbr.R 3 | \name{print.RDBRmodel} 4 | \alias{print.RDBRmodel} 5 | \title{Print RDBR model} 6 | \usage{ 7 | \method{print}{RDBRmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The rdbr model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print RDBR model 19 | } 20 | -------------------------------------------------------------------------------- /man/as.probability.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{as.probability} 4 | \alias{as.probability} 5 | \title{Convert a mlresult to a probability matrix} 6 | \usage{ 7 | as.probability(mlresult) 8 | } 9 | \arguments{ 10 | \item{mlresult}{The mlresult object} 11 | } 12 | \value{ 13 | matrix with probabilities values 14 | } 15 | \description{ 16 | Convert a mlresult to a probability matrix 17 | } 18 | -------------------------------------------------------------------------------- /man/is.bipartition.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{is.bipartition} 4 | \alias{is.bipartition} 5 | \title{Test if a mlresult contains crisp values as default} 6 | \usage{ 7 | is.bipartition(mlresult) 8 | } 9 | \arguments{ 10 | \item{mlresult}{The mlresult object} 11 | } 12 | \value{ 13 | logical value 14 | } 15 | \description{ 16 | Test if a mlresult contains crisp values as default 17 | } 18 | -------------------------------------------------------------------------------- /man/is.probability.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{is.probability} 4 | \alias{is.probability} 5 | \title{Test if a mlresult contains score values as default} 6 | \usage{ 7 | is.probability(mlresult) 8 | } 9 | \arguments{ 10 | \item{mlresult}{The mlresult object} 11 | } 12 | \value{ 13 | logical value 14 | } 15 | \description{ 16 | Test if a mlresult contains score values as default 17 | } 18 | -------------------------------------------------------------------------------- /man/plus-.mlconfmat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/evaluation.R 3 | \name{+.mlconfmat} 4 | \alias{+.mlconfmat} 5 | \title{Join two multi-label confusion matrix} 6 | \usage{ 7 | \method{+}{mlconfmat}(mlcm1, mlcm2) 8 | } 9 | \arguments{ 10 | \item{mlcm1}{A mlconfmat} 11 | 12 | \item{mlcm2}{Other mlconfmat} 13 | } 14 | \value{ 15 | mlconfmat 16 | } 17 | \description{ 18 | Join two multi-label confusion matrix 19 | } 20 | -------------------------------------------------------------------------------- /man/print.MLKNNmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_mlknn.R 3 | \name{print.MLKNNmodel} 4 | \alias{print.MLKNNmodel} 5 | \title{Print MLKNN model} 6 | \usage{ 7 | \method{print}{MLKNNmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The mlknn model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print MLKNN model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.RAkELmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_rakel.R 3 | \name{print.RAkELmodel} 4 | \alias{print.RAkELmodel} 5 | \title{Print RAkEL model} 6 | \usage{ 7 | \method{print}{RAkELmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The rakel model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print RAkEL model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.randomModel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/base_learner.R 3 | \name{print.randomModel} 4 | \alias{print.randomModel} 5 | \title{Print Random model} 6 | \usage{ 7 | \method{print}{randomModel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The base model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print Random model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.PruDentmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_prudent.R 3 | \name{print.PruDentmodel} 4 | \alias{print.PruDentmodel} 5 | \title{Print PruDent model} 6 | \usage{ 7 | \method{print}{PruDentmodel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The prudent model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print PruDent model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.majorityModel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/base_learner.R 3 | \name{print.majorityModel} 4 | \alias{print.majorityModel} 5 | \title{Print Majority model} 6 | \usage{ 7 | \method{print}{majorityModel}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The base model} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Print Majority model 19 | } 20 | -------------------------------------------------------------------------------- /man/print.mlresult.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{print.mlresult} 4 | \alias{print.mlresult} 5 | \title{Print the mlresult} 6 | \usage{ 7 | \method{print}{mlresult}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The mlresult to print} 11 | 12 | \item{...}{Extra parameters for print method} 13 | } 14 | \value{ 15 | No return value, called for print a prediction result 16 | } 17 | \description{ 18 | Print the mlresult 19 | } 20 | -------------------------------------------------------------------------------- /man/print.mlconfmat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/evaluation.R 3 | \name{print.mlconfmat} 4 | \alias{print.mlconfmat} 5 | \title{Print a Multi-label Confusion Matrix} 6 | \usage{ 7 | \method{print}{mlconfmat}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The mlconfmat} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print a confusion matrix 16 | } 17 | \description{ 18 | Print a Multi-label Confusion Matrix 19 | } 20 | -------------------------------------------------------------------------------- /man/print.kFoldPartition.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sampling.R 3 | \name{print.kFoldPartition} 4 | \alias{print.kFoldPartition} 5 | \title{Print a kFoldPartition object} 6 | \usage{ 7 | \method{print}{kFoldPartition}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The kFoldPartition object} 11 | 12 | \item{...}{ignored} 13 | } 14 | \value{ 15 | No return value, called for print folds' detail 16 | } 17 | \description{ 18 | Print a kFoldPartition object 19 | } 20 | -------------------------------------------------------------------------------- /man/merge_mlconfmat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/evaluation.R 3 | \name{merge_mlconfmat} 4 | \alias{merge_mlconfmat} 5 | \title{Join a list of multi-label confusion matrix} 6 | \usage{ 7 | merge_mlconfmat(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{A mlconfmat object or a list of mlconfmat objects} 11 | 12 | \item{...}{mlconfmat objects} 13 | } 14 | \value{ 15 | mlconfmat 16 | } 17 | \description{ 18 | Join a list of multi-label confusion matrix 19 | } 20 | -------------------------------------------------------------------------------- /utiml.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageCheckArgs: -as-cran 22 | PackageRoxygenize: rd,collate,namespace 23 | -------------------------------------------------------------------------------- /R/mldr.R: -------------------------------------------------------------------------------- 1 | #' Fix the mldr dataset to use factors 2 | #' 3 | #' @param mdata A mldr dataset. 4 | #' 5 | #' @return A mldr object 6 | #' @export 7 | #' 8 | #' @examples 9 | #' toyml <- mldata(toyml) 10 | mldata <- function (mdata) { 11 | # Change character attributes to factors 12 | attrs <- which( 13 | sapply(mdata$dataset[, mdata$attributesIndexes], class) == "character" 14 | ) 15 | mdata$dataset[,attrs] <- as.data.frame( 16 | apply(mdata$dataset[, attrs, drop=FALSE], 2, as.factor) 17 | ) 18 | 19 | mdata 20 | } 21 | -------------------------------------------------------------------------------- /man/as.matrix.mlconfmat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/evaluation.R 3 | \name{as.matrix.mlconfmat} 4 | \alias{as.matrix.mlconfmat} 5 | \title{Convert a multi-label Confusion Matrix to matrix} 6 | \usage{ 7 | \method{as.matrix}{mlconfmat}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{The mlconfmat} 11 | 12 | \item{...}{passed to as.matrix} 13 | } 14 | \value{ 15 | A confusion matrix with TP, TN, FP and FN columns 16 | } 17 | \description{ 18 | Convert a multi-label Confusion Matrix to matrix 19 | } 20 | -------------------------------------------------------------------------------- /man/summary.mltransformation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/transformation.R 3 | \name{summary.mltransformation} 4 | \alias{summary.mltransformation} 5 | \title{Summary method for mltransformation} 6 | \usage{ 7 | \method{summary}{mltransformation}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{A transformed dataset} 11 | 12 | \item{...}{additional arguments affecting the summary produced.} 13 | } 14 | \value{ 15 | No return value, called for print model's detail 16 | } 17 | \description{ 18 | Summary method for mltransformation 19 | } 20 | -------------------------------------------------------------------------------- /man/multilabel_measures.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/evaluation.R 3 | \name{multilabel_measures} 4 | \alias{multilabel_measures} 5 | \title{Return the name of all measures} 6 | \usage{ 7 | multilabel_measures() 8 | } 9 | \value{ 10 | array of character contained the measures names. 11 | } 12 | \description{ 13 | Return the name of all measures 14 | } 15 | \examples{ 16 | multilabel_measures() 17 | } 18 | \seealso{ 19 | Other evaluation: 20 | \code{\link{cv}()}, 21 | \code{\link{multilabel_confusion_matrix}()}, 22 | \code{\link{multilabel_evaluate}()} 23 | } 24 | \concept{evaluation} 25 | -------------------------------------------------------------------------------- /man/utiml_measure_names.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/evaluation.R 3 | \name{utiml_measure_names} 4 | \alias{utiml_measure_names} 5 | \title{Return the name of measures} 6 | \usage{ 7 | utiml_measure_names(measures = c("all")) 8 | } 9 | \arguments{ 10 | \item{measures}{The group of measures (Default: "all").} 11 | } 12 | \value{ 13 | array of character contained the measures names. 14 | } 15 | \description{ 16 | Return the name of measures 17 | } 18 | \examples{ 19 | utiml_measure_names() 20 | utiml_measure_names("bipartition") 21 | utiml_measure_names(c("micro-based", "macro-based")) 22 | 23 | } 24 | -------------------------------------------------------------------------------- /man/as.ranking.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{as.ranking} 4 | \alias{as.ranking} 5 | \title{Convert a mlresult to a ranking matrix} 6 | \usage{ 7 | as.ranking(mlresult, ties.method = "min", ...) 8 | } 9 | \arguments{ 10 | \item{mlresult}{The mlresult object} 11 | 12 | \item{ties.method}{A character string specifying how ties are treated 13 | (Default: "min"). see \code{\link{rank}} to more details.} 14 | 15 | \item{...}{Others parameters passed to the \code{\link{rank}} method.} 16 | } 17 | \value{ 18 | matrix with ranking values 19 | } 20 | \description{ 21 | Convert a mlresult to a ranking matrix 22 | } 23 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | The package was removed from CRAN due to the issue: 2 | "The errors in r-devel are from recent changes which lock the base environment 3 | and its namespace, so that one can no longer create new bindings there." 4 | It was caused by some tests and internal procedures that changed .Random.seed. 5 | These problems are fixed now. 6 | For particular reasons, I could not fix the issue on time. 7 | 8 | ## Test environments 9 | * local Debian 10 install, R 4.0.3 10 | * Ubuntu Linux 16.04.6 LTS on Travis CI, R version 4.0.2 11 | * win-builder (devel and release) 12 | 13 | ## R CMD check results 14 | There were no ERRORs and WARNINGs. 15 | There is a NOTE about mis-spelled words and package archived on CRAN. 16 | 17 | ## Downstream dependencies 18 | There are no downstream dependencies. 19 | -------------------------------------------------------------------------------- /man/sub-.mlresult.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{[.mlresult} 4 | \alias{[.mlresult} 5 | \title{Filter a Multi-Label Result} 6 | \usage{ 7 | \method{[}{mlresult}(mlresult, rowFilter = T, colFilter, ...) 8 | } 9 | \arguments{ 10 | \item{mlresult}{A mlresult object} 11 | 12 | \item{rowFilter}{A list of rows to filter} 13 | 14 | \item{colFilter}{A list of columns to filter} 15 | 16 | \item{...}{Extra parameters to be used as the filter} 17 | } 18 | \value{ 19 | mlresult or matrix. If column filter is performed, then the result 20 | will be a matrix. Otherwise, the result will be a mlresult. 21 | } 22 | \description{ 23 | If column filter is performed, then the result will be a matrix. Otherwise, 24 | the result will be a mlresult. 25 | } 26 | -------------------------------------------------------------------------------- /tests/testfiles/flags-measures.csv: -------------------------------------------------------------------------------- 1 | "measure","value" 2 | "Hamming-Loss", 0.1333 3 | "Subset-Accuracy", 0.4124 4 | "Precision", 0.8369 5 | "Recall", 0.8869 6 | "F-Measure", 0.8508 7 | "Accuracy", 0.7714 8 | "Specificity", 0.8381 9 | "Micro-Precision", 0.8412 10 | "Micro-Recall", 0.8936 11 | "Micro-F-Measure", 0.8666 12 | "Micro-Specificity", 0.8414 13 | "Macro-Precision", 0.8412 14 | "Macro-Recall", 0.8394 15 | "Macro-F-Measure", 0.8303 16 | "Macro-Specificity", 0.7415 17 | "Average-Precision", 0.9178 18 | "Coverage", 3.0825 19 | "OneError", 0.0825 20 | "IsError", 0.4381 21 | "ErrorSetSize", 0.9588 22 | "Ranking-Loss", 0.0875 23 | "Mean-Average-Precision", 0.8615 24 | "Geometric-Mean-Average-Precision", 0.8556 25 | "Mean-Average-Interpolated-Precision", 0.8545 26 | "Geometric-Mean-Average-Interpolated-Precision", 0.8488 27 | "Micro-AUC", 0.9256 28 | "Macro-AUC", 0.8426 29 | "Logarithmic-Loss", 2.3367 -------------------------------------------------------------------------------- /man/normalize_mldata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pre_process.R 3 | \name{normalize_mldata} 4 | \alias{normalize_mldata} 5 | \title{Normalize numerical attributes} 6 | \usage{ 7 | normalize_mldata(mdata) 8 | } 9 | \arguments{ 10 | \item{mdata}{The mldr dataset to be normalized.} 11 | } 12 | \value{ 13 | a new mldr object. 14 | } 15 | \description{ 16 | Normalize all numerical attributes to values between 0 and 1. The highest 17 | value is changed to 1 and the lowest value to 0. 18 | } 19 | \examples{ 20 | norm.toy <- normalize_mldata(toyml) 21 | } 22 | \seealso{ 23 | Other pre process: 24 | \code{\link{fill_sparse_mldata}()}, 25 | \code{\link{remove_attributes}()}, 26 | \code{\link{remove_labels}()}, 27 | \code{\link{remove_skewness_labels}()}, 28 | \code{\link{remove_unique_attributes}()}, 29 | \code{\link{remove_unlabeled_instances}()}, 30 | \code{\link{replace_nominal_attributes}()} 31 | } 32 | \concept{pre process} 33 | -------------------------------------------------------------------------------- /man/remove_unlabeled_instances.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pre_process.R 3 | \name{remove_unlabeled_instances} 4 | \alias{remove_unlabeled_instances} 5 | \title{Remove examples without labels} 6 | \usage{ 7 | remove_unlabeled_instances(mdata) 8 | } 9 | \arguments{ 10 | \item{mdata}{The mldr dataset to remove the instances.} 11 | } 12 | \value{ 13 | a new mldr object. 14 | } 15 | \description{ 16 | Remove the examples that do not have labels. 17 | } 18 | \examples{ 19 | new.toy <- remove_labels(toyml, c(12,14)) 20 | remove_unlabeled_instances(new.toy) 21 | } 22 | \seealso{ 23 | Other pre process: 24 | \code{\link{fill_sparse_mldata}()}, 25 | \code{\link{normalize_mldata}()}, 26 | \code{\link{remove_attributes}()}, 27 | \code{\link{remove_labels}()}, 28 | \code{\link{remove_skewness_labels}()}, 29 | \code{\link{remove_unique_attributes}()}, 30 | \code{\link{replace_nominal_attributes}()} 31 | } 32 | \concept{pre process} 33 | -------------------------------------------------------------------------------- /man/remove_unique_attributes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pre_process.R 3 | \name{remove_unique_attributes} 4 | \alias{remove_unique_attributes} 5 | \title{Remove unique attributes} 6 | \usage{ 7 | remove_unique_attributes(mdata) 8 | } 9 | \arguments{ 10 | \item{mdata}{The mldr dataset to remove.} 11 | } 12 | \value{ 13 | a new mldr object. 14 | } 15 | \description{ 16 | Remove the attributes that have a single value for all instances. Empty and 17 | NA values are considered different values. 18 | } 19 | \examples{ 20 | alt.toy <- toyml 21 | alt.toy$dataset$ratt10 <- mean(alt.toy$dataset$ratt10) 22 | new.toy <- remove_unique_attributes(alt.toy) 23 | } 24 | \seealso{ 25 | Other pre process: 26 | \code{\link{fill_sparse_mldata}()}, 27 | \code{\link{normalize_mldata}()}, 28 | \code{\link{remove_attributes}()}, 29 | \code{\link{remove_labels}()}, 30 | \code{\link{remove_skewness_labels}()}, 31 | \code{\link{remove_unlabeled_instances}()}, 32 | \code{\link{replace_nominal_attributes}()} 33 | } 34 | \concept{pre process} 35 | -------------------------------------------------------------------------------- /man/remove_skewness_labels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pre_process.R 3 | \name{remove_skewness_labels} 4 | \alias{remove_skewness_labels} 5 | \title{Remove unusual or very common labels} 6 | \usage{ 7 | remove_skewness_labels(mdata, t = 1) 8 | } 9 | \arguments{ 10 | \item{mdata}{The mldr dataset to remove the skewness labels.} 11 | 12 | \item{t}{Threshold value. Number of minimum examples positive and negative.} 13 | } 14 | \value{ 15 | a new mldr object. 16 | } 17 | \description{ 18 | Remove the labels that have smaller number of positive or negative examples 19 | based on a specific threshold value. 20 | } 21 | \examples{ 22 | remove_skewness_labels(toyml, 20) 23 | } 24 | \seealso{ 25 | Other pre process: 26 | \code{\link{fill_sparse_mldata}()}, 27 | \code{\link{normalize_mldata}()}, 28 | \code{\link{remove_attributes}()}, 29 | \code{\link{remove_labels}()}, 30 | \code{\link{remove_unique_attributes}()}, 31 | \code{\link{remove_unlabeled_instances}()}, 32 | \code{\link{replace_nominal_attributes}()} 33 | } 34 | \concept{pre process} 35 | -------------------------------------------------------------------------------- /man/fill_sparse_mldata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pre_process.R 3 | \name{fill_sparse_mldata} 4 | \alias{fill_sparse_mldata} 5 | \title{Fill sparse dataset with 0 or '' values} 6 | \usage{ 7 | fill_sparse_mldata(mdata) 8 | } 9 | \arguments{ 10 | \item{mdata}{The mldr dataset to be filled.} 11 | } 12 | \value{ 13 | a new mldr object. 14 | } 15 | \description{ 16 | Transform a sparse dataset filling NA values to 0 or '' based on the column 17 | type. Text columns with numeric values will be modified to numerical. 18 | } 19 | \examples{ 20 | sparse.toy <- toyml 21 | sparse.toy$dataset$ratt10[sample(100, 30)] <- NA 22 | complete.toy <- fill_sparse_mldata(sparse.toy) 23 | } 24 | \seealso{ 25 | Other pre process: 26 | \code{\link{normalize_mldata}()}, 27 | \code{\link{remove_attributes}()}, 28 | \code{\link{remove_labels}()}, 29 | \code{\link{remove_skewness_labels}()}, 30 | \code{\link{remove_unique_attributes}()}, 31 | \code{\link{remove_unlabeled_instances}()}, 32 | \code{\link{replace_nominal_attributes}()} 33 | } 34 | \concept{pre process} 35 | -------------------------------------------------------------------------------- /man/predict.BASELINEmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_baseline.R 3 | \name{predict.BASELINEmodel} 4 | \alias{predict.BASELINEmodel} 5 | \title{Predict Method for BASELINE} 6 | \usage{ 7 | \method{predict}{BASELINEmodel}(object, newdata, probability = getOption("utiml.use.probs", TRUE), ...) 8 | } 9 | \arguments{ 10 | \item{object}{Object of class '\code{BASELINEmodel}'.} 11 | 12 | \item{newdata}{An object containing the new input data. This must be a 13 | matrix, data.frame or a mldr object.} 14 | 15 | \item{probability}{Logical indicating whether class probabilities should be 16 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 17 | 18 | \item{...}{not used.} 19 | } 20 | \value{ 21 | An object of type mlresult, based on the parameter probability. 22 | } 23 | \description{ 24 | This function predicts values based upon a model trained by 25 | \code{\link{baseline}}. 26 | } 27 | \examples{ 28 | model <- baseline(toyml) 29 | pred <- predict(model, toyml) 30 | } 31 | \seealso{ 32 | \code{\link[=baseline]{Baseline}} 33 | } 34 | -------------------------------------------------------------------------------- /man/foodtruck.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{foodtruck} 5 | \alias{foodtruck} 6 | \title{Foodtruck multi-label dataset.} 7 | \format{ 8 | A mldr object with 407 instances, 21 features and 12 labels: 9 | } 10 | \source{ 11 | The dataset is described in: 12 | Rivolli A., Parker L.C., de Carvalho A.C.P.L.F. (2017) Food Truck 13 | Recommendation Using Multi-label Classification. In: Oliveira E., Gama J., 14 | Vale Z., Lopes Cardoso H. (eds) Progress in Artificial Intelligence. EPIA 15 | 2017. Lecture Notes in Computer Science, vol 10423. Springer, Cham 16 | } 17 | \usage{ 18 | foodtruck 19 | } 20 | \description{ 21 | The foodtruck multi-label dataset is a real multi-label dataset, which uses 22 | habits and personal information to predict food truck cuisines. 23 | } 24 | \details{ 25 | General Information 26 | \itemize{ 27 | \item Cardinality: 2.28 28 | \item Density: 0.19 29 | \item Distinct multi-labels: 117 30 | \item Number of single labelsets: 74 31 | \item Max frequency: 114 32 | } 33 | } 34 | \keyword{datasets} 35 | -------------------------------------------------------------------------------- /man/remove_labels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pre_process.R 3 | \name{remove_labels} 4 | \alias{remove_labels} 5 | \title{Remove labels from the dataset} 6 | \usage{ 7 | remove_labels(mdata, labels) 8 | } 9 | \arguments{ 10 | \item{mdata}{The mldr dataset to remove labels.} 11 | 12 | \item{labels}{Label indexes or label names to be removed.} 13 | } 14 | \value{ 15 | a new mldr object. 16 | } 17 | \description{ 18 | Remove specified labels generating a new multi-label dataset. 19 | } 20 | \note{ 21 | If invalid labels names or indexes were informed, they will be ignored. 22 | } 23 | \examples{ 24 | toyml1 <- remove_labels(toyml, c("y1","y5")) 25 | toyml2 <- remove_labels(toyml, c(11, 15)) 26 | } 27 | \seealso{ 28 | Other pre process: 29 | \code{\link{fill_sparse_mldata}()}, 30 | \code{\link{normalize_mldata}()}, 31 | \code{\link{remove_attributes}()}, 32 | \code{\link{remove_skewness_labels}()}, 33 | \code{\link{remove_unique_attributes}()}, 34 | \code{\link{remove_unlabeled_instances}()}, 35 | \code{\link{replace_nominal_attributes}()} 36 | } 37 | \concept{pre process} 38 | -------------------------------------------------------------------------------- /man/create_random_subset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sampling.R 3 | \name{create_random_subset} 4 | \alias{create_random_subset} 5 | \title{Create a random subset of a dataset} 6 | \usage{ 7 | create_random_subset( 8 | mdata, 9 | instances, 10 | attributes = mdata$measures$num.inputs, 11 | replacement = FALSE 12 | ) 13 | } 14 | \arguments{ 15 | \item{mdata}{A mldr dataset} 16 | 17 | \item{instances}{The number of expected instances} 18 | 19 | \item{attributes}{The number of expected attributes. 20 | (Default: all attributes)} 21 | 22 | \item{replacement}{A boolean value to define sample with replacement or not. 23 | (Default: FALSE)} 24 | } 25 | \value{ 26 | A new mldr subset 27 | } 28 | \description{ 29 | Create a random subset of a dataset 30 | } 31 | \examples{ 32 | small.toy <- create_random_subset(toyml, 10, 3) 33 | medium.toy <- create_random_subset(toyml, 50, 5) 34 | } 35 | \seealso{ 36 | Other sampling: 37 | \code{\link{create_holdout_partition}()}, 38 | \code{\link{create_kfold_partition}()}, 39 | \code{\link{create_subset}()} 40 | } 41 | \concept{sampling} 42 | -------------------------------------------------------------------------------- /man/remove_attributes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pre_process.R 3 | \name{remove_attributes} 4 | \alias{remove_attributes} 5 | \title{Remove attributes from the dataset} 6 | \usage{ 7 | remove_attributes(mdata, attributes) 8 | } 9 | \arguments{ 10 | \item{mdata}{The mldr dataset to remove labels.} 11 | 12 | \item{attributes}{Attributes indexes or attributes names to be removed.} 13 | } 14 | \value{ 15 | a new mldr object. 16 | } 17 | \description{ 18 | Remove specified attributes generating a new multi-label dataset. 19 | } 20 | \note{ 21 | If invalid attributes names or indexes were informed, they will be 22 | ignored. 23 | } 24 | \examples{ 25 | toyml1 <- remove_attributes(toyml, c("iatt8","iatt9", "ratt10")) 26 | toyml2 <- remove_attributes(toyml, 10) 27 | } 28 | \seealso{ 29 | Other pre process: 30 | \code{\link{fill_sparse_mldata}()}, 31 | \code{\link{normalize_mldata}()}, 32 | \code{\link{remove_labels}()}, 33 | \code{\link{remove_skewness_labels}()}, 34 | \code{\link{remove_unique_attributes}()}, 35 | \code{\link{remove_unlabeled_instances}()}, 36 | \code{\link{replace_nominal_attributes}()} 37 | } 38 | \concept{pre process} 39 | -------------------------------------------------------------------------------- /man/create_subset.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sampling.R 3 | \name{create_subset} 4 | \alias{create_subset} 5 | \title{Create a subset of a dataset} 6 | \usage{ 7 | create_subset(mdata, rows, cols = NULL) 8 | } 9 | \arguments{ 10 | \item{mdata}{A mldr dataset} 11 | 12 | \item{rows}{A vector with the instances indexes (names or indexes).} 13 | 14 | \item{cols}{A vector with the attributes indexes (names or indexes).} 15 | } 16 | \value{ 17 | A new mldr subset 18 | } 19 | \description{ 20 | Create a subset of a dataset 21 | } 22 | \note{ 23 | It is not necessary specify the labels attributes because they are 24 | included by default. 25 | } 26 | \examples{ 27 | ## Create a dataset with the 20 first examples and the 7 first attributes 28 | small.toy <- create_subset(toyml, seq(20), seq(7)) 29 | 30 | ## Create a random dataset with 50 examples and 5 attributes 31 | random.toy <- create_subset(toyml, sample(100, 50), sample(10, 5)) 32 | } 33 | \seealso{ 34 | Other sampling: 35 | \code{\link{create_holdout_partition}()}, 36 | \code{\link{create_kfold_partition}()}, 37 | \code{\link{create_random_subset}()} 38 | } 39 | \concept{sampling} 40 | -------------------------------------------------------------------------------- /tests/testthat/test_pairwiseclassifiers.R: -------------------------------------------------------------------------------- 1 | context("Pairwise based classifiers") 2 | train <- toyml 3 | test <- toyml$dataset[10:40, toyml$attributesIndexes] 4 | 5 | predictionTest <- function (model) { 6 | set.seed(123) 7 | pred <- predict(model, test) 8 | expect_is(pred, "mlresult") 9 | expect_equal(nrow(pred), nrow(test)) 10 | expect_equal(ncol(pred), toyml$measures$num.labels) 11 | expect_equal(colnames(pred), rownames(toyml$labels)) 12 | expect_equal(rownames(pred), rownames(test)) 13 | 14 | set.seed(123) 15 | pred1 <- predict(model, test, prob = FALSE) 16 | expect_is(pred1, "mlresult") 17 | expect_equal(as.matrix(pred1), attr(pred, "classes")) 18 | expect_equal(as.matrix(pred), attr(pred1, "probs")) 19 | 20 | pred 21 | } 22 | 23 | baseTest <- function (model, expected.class) { 24 | expect_is(model, expected.class) 25 | expect_gte(length(model$models), length(model$labels) * (length(model$labels)-1) / 2) 26 | 27 | predictionTest(model) 28 | } 29 | 30 | test_that("RPC", { 31 | model <- rpc(train, "RANDOM") 32 | baseTest(model, "RPCmodel") 33 | }) 34 | 35 | test_that("CLR", { 36 | model <- clr(train, "RANDOM") 37 | model$models <- c(model$rpcmodel$models, model$brmodel$models) 38 | baseTest(model, "CLRmodel") 39 | }) 40 | -------------------------------------------------------------------------------- /man/replace_nominal_attributes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pre_process.R 3 | \name{replace_nominal_attributes} 4 | \alias{replace_nominal_attributes} 5 | \title{Replace nominal attributes 6 | Replace the nominal attributes by binary attributes.} 7 | \usage{ 8 | replace_nominal_attributes(mdata, ordinal.attributes = list()) 9 | } 10 | \arguments{ 11 | \item{mdata}{The mldr dataset to remove.} 12 | 13 | \item{ordinal.attributes}{Not yet, but it will be used to specify which 14 | attributes need to be replaced.} 15 | } 16 | \value{ 17 | a new mldr object. 18 | } 19 | \description{ 20 | Replace nominal attributes 21 | Replace the nominal attributes by binary attributes. 22 | } 23 | \examples{ 24 | new.toy <- toyml 25 | new.column <- as.factor(sample(c("a","b","c"), 100, replace = TRUE)) 26 | new.toy$dataset$ratt10 <- new.column 27 | head(replace_nominal_attributes(new.toy)) 28 | } 29 | \seealso{ 30 | Other pre process: 31 | \code{\link{fill_sparse_mldata}()}, 32 | \code{\link{normalize_mldata}()}, 33 | \code{\link{remove_attributes}()}, 34 | \code{\link{remove_labels}()}, 35 | \code{\link{remove_skewness_labels}()}, 36 | \code{\link{remove_unique_attributes}()}, 37 | \code{\link{remove_unlabeled_instances}()} 38 | } 39 | \concept{pre process} 40 | -------------------------------------------------------------------------------- /tests/testthat/test_othersclassifiers.R: -------------------------------------------------------------------------------- 1 | context("Other classifiers") 2 | train <- toyml 3 | test <- toyml$dataset[10:40, toyml$attributesIndexes] 4 | 5 | predictionTest <- function (model) { 6 | set.seed(123) 7 | pred <- predict(model, test) 8 | expect_is(pred, "mlresult") 9 | expect_equal(nrow(pred), nrow(test)) 10 | expect_equal(ncol(pred), toyml$measures$num.labels) 11 | expect_equal(colnames(pred), rownames(toyml$labels)) 12 | expect_equal(rownames(pred), rownames(test)) 13 | 14 | set.seed(123) 15 | pred1 <- predict(model, test, prob = FALSE) 16 | expect_is(pred1, "mlresult") 17 | expect_equal(as.matrix(pred1), attr(pred, "classes")) 18 | expect_equal(as.matrix(pred), attr(pred1, "probs")) 19 | 20 | pred 21 | } 22 | 23 | baseTest <- function (model, expected.class) { 24 | expect_is(model, expected.class) 25 | predictionTest(model) 26 | } 27 | 28 | test_that("Baseline", { 29 | model <- baseline(train) 30 | baseTest(model, "BASELINEmodel") 31 | 32 | baseTest(baseline(train, "F1"), "BASELINEmodel") 33 | baseTest(baseline(train, "hamming-loss"), "BASELINEmodel") 34 | baseTest(baseline(train, "subset-accuracy"), "BASELINEmodel") 35 | 36 | expect_equal(baseline(train, "general")$predict, model$predict) 37 | expect_error(baseline(train, "abc")) 38 | }) 39 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: utiml 2 | Type: Package 3 | Title: Utilities for Multi-Label Learning 4 | Version: 0.1.7 5 | Date: 2021-05-26 6 | Authors@R: person("Adriano", "Rivolli", email = "rivolli@utfpr.edu.br", 7 | role = c("aut", "cre")) 8 | Description: Multi-label learning strategies and others procedures to support multi- 9 | label classification in R. The package provides a set of multi-label procedures such as 10 | sampling methods, transformation strategies, threshold functions, pre-processing 11 | techniques and evaluation metrics. A complete overview of the matter can be seen in 12 | Zhang, M. and Zhou, Z. (2014) and Gibaja, E. and 13 | Ventura, S. (2015) A Tutorial on Multi-label Learning. 14 | URL: https://github.com/rivolli/utiml 15 | Depends: 16 | R (>= 3.0.0), 17 | mldr(>= 0.4.0), 18 | parallel, 19 | ROCR 20 | Imports: 21 | stats, 22 | utils, 23 | methods 24 | Suggests: 25 | C50, 26 | e1071, 27 | infotheo, 28 | kknn, 29 | knitr, 30 | randomForest, 31 | rmarkdown, 32 | markdown, 33 | rpart, 34 | testthat, 35 | xgboost(>= 0.6-4) 36 | License: GPL-3 37 | LazyData: true 38 | BugReports: https://github.com/rivolli/utiml 39 | RoxygenNote: 7.1.1 40 | VignetteBuilder: knitr 41 | Encoding: UTF-8 42 | -------------------------------------------------------------------------------- /man/predict.MLKNNmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_mlknn.R 3 | \name{predict.MLKNNmodel} 4 | \alias{predict.MLKNNmodel} 5 | \title{Predict Method for ML-KNN} 6 | \usage{ 7 | \method{predict}{MLKNNmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{MLKNNmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Not used.} 26 | 27 | \item{cores}{Ignored because this method does not support multi-core.} 28 | 29 | \item{seed}{Ignored because this method is deterministic.} 30 | } 31 | \value{ 32 | An object of type mlresult, based on the parameter probability. 33 | } 34 | \description{ 35 | This function predicts values based upon a model trained by \code{mlknn}. 36 | ' 37 | } 38 | \examples{ 39 | model <- mlknn(toyml) 40 | pred <- predict(model, toyml) 41 | } 42 | \seealso{ 43 | \code{\link[=mlknn]{ML-KNN}} 44 | } 45 | -------------------------------------------------------------------------------- /man/predict.LPmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_lp.R 3 | \name{predict.LPmodel} 4 | \alias{predict.LPmodel} 5 | \title{Predict Method for Label Powerset} 6 | \usage{ 7 | \method{predict}{LPmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{LPmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{Not used} 29 | 30 | \item{seed}{An optional integer used to set the seed. (Default: 31 | \code{options("utiml.seed", NA)})} 32 | } 33 | \value{ 34 | An object of type mlresult, based on the parameter probability. 35 | } 36 | \description{ 37 | This function predicts values based upon a model trained by \code{\link{lp}}. 38 | } 39 | \examples{ 40 | model <- lp(toyml, "RANDOM") 41 | pred <- predict(model, toyml) 42 | } 43 | \seealso{ 44 | \code{\link[=lp]{Label Powerset (LP)}} 45 | } 46 | -------------------------------------------------------------------------------- /man/predict.PSmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ps.R 3 | \name{predict.PSmodel} 4 | \alias{predict.PSmodel} 5 | \title{Predict Method for Pruned Set Transformation} 6 | \usage{ 7 | \method{predict}{PSmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{PSmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{Not used} 29 | 30 | \item{seed}{An optional integer used to set the seed. (Default: 31 | \code{options("utiml.seed", NA)})} 32 | } 33 | \value{ 34 | An object of type mlresult, based on the parameter probability. 35 | } 36 | \description{ 37 | This function predicts values based upon a model trained by 38 | \code{\link{ps}}. 39 | } 40 | \examples{ 41 | model <- ps(toyml, "RANDOM") 42 | pred <- predict(model, toyml) 43 | } 44 | \seealso{ 45 | \code{\link[=ps]{Pruned Set (PS)}} 46 | } 47 | -------------------------------------------------------------------------------- /tests/testthat/test_cv.R: -------------------------------------------------------------------------------- 1 | context("CV") 2 | 3 | test_that("Test CV returns", { 4 | res1 <- cv(toyml, br, base.algorithm="RANDOM", cv.folds=10) 5 | expect_length(res1, 22) 6 | 7 | res2 <- cv(toyml, br, base.algorithm="RANDOM", cv.folds=3, cv.results = TRUE) 8 | expect_length(res2, 2) 9 | expect_named(res2, c("multilabel", "labels")) 10 | expect_equal(dim(res2$multilabel), c(3, length(res1))) 11 | expect_named(res2$labels, rownames(toyml$labels)) 12 | expect_equal(nrow(res2$labels[[1]]), 3) 13 | 14 | res3 <- cv(toyml, br, base.algorithm="RANDOM", cv.folds=3, 15 | cv.predictions=TRUE) 16 | expect_length(res3, 2) 17 | expect_named(res3, c("multilabel", "predictions")) 18 | expect_equal(dim(res3$multilabel), c(3, length(res1))) 19 | expect_length(res3$predictions, 3) 20 | expect_equal(colnames(res3$predictions[[1]]), names(res2$labels)) 21 | }) 22 | 23 | test_that("Test CV seed", { 24 | res1 <- cv(toyml, dbr, base.algorithm="RANDOM", cv.folds=4, cv.seed = 123) 25 | res2 <- cv(toyml, dbr, base.algorithm="RANDOM", cv.folds=4, cv.seed = 123) 26 | expect_equal(res1, res2) 27 | 28 | set.seed(123) 29 | res3 <- cv(toyml, dbr, base.algorithm="RANDOM", cv.folds=4) 30 | expect_equal(res1, res3) 31 | 32 | res4 <- cv(toyml, dbr, base.algorithm="RANDOM", cv.folds=4, 33 | cv.sampling="iterative", cv.seed = 123) 34 | expect_false(isTRUE(all.equal(res1, res4))) 35 | }) 36 | -------------------------------------------------------------------------------- /man/multilabel_prediction.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{multilabel_prediction} 4 | \alias{multilabel_prediction} 5 | \title{Create a mlresult object} 6 | \usage{ 7 | multilabel_prediction( 8 | bipartitions, 9 | probabilities, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | empty.prediction = getOption("utiml.empty.prediction", FALSE) 12 | ) 13 | } 14 | \arguments{ 15 | \item{bipartitions}{The matrix of predictions (bipartition values), 16 | only 0 and 1} 17 | 18 | \item{probabilities}{The matrix of probability/confidence of a prediction, 19 | between 0..1} 20 | 21 | \item{probability}{A logical value. If \code{TRUE} the predicted values are 22 | the score between 0 and 1, otherwise the values are bipartition 0 or 1. 23 | (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{empty.prediction}{A logical value. If \code{TRUE} the predicted values 26 | may contains empty values, otherwise at least one label will be positive for 27 | each instance.} 28 | } 29 | \value{ 30 | An object of type mlresult 31 | } 32 | \description{ 33 | Create a mlresult object 34 | } 35 | \examples{ 36 | probs <- matrix( 37 | runif(90), ncol=3, dimnames = list(1:30, c("y1", "y2", "y3")) 38 | ) 39 | preds <- matrix( 40 | as.numeric(probs > 0.5), ncol=3, dimnames = list(1:30, c("y1", "y2", "y3")) 41 | ) 42 | multilabel_prediction(probs, preds) 43 | } 44 | -------------------------------------------------------------------------------- /man/predict.PPTmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ppt.R 3 | \name{predict.PPTmodel} 4 | \alias{predict.PPTmodel} 5 | \title{Predict Method for Pruned Problem Transformation} 6 | \usage{ 7 | \method{predict}{PPTmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{PPTmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{Not used} 29 | 30 | \item{seed}{An optional integer used to set the seed. (Default: 31 | \code{options("utiml.seed", NA)})} 32 | } 33 | \value{ 34 | An object of type mlresult, based on the parameter probability. 35 | } 36 | \description{ 37 | This function predicts values based upon a model trained by 38 | \code{\link{ppt}}. 39 | } 40 | \examples{ 41 | model <- ppt(toyml, "RANDOM") 42 | pred <- predict(model, toyml) 43 | } 44 | \seealso{ 45 | \code{\link[=ppt]{Pruned Problem Transformation (PPT)}} 46 | } 47 | -------------------------------------------------------------------------------- /tests/testthat/test_internal.R: -------------------------------------------------------------------------------- 1 | context("R Internal tests") 2 | 3 | test_that("Normalize", { 4 | expect_equal(utiml_normalize(1:3), c(0.0, 0.5, 1.0)) 5 | expect_equal(utiml_normalize(1:5), c(0.0, 0.25, 0.5, 0.75, 1.0)) 6 | expect_equal(utiml_normalize(c(1,2,3,4,5), 10, 0), 1:5/10) 7 | }) 8 | 9 | test_that("Ifelse", { 10 | c1 <- rep(1, 10) 11 | c2 <- 1:10 12 | expect_equal(utiml_ifelse(T, c1, c2), c1) 13 | expect_equal(utiml_ifelse(F, c1, c2), c2) 14 | expect_equal(utiml_ifelse(T, c1, NA), c1) 15 | expect_equal(utiml_ifelse(F, c1, NA), NA) 16 | expect_equal(utiml_ifelse(T, NA, c2), NA) 17 | expect_equal(utiml_ifelse(F, NA, c2), c2) 18 | expect_null(utiml_ifelse(NA, c1, c2)) 19 | }) 20 | 21 | test_that("New data", { 22 | test <- toyml$dataset[,toyml$attributesIndexes] 23 | expect_equal(utiml_newdata(test), test) 24 | expect_equal(utiml_newdata(toyml), test) 25 | }) 26 | 27 | test_that("Rename", { 28 | expect_equal(utiml_rename(c("a", "b", "c")), c(a="a", b="b", c="c")) 29 | expect_equal(utiml_rename(c(1, 2, 3), c("a", "b", "c")), c(a=1, b=2, c=3)) 30 | }) 31 | 32 | test_that("Equals sets", { 33 | expect_true(utiml_is_equal_sets(c(1, 2, 3), c(3, 2, 1))) 34 | expect_true(utiml_is_equal_sets(c(3, 2, 1), c(1, 2, 3))) 35 | expect_true(utiml_is_equal_sets(c(), c())) 36 | 37 | expect_false(utiml_is_equal_sets(c(1, 2, 3), c(1, 2, 3, 4))) 38 | expect_false(utiml_is_equal_sets(c(1, 2, 3, 4), c(1, 2, 3))) 39 | expect_false(utiml_is_equal_sets(c(1, 2, 3), c())) 40 | }) 41 | -------------------------------------------------------------------------------- /tests/testthat/test_base_learner.R: -------------------------------------------------------------------------------- 1 | context("Base learner") 2 | testdataset <- list( 3 | data = toyml$dataset[, c(1,2,3,4,13)], 4 | labelindex = 5, 5 | labelname = "y3", 6 | mlmethod = "test", 7 | mldataset = "toyml" 8 | ) 9 | testdataset$data$y3 <- as.factor(testdataset$data$y3) 10 | 11 | test_that("test train/prediction base learner algorithms", { 12 | methods <- c("baseSVM", #"baseJ48", 13 | "baseC5.0", "baseCART", "baseRF", 14 | "baseNB", "baseKNN", "baseMAJORITY", "baseRANDOM") 15 | names(methods) <- c("svm", #"J48", 16 | "C5.0", "rpart", "randomForest", 17 | "naiveBayes", "baseKNN", "majorityModel", "randomModel") 18 | for (modelname in names(methods)) { 19 | class(testdataset) <- methods[modelname] 20 | model <- mltrain(testdataset) 21 | expect_is(model, modelname) 22 | result <- mlpredict(model, testdataset$data[11:20, 1:4]) 23 | expect_is(result, "data.frame", label = modelname) 24 | expect_equal(rownames(result), as.character(11:20), label = modelname) 25 | expect_equal(colnames(result), c("prediction", "probability"), 26 | label = modelname) 27 | } 28 | class(testdataset) <- NULL 29 | expect_error(mltrain(testdataset)) 30 | expect_error(mlpredict(testdataset)) 31 | }) 32 | 33 | test_that("KNN", { 34 | #TODO Train with a k and predict with other k 35 | }) 36 | 37 | test_that("Summary", { 38 | class(testdataset) <- "mltransformation" 39 | expect_equal(summary(testdataset), summary(testdataset$data)) 40 | }) 41 | -------------------------------------------------------------------------------- /man/predict.HOMERmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_homer.R 3 | \name{predict.HOMERmodel} 4 | \alias{predict.HOMERmodel} 5 | \title{Predict Method for HOMER} 6 | \usage{ 7 | \method{predict}{HOMERmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{HOMERmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the prediction. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. (Default: 33 | \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of type mlresult, based on the parameter probability. 37 | } 38 | \description{ 39 | This function predicts values based upon a model trained by 40 | \code{\link{homer}}. 41 | } 42 | \examples{ 43 | model <- homer(toyml, "RANDOM") 44 | pred <- predict(model, toyml) 45 | } 46 | \seealso{ 47 | \code{\link[=homer]{Hierarchy Of Multilabel classifiER (HOMER)}} 48 | } 49 | -------------------------------------------------------------------------------- /man/predict.LIFTmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_lift.R 3 | \name{predict.LIFTmodel} 4 | \alias{predict.LIFTmodel} 5 | \title{Predict Method for LIFT} 6 | \usage{ 7 | \method{predict}{LIFTmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{LIFTmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the training. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. This is useful when 33 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of type mlresult, based on the parameter probability. 37 | } 38 | \description{ 39 | This function predicts values based upon a model trained by 40 | \code{\link{lift}}. 41 | } 42 | \examples{ 43 | model <- lift(toyml, "RANDOM") 44 | pred <- predict(model, toyml) 45 | } 46 | \seealso{ 47 | \code{\link[=lift]{LIFT}} 48 | } 49 | -------------------------------------------------------------------------------- /man/predict.CLRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_clr.R 3 | \name{predict.CLRmodel} 4 | \alias{predict.CLRmodel} 5 | \title{Predict Method for CLR} 6 | \usage{ 7 | \method{predict}{CLRmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{CLRmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the training. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. This is useful when 33 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of type mlresult, based on the parameter probability. 37 | } 38 | \description{ 39 | This function predicts values based upon a model trained by 40 | \code{\link{clr}}. 41 | } 42 | \examples{ 43 | model <- clr(toyml, "RANDOM") 44 | pred <- predict(model, toyml) 45 | } 46 | \seealso{ 47 | \code{\link[=br]{Binary Relevance (BR)}} 48 | } 49 | -------------------------------------------------------------------------------- /man/predict.RPCmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_rpc.R 3 | \name{predict.RPCmodel} 4 | \alias{predict.RPCmodel} 5 | \title{Predict Method for RPC} 6 | \usage{ 7 | \method{predict}{RPCmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{RPCmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the training. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. This is useful when 33 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of type mlresult, based on the parameter probability. 37 | } 38 | \description{ 39 | This function predicts values based upon a model trained by 40 | \code{\link{rpc}}. 41 | } 42 | \examples{ 43 | model <- rpc(toyml, "RANDOM") 44 | pred <- predict(model, toyml) 45 | } 46 | \seealso{ 47 | \code{\link[=br]{Binary Relevance (BR)}} 48 | } 49 | -------------------------------------------------------------------------------- /man/predict.RAkELmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_rakel.R 3 | \name{predict.RAkELmodel} 4 | \alias{predict.RAkELmodel} 5 | \title{Predict Method for RAkEL} 6 | \usage{ 7 | \method{predict}{RAkELmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{RAkELmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the prediction. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. This is useful when 33 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of type mlresult, based on the parameter probability. 37 | } 38 | \description{ 39 | This function predicts values based upon a model trained by 40 | \code{\link{rakel}}. 41 | } 42 | \examples{ 43 | model <- rakel(toyml, "RANDOM") 44 | pred <- predict(model, toyml) 45 | } 46 | \seealso{ 47 | \code{\link[=rakel]{Random k Labelsets (RAkEL)}} 48 | } 49 | -------------------------------------------------------------------------------- /man/predict.ESLmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_esl.R 3 | \name{predict.ESLmodel} 4 | \alias{predict.ESLmodel} 5 | \title{Predict Method for Ensemble of Single Label} 6 | \usage{ 7 | \method{predict}{ESLmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{ESLmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the training. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. This is useful when 33 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of type mlresult, based on the parameter probability. 37 | } 38 | \description{ 39 | This function predicts values based upon a model trained by 40 | \code{\link{esl}}. 41 | } 42 | \examples{ 43 | model <- esl(toyml, "RANDOM") 44 | pred <- predict(model, toyml) 45 | } 46 | \seealso{ 47 | \code{\link[=esl]{Ensemble of Single Label (ESL)}} 48 | } 49 | -------------------------------------------------------------------------------- /man/partition_fold.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sampling.R 3 | \name{partition_fold} 4 | \alias{partition_fold} 5 | \title{Create the multi-label dataset from folds} 6 | \usage{ 7 | partition_fold(kfold, n, has.validation = FALSE) 8 | } 9 | \arguments{ 10 | \item{kfold}{A \code{kFoldPartition} object obtained from use of the method 11 | \link{create_kfold_partition}.} 12 | 13 | \item{n}{The number of the fold to separated train and test subsets.} 14 | 15 | \item{has.validation}{Logical value that indicate if a validation 16 | dataset will be used. (Default: \code{FALSE})} 17 | } 18 | \value{ 19 | A list contained train and test mldr dataset: 20 | \describe{ 21 | \code{train}{The mldr dataset with train examples, that includes all 22 | examples except those that are in test and validation samples} 23 | \code{test}{The mldr dataset with test examples, defined by the 24 | number of the fold} 25 | \code{validation}{Optionally, only if \code{has.validation = TRUE}. 26 | The mldr dataset with validation examples} 27 | } 28 | } 29 | \description{ 30 | This is a simple way to use k-fold cross validation. 31 | } 32 | \examples{ 33 | folds <- create_kfold_partition(toyml, 10) 34 | 35 | # Using the first partition 36 | dataset <- partition_fold(folds, 1) 37 | names(dataset) 38 | ## [1] "train" "test" 39 | 40 | # All iterations 41 | for (i in 1:10) { 42 | dataset <- partition_fold(folds, i) 43 | #dataset$train 44 | #dataset$test 45 | } 46 | 47 | # Using 3 folds validation 48 | dataset <- partition_fold(folds, 3, TRUE) 49 | # dataset$train, dataset$test, #dataset$validation 50 | } 51 | -------------------------------------------------------------------------------- /man/predict.CCmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_cc.R 3 | \name{predict.CCmodel} 4 | \alias{predict.CCmodel} 5 | \title{Predict Method for Classifier Chains} 6 | \usage{ 7 | \method{predict}{CCmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = NULL, 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{CCmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{Ignored because this method does not support multi-core.} 29 | 30 | \item{seed}{An optional integer used to set the seed. 31 | (Default: \code{options("utiml.seed", NA)})} 32 | } 33 | \value{ 34 | An object of type mlresult, based on the parameter probability. 35 | } 36 | \description{ 37 | This function predicts values based upon a model trained by \code{cc}. 38 | } 39 | \note{ 40 | The Classifier Chains prediction can not be parallelized 41 | } 42 | \examples{ 43 | model <- cc(toyml, "RANDOM") 44 | pred <- predict(model, toyml) 45 | 46 | \donttest{ 47 | # Predict SVM bipartitions 48 | pred <- predict(model, toyml, prob = FALSE) 49 | 50 | # Passing a specif parameter for SVM predict algorithm 51 | pred <- predict(model, toyml, na.action = na.fail) 52 | } 53 | } 54 | \seealso{ 55 | \code{\link[=cc]{Classifier Chains (CC)}} 56 | } 57 | -------------------------------------------------------------------------------- /tests/testthat/test_powersetclassifiers.R: -------------------------------------------------------------------------------- 1 | context("Powerset based classifiers") 2 | train <- toyml 3 | test <- toyml$dataset[10:40, toyml$attributesIndexes] 4 | 5 | predictionTest <- function (model) { 6 | set.seed(123) 7 | pred <- predict(model, test) 8 | expect_is(pred, "mlresult") 9 | expect_equal(nrow(pred), nrow(test)) 10 | expect_equal(ncol(pred), toyml$measures$num.labels) 11 | expect_equal(colnames(pred), rownames(toyml$labels)) 12 | expect_equal(rownames(pred), rownames(test)) 13 | 14 | set.seed(123) 15 | pred1 <- predict(model, test, prob = FALSE) 16 | expect_is(pred1, "mlresult") 17 | expect_equal(as.matrix(pred1), attr(pred, "classes")) 18 | expect_equal(as.matrix(pred), attr(pred1, "probs")) 19 | 20 | pred 21 | } 22 | 23 | baseTest <- function (model, expected.class) { 24 | expect_is(model, expected.class) 25 | predictionTest(model) 26 | } 27 | 28 | test_that("LP", { 29 | model <- lp(train, "RANDOM") 30 | baseTest(model, "LPmodel") 31 | }) 32 | 33 | test_that("RAkEL", { 34 | model <- rakel(train, "RANDOM") 35 | baseTest(model, "RAkELmodel") 36 | }) 37 | 38 | test_that("PPT", { 39 | model <- ppt(train, "RANDOM") 40 | baseTest(model, "PPTmodel") 41 | 42 | model <- ppt(train, "RANDOM", info.loss=TRUE) 43 | baseTest(model, "PPTmodel") 44 | 45 | expect_error(ppt(train, "RANDOM", p=0)) 46 | }) 47 | 48 | test_that("PS", { 49 | model <- ps(train, "RANDOM") 50 | baseTest(model, "PSmodel") 51 | 52 | model <- ps(train, "RANDOM", strategy="B") 53 | baseTest(model, "PSmodel") 54 | 55 | expect_error(ps(train, "RANDOM", p=0)) 56 | }) 57 | 58 | test_that("EPS", { 59 | model <- eps(train, "RANDOM") 60 | baseTest(model, "EPSmodel") 61 | 62 | expect_error(eps(train, "RANDOM", m=0)) 63 | }) 64 | -------------------------------------------------------------------------------- /man/predict.MBRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_mbr.R 3 | \name{predict.MBRmodel} 4 | \alias{predict.MBRmodel} 5 | \title{Predict Method for Meta-BR/2BR} 6 | \usage{ 7 | \method{predict}{MBRmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{MBRmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the training. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. This is useful when 33 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of type mlresult, based on the parameter probability. 37 | } 38 | \description{ 39 | This function predicts values based upon a model trained by \code{mbr}. 40 | } 41 | \examples{ 42 | \donttest{ 43 | # Predict SVM scores 44 | model <- mbr(toyml) 45 | pred <- predict(model, toyml) 46 | 47 | # Predict SVM bipartitions 48 | pred <- predict(model, toyml, probability = FALSE) 49 | 50 | # Passing a specif parameter for SVM predict algorithm 51 | pred <- predict(model, toyml, na.action = na.fail) 52 | } 53 | } 54 | \seealso{ 55 | \code{\link[=mbr]{Meta-BR (MBR or 2BR)}} 56 | } 57 | -------------------------------------------------------------------------------- /man/predict.PruDentmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_prudent.R 3 | \name{predict.PruDentmodel} 4 | \alias{predict.PruDentmodel} 5 | \title{Predict Method for PruDent} 6 | \usage{ 7 | \method{predict}{PruDentmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{PruDentmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the training. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. This is useful when 33 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of type mlresult, based on the parameter probability. 37 | } 38 | \description{ 39 | This function predicts values based upon a model trained by \code{prudent}. 40 | } 41 | \examples{ 42 | \donttest{ 43 | # Predict SVM scores 44 | model <- prudent(toyml) 45 | pred <- predict(model, toyml) 46 | 47 | # Predict SVM bipartitions 48 | pred <- predict(model, toyml, probability = FALSE) 49 | 50 | # Passing a specif parameter for SVM predict algorithm 51 | pred <- predict(model, toyml, na.action = na.fail) 52 | } 53 | } 54 | \seealso{ 55 | \code{\link[=prudent]{PruDent}} 56 | } 57 | -------------------------------------------------------------------------------- /man/predict.EPSmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_eps.R 3 | \name{predict.EPSmodel} 4 | \alias{predict.EPSmodel} 5 | \title{Predict Method for Ensemble of Pruned Set Transformation} 6 | \usage{ 7 | \method{predict}{EPSmodel}( 8 | object, 9 | newdata, 10 | threshold = 0.5, 11 | probability = getOption("utiml.use.probs", TRUE), 12 | ..., 13 | cores = getOption("utiml.cores", 1), 14 | seed = getOption("utiml.seed", NA) 15 | ) 16 | } 17 | \arguments{ 18 | \item{object}{Object of class '\code{EPSmodel}'.} 19 | 20 | \item{newdata}{An object containing the new input data. This must be a 21 | matrix, data.frame or a mldr object.} 22 | 23 | \item{threshold}{A threshold value for producing bipartitions. (Default: 0.5)} 24 | 25 | \item{probability}{Logical indicating whether class probabilities should be 26 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 27 | 28 | \item{...}{Others arguments passed to the base algorithm prediction for all 29 | subproblems.} 30 | 31 | \item{cores}{The number of cores to parallelize the prediction. Values higher 32 | than 1 require the \pkg{parallel} package. (Default: 33 | \code{options("utiml.cores", 1)})} 34 | 35 | \item{seed}{An optional integer used to set the seed. (Default: 36 | \code{options("utiml.seed", NA)})} 37 | } 38 | \value{ 39 | An object of type mlresult, based on the parameter probability. 40 | } 41 | \description{ 42 | This function predicts values based upon a model trained by 43 | \code{\link{eps}}. Different from the others methods the probability value, 44 | is actually, the sum of all probability predictions such as it is described 45 | in the original paper. 46 | } 47 | \examples{ 48 | model <- eps(toyml, "RANDOM") 49 | pred <- predict(model, toyml) 50 | } 51 | \seealso{ 52 | \code{\link[=eps]{Ensemble of Pruned Set (EPS)}} 53 | } 54 | -------------------------------------------------------------------------------- /man/predict.NSmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ns.R 3 | \name{predict.NSmodel} 4 | \alias{predict.NSmodel} 5 | \title{Predict Method for Nested Stacking} 6 | \usage{ 7 | \method{predict}{NSmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = NULL, 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{NSmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{Ignored because this method does not support multi-core.} 29 | 30 | \item{seed}{An optional integer used to set the seed. 31 | (Default: \code{options("utiml.seed", NA)})} 32 | } 33 | \value{ 34 | An object of type mlresult, based on the parameter probability. 35 | } 36 | \description{ 37 | This function predicts values based upon a model trained by \code{ns}. 38 | The scores of the prediction was adapted once this method uses a correction 39 | of labelsets to predict only classes present on training data. To more 40 | information about this implementation see \code{\link{subset_correction}}. 41 | } 42 | \examples{ 43 | model <- ns(toyml, "RANDOM") 44 | pred <- predict(model, toyml) 45 | 46 | \donttest{ 47 | # Predict SVM bipartitions 48 | pred <- predict(model, toyml, probability = FALSE) 49 | 50 | # Passing a specif parameter for SVM predict algorithm 51 | pred <- predict(model, toyml, na.action = na.fail) 52 | } 53 | } 54 | \seealso{ 55 | \code{\link[=ns]{Nested Stacking (NS)}} 56 | } 57 | -------------------------------------------------------------------------------- /man/mcut_threshold.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/threshold.R 3 | \name{mcut_threshold} 4 | \alias{mcut_threshold} 5 | \alias{mcut_threshold.default} 6 | \alias{mcut_threshold.mlresult} 7 | \title{Maximum Cut Thresholding (MCut)} 8 | \usage{ 9 | mcut_threshold(prediction, probability = FALSE) 10 | 11 | \method{mcut_threshold}{default}(prediction, probability = FALSE) 12 | 13 | \method{mcut_threshold}{mlresult}(prediction, probability = FALSE) 14 | } 15 | \arguments{ 16 | \item{prediction}{A matrix or mlresult.} 17 | 18 | \item{probability}{A logical value. If \code{TRUE} the predicted values are 19 | the score between 0 and 1, otherwise the values are bipartition 0 or 1. 20 | (Default: \code{FALSE})} 21 | } 22 | \value{ 23 | A mlresult object. 24 | } 25 | \description{ 26 | The Maximum Cut (MCut) automatically determines a threshold for each instance 27 | that selects a subset of labels with higher scores than others. This leads to 28 | the selection of the middle of the interval defined by these two scores as 29 | the threshold. 30 | } 31 | \section{Methods (by class)}{ 32 | \itemize{ 33 | \item \code{default}: Maximum Cut Thresholding (MCut) method for matrix 34 | 35 | \item \code{mlresult}: Maximum Cut Thresholding (MCut) for mlresult 36 | }} 37 | 38 | \examples{ 39 | prediction <- matrix(runif(16), ncol = 4) 40 | mcut_threshold(prediction) 41 | } 42 | \references{ 43 | Largeron, C., Moulin, C., & Gery, M. (2012). MCut: A Thresholding Strategy 44 | for Multi-label Classification. In 11th International Symposium, IDA 2012 45 | (pp. 172-183). 46 | } 47 | \seealso{ 48 | Other threshold: 49 | \code{\link{fixed_threshold}()}, 50 | \code{\link{lcard_threshold}()}, 51 | \code{\link{pcut_threshold}()}, 52 | \code{\link{rcut_threshold}()}, 53 | \code{\link{scut_threshold}()}, 54 | \code{\link{subset_correction}()} 55 | } 56 | \concept{threshold} 57 | -------------------------------------------------------------------------------- /man/as.mlresult.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mlresult.R 3 | \name{as.mlresult} 4 | \alias{as.mlresult} 5 | \alias{as.mlresult.default} 6 | \alias{as.mlresult.mlresult} 7 | \title{Convert a matrix prediction in a multi label prediction} 8 | \usage{ 9 | as.mlresult(predictions, probability = TRUE, ...) 10 | 11 | \method{as.mlresult}{default}(predictions, probability = TRUE, ..., threshold = 0.5) 12 | 13 | \method{as.mlresult}{mlresult}(predictions, probability = TRUE, ...) 14 | } 15 | \arguments{ 16 | \item{predictions}{a Matrix or data.frame contained the scores/probabilities 17 | values. The columns are the labels and the rows are the examples.} 18 | 19 | \item{probability}{A logical value. If \code{TRUE} the predicted values are 20 | the score between 0 and 1, otherwise the values are bipartition 0 or 1. 21 | (Default: \code{TRUE})} 22 | 23 | \item{...}{ignored} 24 | 25 | \item{threshold}{A single value between 0 and 1 or a list with threshold 26 | values contained one value per label (Default: 0.5). Only used when the 27 | predictions are not a mlresult.} 28 | } 29 | \value{ 30 | An object of type mlresult 31 | } 32 | \description{ 33 | Convert a matrix prediction in a multi label prediction 34 | } 35 | \section{Methods (by class)}{ 36 | \itemize{ 37 | \item \code{default}: Default mlresult transform method 38 | 39 | \item \code{mlresult}: change the mlresult type 40 | }} 41 | 42 | \examples{ 43 | predictions <- matrix(runif(100), ncol = 10) 44 | colnames(predictions) <- paste('label', 1:10, sep='') 45 | 46 | # Create a mlresult from a matrix 47 | mlresult <- as.mlresult(predictions) 48 | mlresult <- as.mlresult(predictions, probability = FALSE) 49 | mlresult <- as.mlresult(predictions, probability = FALSE, threshold = 0.6) 50 | 51 | # Change the current type of a mlresult 52 | mlresult <- as.mlresult(mlresult, probability = TRUE) 53 | } 54 | -------------------------------------------------------------------------------- /man/rcut_threshold.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/threshold.R 3 | \name{rcut_threshold} 4 | \alias{rcut_threshold} 5 | \alias{rcut_threshold.default} 6 | \alias{rcut_threshold.mlresult} 7 | \title{Rank Cut (RCut) threshold method} 8 | \usage{ 9 | rcut_threshold(prediction, k, probability = FALSE) 10 | 11 | \method{rcut_threshold}{default}(prediction, k, probability = FALSE) 12 | 13 | \method{rcut_threshold}{mlresult}(prediction, k, probability = FALSE) 14 | } 15 | \arguments{ 16 | \item{prediction}{A matrix or mlresult.} 17 | 18 | \item{k}{The number of elements that will be positive.} 19 | 20 | \item{probability}{A logical value. If \code{TRUE} the predicted values are 21 | the score between 0 and 1, otherwise the values are bipartition 0 or 1. 22 | (Default: \code{FALSE})} 23 | } 24 | \value{ 25 | A mlresult object. 26 | } 27 | \description{ 28 | The Rank Cut (RCut) method is an instance-wise strategy, which outputs the k 29 | labels with the highest scores for each instance at the deployment. 30 | } 31 | \section{Methods (by class)}{ 32 | \itemize{ 33 | \item \code{default}: Rank Cut (RCut) threshold method for matrix 34 | 35 | \item \code{mlresult}: Rank Cut (RCut) threshold method for mlresult 36 | }} 37 | 38 | \examples{ 39 | prediction <- matrix(runif(16), ncol = 4) 40 | rcut_threshold(prediction, 2) 41 | } 42 | \references{ 43 | Al-Otaibi, R., Flach, P., & Kull, M. (2014). Multi-label Classification: A 44 | Comparative Study on Threshold Selection Methods. In First International 45 | Workshop on Learning over Multiple Contexts (LMCE) at ECML-PKDD 2014. 46 | } 47 | \seealso{ 48 | Other threshold: 49 | \code{\link{fixed_threshold}()}, 50 | \code{\link{lcard_threshold}()}, 51 | \code{\link{mcut_threshold}()}, 52 | \code{\link{pcut_threshold}()}, 53 | \code{\link{scut_threshold}()}, 54 | \code{\link{subset_correction}()} 55 | } 56 | \concept{threshold} 57 | -------------------------------------------------------------------------------- /man/predict.BRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_br.R 3 | \name{predict.BRmodel} 4 | \alias{predict.BRmodel} 5 | \title{Predict Method for Binary Relevance} 6 | \usage{ 7 | \method{predict}{BRmodel}( 8 | object, 9 | newdata, 10 | probability = getOption("utiml.use.probs", TRUE), 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{object}{Object of class '\code{BRmodel}'.} 18 | 19 | \item{newdata}{An object containing the new input data. This must be a 20 | matrix, data.frame or a mldr object.} 21 | 22 | \item{probability}{Logical indicating whether class probabilities should be 23 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm prediction for all 26 | subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the training. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. This is useful when 33 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of type mlresult, based on the parameter probability. 37 | } 38 | \description{ 39 | This function predicts values based upon a model trained by \code{\link{br}}. 40 | } 41 | \examples{ 42 | model <- br(toyml, "RANDOM") 43 | pred <- predict(model, toyml) 44 | 45 | \donttest{ 46 | # Predict SVM scores 47 | model <- br(toyml, "SVM") 48 | pred <- predict(model, toyml) 49 | 50 | # Predict SVM bipartitions running in 2 cores 51 | pred <- predict(model, toyml, probability = FALSE, CORES = 2) 52 | 53 | # Passing a specif parameter for SVM predict algorithm 54 | pred <- predict(model, toyml, na.action = na.fail) 55 | } 56 | } 57 | \seealso{ 58 | \code{\link[=br]{Binary Relevance (BR)}} 59 | } 60 | -------------------------------------------------------------------------------- /man/lcard_threshold.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/threshold.R 3 | \name{lcard_threshold} 4 | \alias{lcard_threshold} 5 | \alias{lcard_threshold.default} 6 | \alias{lcard_threshold.mlresult} 7 | \title{Threshold based on cardinality} 8 | \usage{ 9 | lcard_threshold(prediction, cardinality, probability = FALSE) 10 | 11 | \method{lcard_threshold}{default}(prediction, cardinality, probability = FALSE) 12 | 13 | \method{lcard_threshold}{mlresult}(prediction, cardinality, probability = FALSE) 14 | } 15 | \arguments{ 16 | \item{prediction}{A matrix or mlresult.} 17 | 18 | \item{cardinality}{A real value of training dataset label cardinality, used 19 | to define the threshold value.} 20 | 21 | \item{probability}{A logical value. If \code{TRUE} the predicted values are 22 | the score between 0 and 1, otherwise the values are bipartition 0 or 1. 23 | (Default: \code{FALSE})} 24 | } 25 | \value{ 26 | A mlresult object. 27 | } 28 | \description{ 29 | Find and apply the best threshold based on cardinality of training set. 30 | The threshold is choice based on how much the average observed label 31 | cardinality is close to the average predicted label cardinality. 32 | } 33 | \section{Methods (by class)}{ 34 | \itemize{ 35 | \item \code{default}: Cardinality Threshold for matrix or data.frame 36 | 37 | \item \code{mlresult}: Cardinality Threshold for mlresult 38 | }} 39 | 40 | \examples{ 41 | prediction <- matrix(runif(16), ncol = 4) 42 | lcard_threshold(prediction, 2.1) 43 | } 44 | \references{ 45 | Read, J., Pfahringer, B., Holmes, G., & Frank, E. (2011). Classifier chains 46 | for multi-label classification. Machine Learning, 85(3), 333-359. 47 | } 48 | \seealso{ 49 | Other threshold: 50 | \code{\link{fixed_threshold}()}, 51 | \code{\link{mcut_threshold}()}, 52 | \code{\link{pcut_threshold}()}, 53 | \code{\link{rcut_threshold}()}, 54 | \code{\link{scut_threshold}()}, 55 | \code{\link{subset_correction}()} 56 | } 57 | \concept{threshold} 58 | -------------------------------------------------------------------------------- /man/predict.ECCmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ecc.R 3 | \name{predict.ECCmodel} 4 | \alias{predict.ECCmodel} 5 | \title{Predict Method for Ensemble of Classifier Chains} 6 | \usage{ 7 | \method{predict}{ECCmodel}( 8 | object, 9 | newdata, 10 | vote.schema = "maj", 11 | probability = getOption("utiml.use.probs", TRUE), 12 | ..., 13 | cores = getOption("utiml.cores", 1), 14 | seed = getOption("utiml.seed", NA) 15 | ) 16 | } 17 | \arguments{ 18 | \item{object}{Object of class '\code{ECCmodel}'.} 19 | 20 | \item{newdata}{An object containing the new input data. This must be a 21 | matrix, data.frame or a mldr object.} 22 | 23 | \item{vote.schema}{Define the way that ensemble must compute the predictions. 24 | The default valid options are: c("avg", "maj", "max", "min"). If \code{NULL} 25 | then all predictions are returned. (Default: \code{'maj'})} 26 | 27 | \item{probability}{Logical indicating whether class probabilities should be 28 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 29 | 30 | \item{...}{Others arguments passed to the base algorithm prediction for all 31 | subproblems.} 32 | 33 | \item{cores}{The number of cores to parallelize the training. Values higher 34 | than 1 require the \pkg{parallel} package. (Default: 35 | \code{options("utiml.cores", 1)})} 36 | 37 | \item{seed}{An optional integer used to set the seed. This is useful when 38 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 39 | } 40 | \value{ 41 | An object of type mlresult, based on the parameter probability. 42 | } 43 | \description{ 44 | This method predicts values based upon a model trained by \code{\link{ecc}}. 45 | } 46 | \examples{ 47 | \donttest{ 48 | # Predict SVM scores 49 | model <- ecc(toyml) 50 | pred <- predict(model, toyml) 51 | 52 | # Predict SVM bipartitions running in 2 cores 53 | pred <- predict(model, toyml, probability = FALSE, cores = 2) 54 | 55 | # Return the classes with the highest score 56 | pred <- predict(model, toyml, vote.schema = 'max') 57 | } 58 | } 59 | \seealso{ 60 | \code{\link[=ecc]{Ensemble of Classifier Chains (ECC)}} 61 | } 62 | -------------------------------------------------------------------------------- /man/predict.EBRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ebr.R 3 | \name{predict.EBRmodel} 4 | \alias{predict.EBRmodel} 5 | \title{Predict Method for Ensemble of Binary Relevance} 6 | \usage{ 7 | \method{predict}{EBRmodel}( 8 | object, 9 | newdata, 10 | vote.schema = "maj", 11 | probability = getOption("utiml.use.probs", TRUE), 12 | ..., 13 | cores = getOption("utiml.cores", 1), 14 | seed = getOption("utiml.seed", NA) 15 | ) 16 | } 17 | \arguments{ 18 | \item{object}{Object of class '\code{EBRmodel}'.} 19 | 20 | \item{newdata}{An object containing the new input data. This must be a 21 | matrix, data.frame or a mldr object.} 22 | 23 | \item{vote.schema}{Define the way that ensemble must compute the predictions. 24 | The default valid options are: c("avg", "maj", "max", "min"). If \code{NULL} 25 | then all predictions are returned. (Default: \code{'maj'})} 26 | 27 | \item{probability}{Logical indicating whether class probabilities should be 28 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 29 | 30 | \item{...}{Others arguments passed to the base algorithm prediction for all 31 | subproblems.} 32 | 33 | \item{cores}{The number of cores to parallelize the training. Values higher 34 | than 1 require the \pkg{parallel} package. (Default: 35 | \code{options("utiml.cores", 1)})} 36 | 37 | \item{seed}{An optional integer used to set the seed. This is useful when 38 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 39 | } 40 | \value{ 41 | An object of type mlresult, based on the parameter probability. 42 | } 43 | \description{ 44 | This method predicts values based upon a model trained by \code{\link{ebr}}. 45 | } 46 | \examples{ 47 | \donttest{ 48 | # Predict SVM scores 49 | model <- ebr(toyml) 50 | pred <- predict(model, toyml) 51 | 52 | # Predict SVM bipartitions running in 2 cores 53 | pred <- predict(model, toyml, prob = FALSE, cores = 2) 54 | 55 | # Return the classes with the highest score 56 | pred <- predict(model, toyml, vote = 'max') 57 | } 58 | } 59 | \seealso{ 60 | \code{\link[=ebr]{Ensemble of Binary Relevance (EBR)}} \code{ 61 | \link[=compute_multilabel_predictions]{Compute Multi-label Predictions}} 62 | } 63 | -------------------------------------------------------------------------------- /man/toyml.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{toyml} 5 | \alias{toyml} 6 | \title{Toy multi-label dataset.} 7 | \format{ 8 | A mldr object with 100 instances, 10 features and 5 labels: 9 | \describe{ 10 | \item{att1}{Relevant numeric attribute between (-1 and 1)} 11 | \item{att2}{Relevant numeric attribute between (-1 and 1)} 12 | \item{att3}{Relevant numeric attribute between (-1 and 1)} 13 | \item{att4}{Relevant numeric attribute between (-1 and 1)} 14 | \item{att5}{Relevant numeric attribute between (-1 and 1)} 15 | \item{att6}{Relevant numeric attribute between (-1 and 1)} 16 | \item{att7}{Relevant numeric attribute between (-1 and 1)} 17 | \item{iatt8}{Irrelevant numeric attribute between (-1 and 1)} 18 | \item{iatt9}{Irrelevant numeric attribute between (-1 and 1)} 19 | \item{ratt10}{Redundant numeric attribute between (-1 and 1)} 20 | \item{y1}{Label 'y1' - Frequency: 0.17} 21 | \item{y2}{Label 'y2' - Frequency: 0.78} 22 | \item{y3}{Label 'y3' - Frequency: 0.19} 23 | \item{y4}{Label 'y4' - Frequency: 0.69} 24 | \item{y5}{Label 'y5' - Frequency: 0.17} 25 | } 26 | } 27 | \source{ 28 | Generated by \url{http://sites.labic.icmc.usp.br/mldatagen/} 29 | Configuration: 30 | \itemize{ 31 | \item Strategy: Hyperspheres 32 | \item Relevant Features: 7 33 | \item Irrelevant Features: 2 34 | \item Redundant Features: 1 35 | \item Number of Labels (q): 5 36 | \item Number of Instances: 100 37 | \item Noise (from 0 to 1): 0.05 38 | \item Maximum Radius/Half-Edge of the Hyperspheres/Hypercubes: 0.8 39 | \item Minimum Radius/Half-Edge of the Hyperspheres/Hypercubes: ((q/10)+1)/q 40 | } 41 | } 42 | \usage{ 43 | toyml 44 | } 45 | \description{ 46 | A toy multi-label dataset is a synthetic dataset generated by the tool 47 | \url{http://sites.labic.icmc.usp.br/mldatagen/} using the Hyperspheres 48 | strategy. Its purpose is to be used for small tests and examples. 49 | } 50 | \details{ 51 | General Information 52 | \itemize{ 53 | \item Cardinality: 2 54 | \item Density: 0.4 55 | \item Distinct multi-labels: 18 56 | \item Number of single labelsets: 5 57 | \item Max frequency: 23 58 | } 59 | } 60 | \keyword{datasets} 61 | -------------------------------------------------------------------------------- /man/mlknn.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_mlknn.R 3 | \name{mlknn} 4 | \alias{mlknn} 5 | \title{Multi-label KNN (ML-KNN) for multi-label Classification} 6 | \usage{ 7 | mlknn( 8 | mdata, 9 | k = 10, 10 | s = 1, 11 | distance = "euclidean", 12 | ..., 13 | cores = getOption("utiml.cores", 1), 14 | seed = getOption("utiml.seed", NA) 15 | ) 16 | } 17 | \arguments{ 18 | \item{mdata}{A mldr dataset used to train the binary models.} 19 | 20 | \item{k}{The number of neighbors. (Default: \code{10})} 21 | 22 | \item{s}{Smoothing parameter controlling the strength of uniform prior. When 23 | it is set to be 1, we have the Laplace smoothing. (Default: \code{1}).} 24 | 25 | \item{distance}{The name of method used to compute the distance. See 26 | \code{\link[stats]{dist}} to the list of options. 27 | (Default: \code{"euclidian"})} 28 | 29 | \item{...}{Not used.} 30 | 31 | \item{cores}{Ignored because this method does not support multi-core.} 32 | 33 | \item{seed}{Ignored because this method is deterministic.} 34 | } 35 | \value{ 36 | An object of class \code{MLKNNmodel} containing the set of fitted 37 | models, including: 38 | \describe{ 39 | \item{labels}{A vector with the label names.} 40 | \item{prior}{The prior probability of each label to occur.} 41 | \item{posterior}{The posterior probability of each label to occur given 42 | that k neighbors have it.} 43 | } 44 | } 45 | \description{ 46 | Create a ML-KNN classifier to predict multi-label data. It is a multi-label 47 | lazy learning, which is derived from the traditional K-nearest neighbor (KNN) 48 | algorithm. For each unseen instance, its K nearest neighbors in the training 49 | set are identified and based on statistical information gained from the label 50 | sets of these neighboring instances, the maximum a posteriori (MAP) principle 51 | is utilized to determine the label set for the unseen instance. 52 | } 53 | \examples{ 54 | model <- mlknn(toyml, k=3) 55 | pred <- predict(model, toyml) 56 | } 57 | \references{ 58 | Zhang, M.L. L., & Zhou, Z.H. H. (2007). ML-KNN: A lazy learning approach 59 | to multi-label learning. Pattern Recognition, 40(7), 2038-2048. 60 | } 61 | \concept{Adaptatio methods} 62 | -------------------------------------------------------------------------------- /man/pcut_threshold.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/threshold.R 3 | \name{pcut_threshold} 4 | \alias{pcut_threshold} 5 | \alias{pcut_threshold.default} 6 | \alias{pcut_threshold.mlresult} 7 | \title{Proportional Thresholding (PCut)} 8 | \usage{ 9 | pcut_threshold(prediction, ratio, probability = FALSE) 10 | 11 | \method{pcut_threshold}{default}(prediction, ratio, probability = FALSE) 12 | 13 | \method{pcut_threshold}{mlresult}(prediction, ratio, probability = FALSE) 14 | } 15 | \arguments{ 16 | \item{prediction}{A matrix or mlresult.} 17 | 18 | \item{ratio}{A single value between 0 and 1 or a list with ratio values 19 | contained one value per label.} 20 | 21 | \item{probability}{A logical value. If \code{TRUE} the predicted values are 22 | the score between 0 and 1, otherwise the values are bipartition 0 or 1. 23 | (Default: \code{FALSE})} 24 | } 25 | \value{ 26 | A mlresult object. 27 | } 28 | \description{ 29 | Define the proportion of examples for each label will be positive. 30 | The Proportion Cut (PCut) method can be a label-wise or global method that 31 | calibrates the threshold(s) from the training data globally or per label. 32 | } 33 | \section{Methods (by class)}{ 34 | \itemize{ 35 | \item \code{default}: Proportional Thresholding (PCut) method for matrix 36 | 37 | \item \code{mlresult}: Proportional Thresholding (PCut) for mlresult 38 | }} 39 | 40 | \examples{ 41 | prediction <- matrix(runif(16), ncol = 4) 42 | pcut_threshold(prediction, .45) 43 | } 44 | \references{ 45 | Al-Otaibi, R., Flach, P., & Kull, M. (2014). Multi-label Classification: A 46 | Comparative Study on Threshold Selection Methods. In First International 47 | Workshop on Learning over Multiple Contexts (LMCE) at ECML-PKDD 2014. 48 | 49 | Largeron, C., Moulin, C., & Gery, M. (2012). MCut: A Thresholding Strategy 50 | for Multi-label Classification. In 11th International Symposium, IDA 2012 51 | (pp. 172-183). 52 | } 53 | \seealso{ 54 | Other threshold: 55 | \code{\link{fixed_threshold}()}, 56 | \code{\link{lcard_threshold}()}, 57 | \code{\link{mcut_threshold}()}, 58 | \code{\link{rcut_threshold}()}, 59 | \code{\link{scut_threshold}()}, 60 | \code{\link{subset_correction}()} 61 | } 62 | \concept{threshold} 63 | -------------------------------------------------------------------------------- /man/subset_correction.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/threshold.R 3 | \name{subset_correction} 4 | \alias{subset_correction} 5 | \title{Subset Correction of a predicted result} 6 | \usage{ 7 | subset_correction(mlresult, train_y, probability = FALSE) 8 | } 9 | \arguments{ 10 | \item{mlresult}{An object of mlresult that contain the scores and bipartition 11 | values.} 12 | 13 | \item{train_y}{A matrix/data.frame with all labels values of the training 14 | dataset or a mldr train dataset.} 15 | 16 | \item{probability}{A logical value. If \code{TRUE} the predicted values are 17 | the score between 0 and 1, otherwise the values are bipartition 0 or 1. 18 | (Default: \code{FALSE})} 19 | } 20 | \value{ 21 | A new mlresult where all results are present in the training 22 | labelsets. 23 | } 24 | \description{ 25 | This method restrict a multi-label learner to predict only label combinations 26 | whose existence is present in the (training) data. To this all labelsets 27 | that are predicted but are not found on training data is replaced by the most 28 | similar labelset. 29 | } 30 | \details{ 31 | If the most similar is not unique, those label combinations with higher 32 | frequency in the training data are preferred. The Hamming loss distance is 33 | used to determine the difference between the labelsets. 34 | } 35 | \note{ 36 | The original paper describes a method to create only bipartitions 37 | result, but we adapted the method to change the scores. Based on the 38 | base.threshold value the scores higher than the threshold value, but must be 39 | lower are changed to respect this restriction. If \code{NULL} this 40 | correction will be ignored. 41 | } 42 | \examples{ 43 | prediction <- predict(br(toyml, "RANDOM"), toyml) 44 | subset_correction(prediction, toyml) 45 | } 46 | \references{ 47 | Senge, R., Coz, J. J. del, & Hullermeier, E. (2013). Rectifying classifier 48 | chains for multi-label classification. In Workshop of Lernen, Wissen & 49 | Adaptivitat (LWA 2013) (pp. 162-169). Bamberg, Germany. 50 | } 51 | \seealso{ 52 | Other threshold: 53 | \code{\link{fixed_threshold}()}, 54 | \code{\link{lcard_threshold}()}, 55 | \code{\link{mcut_threshold}()}, 56 | \code{\link{pcut_threshold}()}, 57 | \code{\link{rcut_threshold}()}, 58 | \code{\link{scut_threshold}()} 59 | } 60 | \concept{threshold} 61 | -------------------------------------------------------------------------------- /man/lp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_lp.R 3 | \name{lp} 4 | \alias{lp} 5 | \title{Label Powerset for multi-label Classification} 6 | \usage{ 7 | lp( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | ..., 11 | cores = getOption("utiml.cores", 1), 12 | seed = getOption("utiml.seed", NA) 13 | ) 14 | } 15 | \arguments{ 16 | \item{mdata}{A mldr dataset used to train the binary models.} 17 | 18 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 19 | \code{options("utiml.base.algorithm", "SVM")})} 20 | 21 | \item{...}{Others arguments passed to the base algorithm for all subproblems} 22 | 23 | \item{cores}{Not used} 24 | 25 | \item{seed}{An optional integer used to set the seed. (Default: 26 | \code{options("utiml.seed", NA)})} 27 | } 28 | \value{ 29 | An object of class \code{LPmodel} containing the set of fitted 30 | models, including: 31 | \describe{ 32 | \item{labels}{A vector with the label names.} 33 | \item{model}{A multi-class model.} 34 | } 35 | } 36 | \description{ 37 | Create a Label Powerset model for multilabel classification. 38 | } 39 | \details{ 40 | Label Powerset is a simple transformation method to predict multi-label data. 41 | This is based on the multi-class approach to build a model where the classes 42 | are each labelset. 43 | } 44 | \examples{ 45 | model <- lp(toyml, "RANDOM") 46 | pred <- predict(model, toyml) 47 | } 48 | \references{ 49 | Boutell, M. R., Luo, J., Shen, X., & Brown, C. M. (2004). Learning 50 | multi-label scene classification. Pattern Recognition, 37(9), 1757-1771. 51 | } 52 | \seealso{ 53 | Other Transformation methods: 54 | \code{\link{brplus}()}, 55 | \code{\link{br}()}, 56 | \code{\link{cc}()}, 57 | \code{\link{clr}()}, 58 | \code{\link{dbr}()}, 59 | \code{\link{ebr}()}, 60 | \code{\link{ecc}()}, 61 | \code{\link{eps}()}, 62 | \code{\link{esl}()}, 63 | \code{\link{homer}()}, 64 | \code{\link{lift}()}, 65 | \code{\link{mbr}()}, 66 | \code{\link{ns}()}, 67 | \code{\link{ppt}()}, 68 | \code{\link{prudent}()}, 69 | \code{\link{ps}()}, 70 | \code{\link{rakel}()}, 71 | \code{\link{rdbr}()}, 72 | \code{\link{rpc}()} 73 | 74 | Other Powerset: 75 | \code{\link{eps}()}, 76 | \code{\link{ppt}()}, 77 | \code{\link{ps}()}, 78 | \code{\link{rakel}()} 79 | } 80 | \concept{Powerset} 81 | \concept{Transformation methods} 82 | -------------------------------------------------------------------------------- /man/fixed_threshold.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/threshold.R 3 | \name{fixed_threshold} 4 | \alias{fixed_threshold} 5 | \alias{fixed_threshold.default} 6 | \alias{fixed_threshold.mlresult} 7 | \title{Apply a fixed threshold in the results} 8 | \usage{ 9 | fixed_threshold(prediction, threshold = 0.5, probability = FALSE) 10 | 11 | \method{fixed_threshold}{default}(prediction, threshold = 0.5, probability = FALSE) 12 | 13 | \method{fixed_threshold}{mlresult}(prediction, threshold = 0.5, probability = FALSE) 14 | } 15 | \arguments{ 16 | \item{prediction}{A matrix with scores/probabilities where the columns 17 | are the labels and the rows are the instances.} 18 | 19 | \item{threshold}{A single value between 0 and 1 or a list with threshold 20 | values contained one value per label.} 21 | 22 | \item{probability}{A logical value. If \code{TRUE} the predicted values are 23 | the score between 0 and 1, otherwise the values are bipartition 0 or 1. 24 | (Default: \code{FALSE})} 25 | } 26 | \value{ 27 | A mlresult object. 28 | } 29 | \description{ 30 | Transform a prediction matrix with scores/probabilities in a mlresult 31 | applying a fixed threshold. A global fixed threshold can be used of all 32 | labels or different fixed thresholds, one for each label. 33 | } 34 | \section{Methods (by class)}{ 35 | \itemize{ 36 | \item \code{default}: Fixed Threshold for matrix or data.frame 37 | 38 | \item \code{mlresult}: Fixed Threshold for mlresult 39 | }} 40 | 41 | \examples{ 42 | # Create a prediction matrix with scores 43 | result <- matrix( 44 | data = rnorm(9, 0.5, 0.2), 45 | ncol = 3, 46 | dimnames = list(NULL, c('lbl1', 'lb2', 'lb3')) 47 | ) 48 | 49 | # Use 0.5 as threshold 50 | fixed_threshold(result) 51 | 52 | # Use an threshold for each label 53 | fixed_threshold(result, c(0.4, 0.6, 0.7)) 54 | } 55 | \references{ 56 | Al-Otaibi, R., Flach, P., & Kull, M. (2014). Multi-label Classification: A 57 | Comparative Study on Threshold Selection Methods. In First International 58 | Workshop on Learning over Multiple Contexts (LMCE) at ECML-PKDD 2014. 59 | } 60 | \seealso{ 61 | Other threshold: 62 | \code{\link{lcard_threshold}()}, 63 | \code{\link{mcut_threshold}()}, 64 | \code{\link{pcut_threshold}()}, 65 | \code{\link{rcut_threshold}()}, 66 | \code{\link{scut_threshold}()}, 67 | \code{\link{subset_correction}()} 68 | } 69 | \concept{threshold} 70 | -------------------------------------------------------------------------------- /man/compute_multilabel_predictions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ensemble.R 3 | \name{compute_multilabel_predictions} 4 | \alias{compute_multilabel_predictions} 5 | \title{Compute the multi-label ensemble predictions based on some vote schema} 6 | \usage{ 7 | compute_multilabel_predictions( 8 | predictions, 9 | vote.schema = "maj", 10 | probability = getOption("utiml.use.probs", TRUE) 11 | ) 12 | } 13 | \arguments{ 14 | \item{predictions}{A list of multi-label predictions (mlresult).} 15 | 16 | \item{vote.schema}{Define the way that ensemble must compute the predictions. 17 | The default valid options are: 18 | \describe{ 19 | \item{'avg'}{Compute the mean of probabilities and the bipartitions} 20 | \item{'maj'}{Compute the majority of votes} 21 | \item{'max'}{Compute the higher probability for each instance/label} 22 | \item{'min'}{Compute the lower probability for each instance/label} 23 | }. (Default: 'maj')} 24 | 25 | \item{probability}{A logical value. If \code{TRUE} the predicted values are 26 | the score between 0 and 1, otherwise the values are bipartition 0 or 1.} 27 | } 28 | \value{ 29 | A mlresult with computed predictions. 30 | } 31 | \description{ 32 | Compute the multi-label ensemble predictions based on some vote schema 33 | } 34 | \note{ 35 | You can create your own vote schema, just create a method that receive 36 | two matrix (bipartitions and probabilities) and return a list with the 37 | final bipartitions and probabilities. 38 | 39 | Remember that this method will compute the ensemble votes for each label. 40 | Thus the bipartition and probability matrix passed as argument for this 41 | method is related with the bipartitions and probabilities for a single 42 | label. 43 | } 44 | \examples{ 45 | \donttest{ 46 | model <- br(toyml, "KNN") 47 | predictions <- list( 48 | predict(model, toyml[1:10], k=1), 49 | predict(model, toyml[1:10], k=3), 50 | predict(model, toyml[1:10], k=5) 51 | ) 52 | 53 | result <- compute_multilabel_predictions(predictions, "maj") 54 | 55 | ## Random choice 56 | random_choice <- function (bipartition, probability) { 57 | cols <- sample(seq(ncol(bipartition)), nrow(bipartition), replace = TRUE) 58 | list( 59 | bipartition = bipartition[cbind(seq(nrow(bipartition)), cols)], 60 | probability = probability[cbind(seq(nrow(probability)), cols)] 61 | ) 62 | } 63 | result <- compute_multilabel_predictions(predictions, "random_choice") 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /man/baseline.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_baseline.R 3 | \name{baseline} 4 | \alias{baseline} 5 | \title{Baseline reference for multilabel classification} 6 | \usage{ 7 | baseline( 8 | mdata, 9 | metric = c("general", "F1", "hamming-loss", "subset-accuracy", "ranking-loss"), 10 | ... 11 | ) 12 | } 13 | \arguments{ 14 | \item{mdata}{A mldr dataset used to train the binary models.} 15 | 16 | \item{metric}{Define the strategy used to predict the labels. 17 | 18 | The possible values are: \code{'general'}, \code{'F1'}, 19 | \code{'hamming-loss'} or \code{'subset-accuracy'}. See the description 20 | for more details. (Default: \code{'general'}).} 21 | 22 | \item{...}{not used} 23 | } 24 | \value{ 25 | An object of class \code{BASELINEmodel} containing the set of fitted 26 | models, including: 27 | \describe{ 28 | \item{labels}{A vector with the label names.} 29 | \item{predict}{A list with the labels that will be predicted.} 30 | } 31 | } 32 | \description{ 33 | Create a baseline model for multilabel classification. 34 | } 35 | \details{ 36 | Baseline is a naive multi-label classifier that maximize/minimize a specific 37 | measure without induces a learning model. It uses the general information 38 | about the labels in training dataset to estimate the labels in a test 39 | dataset. 40 | 41 | The follow strategies are available: 42 | \describe{ 43 | \item{\code{general}}{Predict the k most frequent labels, where k is the 44 | integer most close of label cardinality.} 45 | \item{\code{F1}}{Predict the most frequent labels that obtain the best F1 46 | measure in training data. In the original paper, the authors use the less 47 | frequent labels.} 48 | \item{\code{hamming-loss}}{Predict the labels that are associated with more 49 | than 50\% of instances.} 50 | \item{\code{subset-accuracy}}{Predict the most common labelset.} 51 | \item{\code{ranking-loss}}{Predict a ranking based on the most frequent 52 | labels.} 53 | } 54 | } 55 | \examples{ 56 | model <- baseline(toyml) 57 | pred <- predict(model, toyml) 58 | 59 | ## Change the metric 60 | model <- baseline(toyml, "F1") 61 | model <- baseline(toyml, "subset-accuracy") 62 | } 63 | \references{ 64 | Metz, J., Abreu, L. F. de, Cherman, E. A., & Monard, M. C. (2012). On the 65 | Estimation of Predictive Evaluation Measure Baselines for Multi-label 66 | Learning. In 13th Ibero-American Conference on AI (pp. 189-198). 67 | Cartagena de Indias, Colombia. 68 | } 69 | -------------------------------------------------------------------------------- /man/create_kfold_partition.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sampling.R 3 | \name{create_kfold_partition} 4 | \alias{create_kfold_partition} 5 | \title{Create the k-folds partition based on the specified algorithm} 6 | \usage{ 7 | create_kfold_partition( 8 | mdata, 9 | k = 10, 10 | method = c("random", "iterative", "stratified") 11 | ) 12 | } 13 | \arguments{ 14 | \item{mdata}{A mldr dataset.} 15 | 16 | \item{k}{The number of desirable folds. (Default: 10)} 17 | 18 | \item{method}{The method to split the data. The default methods are: 19 | \describe{ 20 | \item{random}{Split randomly the folds.} 21 | \item{iterative}{Split the folds considering the labels proportions 22 | individually. Some specific label can not occurs in all 23 | folds.} 24 | \item{stratified}{Split the folds considering the labelset 25 | proportions.} 26 | } 27 | You can also create your own partition method. See the note and example 28 | sections to more details. (Default: "random")} 29 | } 30 | \value{ 31 | An object of type kFoldPartition. 32 | } 33 | \description{ 34 | This method create the kFoldPartition object, from it is possible create 35 | the dataset partitions to train, test and optionally to validation. 36 | } 37 | \note{ 38 | To create your own split method, you need to build a function that 39 | receive a mldr object and a list with the proportions of examples in each 40 | fold and return an other list with the index of the elements for each fold. 41 | } 42 | \examples{ 43 | k10 <- create_kfold_partition(toyml, 10) 44 | k5 <- create_kfold_partition(toyml, 5, "stratified") 45 | 46 | sequencial_split <- function (mdata, r) { 47 | S <- list() 48 | 49 | amount <- trunc(r * mdata$measures$num.instances) 50 | indexes <- c(0, cumsum(amount)) 51 | indexes[length(r)+1] <- mdata$measures$num.instances 52 | 53 | S <- lapply(seq(length(r)), function (i) { 54 | seq(indexes[i]+1, indexes[i+1]) 55 | }) 56 | 57 | S 58 | } 59 | k3 <- create_kfold_partition(toyml, 3, "sequencial_split") 60 | } 61 | \references{ 62 | Sechidis, K., Tsoumakas, G., & Vlahavas, I. (2011). On the 63 | stratification of multi-label data. In Proceedings of the Machine 64 | Learning and Knowledge Discovery in Databases - European Conference, 65 | ECML PKDD (pp. 145-158). 66 | } 67 | \seealso{ 68 | \link[=partition_fold]{How to create the datasets from folds} 69 | 70 | Other sampling: 71 | \code{\link{create_holdout_partition}()}, 72 | \code{\link{create_random_subset}()}, 73 | \code{\link{create_subset}()} 74 | } 75 | \concept{sampling} 76 | -------------------------------------------------------------------------------- /man/rpc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_rpc.R 3 | \name{rpc} 4 | \alias{rpc} 5 | \title{Ranking by Pairwise Comparison (RPC) for multi-label Classification} 6 | \usage{ 7 | rpc( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | ..., 11 | cores = getOption("utiml.cores", 1), 12 | seed = getOption("utiml.seed", NA) 13 | ) 14 | } 15 | \arguments{ 16 | \item{mdata}{A mldr dataset used to train the binary models.} 17 | 18 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 19 | \code{options("utiml.base.algorithm", "SVM")})} 20 | 21 | \item{...}{Others arguments passed to the base algorithm for all subproblems} 22 | 23 | \item{cores}{The number of cores to parallelize the training. Values higher 24 | than 1 require the \pkg{parallel} package. (Default: 25 | \code{options("utiml.cores", 1)})} 26 | 27 | \item{seed}{An optional integer used to set the seed. This is useful when 28 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 29 | } 30 | \value{ 31 | An object of class \code{RPCmodel} containing the set of fitted 32 | models, including: 33 | \describe{ 34 | \item{labels}{A vector with the label names.} 35 | \item{models}{A list of the generated models, named by the label names.} 36 | } 37 | } 38 | \description{ 39 | Create a RPC model for multilabel classification. 40 | } 41 | \details{ 42 | RPC is a simple transformation method that uses pairwise classification to 43 | predict multi-label data. This is based on the one-versus-one approach to 44 | build a specific model for each label combination. 45 | } 46 | \examples{ 47 | model <- rpc(toyml, "RANDOM") 48 | pred <- predict(model, toyml) 49 | } 50 | \references{ 51 | Hullermeier, E., Furnkranz, J., Cheng, W., & Brinker, K. (2008). 52 | Label ranking by learning pairwise preferences. Artificial Intelligence, 53 | 172(16-17), 1897-1916. 54 | } 55 | \seealso{ 56 | Other Transformation methods: 57 | \code{\link{brplus}()}, 58 | \code{\link{br}()}, 59 | \code{\link{cc}()}, 60 | \code{\link{clr}()}, 61 | \code{\link{dbr}()}, 62 | \code{\link{ebr}()}, 63 | \code{\link{ecc}()}, 64 | \code{\link{eps}()}, 65 | \code{\link{esl}()}, 66 | \code{\link{homer}()}, 67 | \code{\link{lift}()}, 68 | \code{\link{lp}()}, 69 | \code{\link{mbr}()}, 70 | \code{\link{ns}()}, 71 | \code{\link{ppt}()}, 72 | \code{\link{prudent}()}, 73 | \code{\link{ps}()}, 74 | \code{\link{rakel}()}, 75 | \code{\link{rdbr}()} 76 | 77 | Other Pairwise methods: 78 | \code{\link{clr}()} 79 | } 80 | \concept{Pairwise methods} 81 | \concept{Transformation methods} 82 | -------------------------------------------------------------------------------- /man/br.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_br.R 3 | \name{br} 4 | \alias{br} 5 | \title{Binary Relevance for multi-label Classification} 6 | \usage{ 7 | br( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | ..., 11 | cores = getOption("utiml.cores", 1), 12 | seed = getOption("utiml.seed", NA) 13 | ) 14 | } 15 | \arguments{ 16 | \item{mdata}{A mldr dataset used to train the binary models.} 17 | 18 | \item{base.algorithm}{A string with the name of the base algorithm (Default: 19 | \code{options("utiml.base.algorithm", "SVM")})} 20 | 21 | \item{...}{Others arguments passed to the base algorithm for all subproblems} 22 | 23 | \item{cores}{The number of cores to parallelize the training. (Default: 24 | \code{options("utiml.cores", 1)})} 25 | 26 | \item{seed}{An optional integer used to set the seed. This is useful when 27 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 28 | } 29 | \value{ 30 | An object of class \code{BRmodel} containing the set of fitted 31 | models, including: 32 | \describe{ 33 | \item{labels}{A vector with the label names.} 34 | \item{models}{A list of the generated models, named by the label names.} 35 | } 36 | } 37 | \description{ 38 | Create a Binary Relevance model for multilabel classification. 39 | } 40 | \details{ 41 | Binary Relevance is a simple and effective transformation method to predict 42 | multi-label data. This is based on the one-versus-all approach to build a 43 | specific model for each label. 44 | } 45 | \examples{ 46 | model <- br(toyml, "RANDOM") 47 | pred <- predict(model, toyml) 48 | 49 | \donttest{ 50 | # Use SVM as base algorithm 51 | model <- br(toyml, "SVM") 52 | pred <- predict(model, toyml) 53 | 54 | # Change the base algorithm and use 2 CORES 55 | model <- br(toyml[1:50], 'RF', cores = 2, seed = 123) 56 | 57 | # Set a parameters for all subproblems 58 | model <- br(toyml, 'KNN', k=5) 59 | } 60 | } 61 | \references{ 62 | Boutell, M. R., Luo, J., Shen, X., & Brown, C. M. (2004). Learning 63 | multi-label scene classification. Pattern Recognition, 37(9), 1757-1771. 64 | } 65 | \seealso{ 66 | Other Transformation methods: 67 | \code{\link{brplus}()}, 68 | \code{\link{cc}()}, 69 | \code{\link{clr}()}, 70 | \code{\link{dbr}()}, 71 | \code{\link{ebr}()}, 72 | \code{\link{ecc}()}, 73 | \code{\link{eps}()}, 74 | \code{\link{esl}()}, 75 | \code{\link{homer}()}, 76 | \code{\link{lift}()}, 77 | \code{\link{lp}()}, 78 | \code{\link{mbr}()}, 79 | \code{\link{ns}()}, 80 | \code{\link{ppt}()}, 81 | \code{\link{prudent}()}, 82 | \code{\link{ps}()}, 83 | \code{\link{rakel}()}, 84 | \code{\link{rdbr}()}, 85 | \code{\link{rpc}()} 86 | } 87 | \concept{Transformation methods} 88 | -------------------------------------------------------------------------------- /man/predict.DBRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_dbr.R 3 | \name{predict.DBRmodel} 4 | \alias{predict.DBRmodel} 5 | \title{Predict Method for DBR} 6 | \usage{ 7 | \method{predict}{DBRmodel}( 8 | object, 9 | newdata, 10 | estimative = NULL, 11 | probability = getOption("utiml.use.probs", TRUE), 12 | ..., 13 | cores = getOption("utiml.cores", 1), 14 | seed = getOption("utiml.seed", NA) 15 | ) 16 | } 17 | \arguments{ 18 | \item{object}{Object of class '\code{DBRmodel}'.} 19 | 20 | \item{newdata}{An object containing the new input data. This must be a 21 | matrix, data.frame or a mldr object.} 22 | 23 | \item{estimative}{A matrix containing the bipartition result of other 24 | multi-label classification algorithm or an mlresult object with the 25 | predictions.} 26 | 27 | \item{probability}{Logical indicating whether class probabilities should be 28 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 29 | 30 | \item{...}{Others arguments passed to the base algorithm prediction for all 31 | subproblems.} 32 | 33 | \item{cores}{The number of cores to parallelize the training. Values higher 34 | than 1 require the \pkg{parallel} package. (Default: 35 | \code{options("utiml.cores", 1)})} 36 | 37 | \item{seed}{An optional integer used to set the seed. This is useful when 38 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 39 | } 40 | \value{ 41 | An object of type mlresult, based on the parameter probability. 42 | } 43 | \description{ 44 | This function predicts values based upon a model trained by \code{dbr}. 45 | In general this method is a restricted version of 46 | \code{\link{predict.BRPmodel}} using the 'NU' strategy. 47 | } 48 | \details{ 49 | As new feature is possible to use other multi-label classifier to predict the 50 | estimate values of each label. To this use the prediction argument to inform 51 | a result of other multi-label algorithm. 52 | } 53 | \examples{ 54 | \donttest{ 55 | # Predict SVM scores 56 | model <- dbr(toyml) 57 | pred <- predict(model, toyml) 58 | 59 | # Passing a specif parameter for SVM predict algorithm 60 | pred <- predict(model, toyml, na.action = na.fail) 61 | 62 | # Using other classifier (EBR) to made the labels estimatives 63 | estimative <- predict(ebr(toyml), toyml) 64 | model <- dbr(toyml, estimate.models = FALSE) 65 | pred <- predict(model, toyml, estimative = estimative) 66 | } 67 | } 68 | \references{ 69 | Montanes, E., Senge, R., Barranquero, J., Ramon Quevedo, J., Jose Del Coz, 70 | J., & Hullermeier, E. (2014). Dependent binary relevance models for 71 | multi-label classification. Pattern Recognition, 47(3), 1494-1508. 72 | } 73 | \seealso{ 74 | \code{\link[=dbr]{Dependent Binary Relevance (DBR)}} 75 | } 76 | -------------------------------------------------------------------------------- /man/lift.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_lift.R 3 | \name{lift} 4 | \alias{lift} 5 | \title{LIFT for multi-label Classification} 6 | \usage{ 7 | lift( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | ratio = 0.1, 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{mdata}{A mldr dataset used to train the binary models.} 18 | 19 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 20 | \code{options("utiml.base.algorithm", "SVM")})} 21 | 22 | \item{ratio}{Control the number of clusters being retained. Must be between 23 | 0 and 1. (Default: \code{0.1})} 24 | 25 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 26 | 27 | \item{cores}{The number of cores to parallelize the training. Values higher 28 | than 1 require the \pkg{parallel} package. (Default: 29 | \code{options("utiml.cores", 1)})} 30 | 31 | \item{seed}{An optional integer used to set the seed. This is useful when 32 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 33 | } 34 | \value{ 35 | An object of class \code{LIFTmodel} containing the set of fitted 36 | models, including: 37 | \describe{ 38 | \item{labels}{A vector with the label names.} 39 | \item{models}{A list of the generated models, named by the label names.} 40 | } 41 | } 42 | \description{ 43 | Create a multi-label learning with Label specIfic FeaTures (LIFT) model. 44 | } 45 | \details{ 46 | LIFT firstly constructs features specific to each label by conducting 47 | clustering analysis on its positive and negative instances, and then performs 48 | training and testing by querying the clustering results. 49 | } 50 | \examples{ 51 | model <- lift(toyml, "RANDOM") 52 | pred <- predict(model, toyml) 53 | 54 | \donttest{ 55 | # Runing lift with a specific ratio 56 | model <- lift(toyml, "RF", 0.15) 57 | } 58 | } 59 | \references{ 60 | Zhang, M.-L., & Wu, L. (2015). Lift: Multi-Label Learning with 61 | Label-Specific Features. IEEE Transactions on Pattern Analysis and Machine 62 | Intelligence, 37(1), 107-120. 63 | } 64 | \seealso{ 65 | Other Transformation methods: 66 | \code{\link{brplus}()}, 67 | \code{\link{br}()}, 68 | \code{\link{cc}()}, 69 | \code{\link{clr}()}, 70 | \code{\link{dbr}()}, 71 | \code{\link{ebr}()}, 72 | \code{\link{ecc}()}, 73 | \code{\link{eps}()}, 74 | \code{\link{esl}()}, 75 | \code{\link{homer}()}, 76 | \code{\link{lp}()}, 77 | \code{\link{mbr}()}, 78 | \code{\link{ns}()}, 79 | \code{\link{ppt}()}, 80 | \code{\link{prudent}()}, 81 | \code{\link{ps}()}, 82 | \code{\link{rakel}()}, 83 | \code{\link{rdbr}()}, 84 | \code{\link{rpc}()} 85 | } 86 | \concept{Transformation methods} 87 | -------------------------------------------------------------------------------- /man/mlpredict.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/base_learner.R 3 | \name{mlpredict} 4 | \alias{mlpredict} 5 | \title{Prediction transformation problems} 6 | \usage{ 7 | mlpredict(model, newdata, ...) 8 | } 9 | \arguments{ 10 | \item{model}{An object model returned by some mltrain method, its class 11 | determine the name of this method.} 12 | 13 | \item{newdata}{A data.frame with the new data to be predicted.} 14 | 15 | \item{...}{Others arguments passed to the predict method.} 16 | } 17 | \value{ 18 | A matrix with the probabilities of each class value/example, 19 | where the rows are the examples and the columns the class values. 20 | } 21 | \description{ 22 | Base classifiers are used to build models to solve the the transformation 23 | problems. To create a new base classifier, two steps are necessary: 24 | \enumerate{ 25 | \item Create a train method 26 | \item Create a prediction method 27 | } 28 | This section is about how to create the second step: a prediction method. 29 | To create a new train method see \code{\link{mltrain}} documentation. 30 | } 31 | \section{How to create a new prediction base method}{ 32 | 33 | Fist is necessary to know the class of model generate by the respective train 34 | method, because this name determines the method name. It must start with 35 | \code{'mlpredict.'}, followed by the model class name, e.g. a model with 36 | class 'fooModel' must be called as \code{mlpredict.fooModel}. 37 | 38 | After defined the name, you need to implement your prediction base method. 39 | The model built on mltrain is available on \code{model} parameter and the 40 | \code{newdata} is the data to be predict. 41 | 42 | The return of this method must be a data.frame with two columns called 43 | \code{"prediction"} and \code{"probability"}. The first column contains the 44 | predicted class and the second the probability/score/confidence of this 45 | prediction. The rows represents the examples. 46 | } 47 | 48 | \examples{ 49 | 50 | # Create a method that predict always the first class 51 | # The model must be of the class 'fooModel' 52 | mlpredict.fooModel <- function (model, newdata, ...) { 53 | # Predict the first class with a random confidence 54 | data.frame( 55 | prediction = rep(model$classes[1], nrow(newdata)), 56 | probability = sapply(runif(nrow(newdata)), function (score) { 57 | max(score, 1 - score) 58 | }), 59 | row.names = rownames(newdata) 60 | ) 61 | } 62 | 63 | \donttest{ 64 | # Create a SVM predict method using the e1071 package (the class of SVM model 65 | # from e1071 package is 'svm') 66 | library(e1071) 67 | mlpredict.svm <- function (dataset, newdata, ...) { 68 | result <- predict(model, newdata, probability = TRUE, ...) 69 | attr(result, 'probabilities') 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /man/clr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_clr.R 3 | \name{clr} 4 | \alias{clr} 5 | \title{Calibrated Label Ranking (CLR) for multi-label Classification} 6 | \usage{ 7 | clr( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | ..., 11 | cores = getOption("utiml.cores", 1), 12 | seed = getOption("utiml.seed", NA) 13 | ) 14 | } 15 | \arguments{ 16 | \item{mdata}{A mldr dataset used to train the binary models.} 17 | 18 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 19 | \code{options("utiml.base.algorithm", "SVM")})} 20 | 21 | \item{...}{Others arguments passed to the base algorithm for all subproblems} 22 | 23 | \item{cores}{The number of cores to parallelize the training. Values higher 24 | than 1 require the \pkg{parallel} package. (Default: 25 | \code{options("utiml.cores", 1)})} 26 | 27 | \item{seed}{An optional integer used to set the seed. This is useful when 28 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 29 | } 30 | \value{ 31 | An object of class \code{RPCmodel} containing the set of fitted 32 | models, including: 33 | \describe{ 34 | \item{labels}{A vector with the label names.} 35 | \item{rpcmodel}{A RPC model.} 36 | \item{brmodel}{A BR model used to calibrated the labels.} 37 | } 38 | } 39 | \description{ 40 | Create a CLR model for multilabel classification. 41 | } 42 | \details{ 43 | CLR is an extension of label ranking that incorporates the calibrated 44 | scenario. The introduction of an artificial calibration label, 45 | separates the relevant from the irrelevant labels. 46 | } 47 | \examples{ 48 | model <- clr(toyml, "RANDOM") 49 | pred <- predict(model, toyml) 50 | } 51 | \references{ 52 | Brinker, K., Furnkranz, J., & Hullermeier, E. (2006). A unified model for 53 | multilabel classification and ranking. In Proceeding of the ECAI 2006: 54 | 17th European Conference on Artificial Intelligence. p. 489-493. 55 | Furnkranz, J., Hullermeier, E., Loza Mencia, E., & Brinker, K. (2008). 56 | Multilabel classification via calibrated label ranking. 57 | Machine Learning, 73(2), 133-153. 58 | } 59 | \seealso{ 60 | Other Transformation methods: 61 | \code{\link{brplus}()}, 62 | \code{\link{br}()}, 63 | \code{\link{cc}()}, 64 | \code{\link{dbr}()}, 65 | \code{\link{ebr}()}, 66 | \code{\link{ecc}()}, 67 | \code{\link{eps}()}, 68 | \code{\link{esl}()}, 69 | \code{\link{homer}()}, 70 | \code{\link{lift}()}, 71 | \code{\link{lp}()}, 72 | \code{\link{mbr}()}, 73 | \code{\link{ns}()}, 74 | \code{\link{ppt}()}, 75 | \code{\link{prudent}()}, 76 | \code{\link{ps}()}, 77 | \code{\link{rakel}()}, 78 | \code{\link{rdbr}()}, 79 | \code{\link{rpc}()} 80 | 81 | Other Pairwise methods: 82 | \code{\link{rpc}()} 83 | } 84 | \concept{Pairwise methods} 85 | \concept{Transformation methods} 86 | -------------------------------------------------------------------------------- /man/ps.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ps.R 3 | \name{ps} 4 | \alias{ps} 5 | \title{Pruned Set for multi-label Classification} 6 | \usage{ 7 | ps( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | p = 3, 11 | strategy = c("A", "B"), 12 | b = 2, 13 | ..., 14 | cores = getOption("utiml.cores", 1), 15 | seed = getOption("utiml.seed", NA) 16 | ) 17 | } 18 | \arguments{ 19 | \item{mdata}{A mldr dataset used to train the binary models.} 20 | 21 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 22 | \code{options("utiml.base.algorithm", "SVM")})} 23 | 24 | \item{p}{Number of instances to prune. All labelsets that occurs p times or 25 | less in the training data is removed. (Default: 3)} 26 | 27 | \item{strategy}{The strategy (A or B) for processing infrequent labelsets. 28 | (Default: A).} 29 | 30 | \item{b}{The number used by the strategy for processing infrequent labelsets.} 31 | 32 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 33 | 34 | \item{cores}{Not used} 35 | 36 | \item{seed}{An optional integer used to set the seed. (Default: 37 | \code{options("utiml.seed", NA)})} 38 | } 39 | \value{ 40 | An object of class \code{PSmodel} containing the set of fitted 41 | models, including: 42 | \describe{ 43 | \item{labels}{A vector with the label names.} 44 | \item{model}{A LP model contained only the most common labelsets.} 45 | } 46 | } 47 | \description{ 48 | Create a Pruned Set model for multilabel classification. 49 | } 50 | \details{ 51 | Pruned Set (PS) is a multi-class transformation that remove the less common 52 | classes to predict multi-label data. 53 | } 54 | \examples{ 55 | model <- ps(toyml, "RANDOM") 56 | pred <- predict(model, toyml) 57 | 58 | \donttest{ 59 | ##Change default configurations 60 | model <- ps(toyml, "RF", p=4, strategy="B", b=1) 61 | } 62 | } 63 | \references{ 64 | Read, J., Pfahringer, B., & Holmes, G. (2008). Multi-label classification 65 | using ensembles of pruned sets. In Proceedings - IEEE International 66 | Conference on Data Mining, ICDM (pp. 995–1000). 67 | } 68 | \seealso{ 69 | Other Transformation methods: 70 | \code{\link{brplus}()}, 71 | \code{\link{br}()}, 72 | \code{\link{cc}()}, 73 | \code{\link{clr}()}, 74 | \code{\link{dbr}()}, 75 | \code{\link{ebr}()}, 76 | \code{\link{ecc}()}, 77 | \code{\link{eps}()}, 78 | \code{\link{esl}()}, 79 | \code{\link{homer}()}, 80 | \code{\link{lift}()}, 81 | \code{\link{lp}()}, 82 | \code{\link{mbr}()}, 83 | \code{\link{ns}()}, 84 | \code{\link{ppt}()}, 85 | \code{\link{prudent}()}, 86 | \code{\link{rakel}()}, 87 | \code{\link{rdbr}()}, 88 | \code{\link{rpc}()} 89 | 90 | Other Powerset: 91 | \code{\link{eps}()}, 92 | \code{\link{lp}()}, 93 | \code{\link{ppt}()}, 94 | \code{\link{rakel}()} 95 | } 96 | \concept{Powerset} 97 | \concept{Transformation methods} 98 | -------------------------------------------------------------------------------- /man/esl.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_esl.R 3 | \name{esl} 4 | \alias{esl} 5 | \title{Ensemble of Single Label} 6 | \usage{ 7 | esl( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | m = 10, 11 | w = 1, 12 | ..., 13 | cores = getOption("utiml.cores", 1), 14 | seed = getOption("utiml.seed", NA) 15 | ) 16 | } 17 | \arguments{ 18 | \item{mdata}{A mldr dataset used to train the binary models.} 19 | 20 | \item{base.algorithm}{A string with the name of the base algorithm (Default: 21 | \code{options("utiml.base.algorithm", "SVM")})} 22 | 23 | \item{m}{The number of members used in the ensemble. (Default: 10)} 24 | 25 | \item{w}{The weight given to the choice of the less frequent labels. When it 26 | is 0, the labels will be random choose, when it is 1 the complement of the 27 | label frequency is used as the probability to choose each label. Values 28 | greater than 1 will privilege the less frequent labels. (Default: 1)} 29 | 30 | \item{...}{Others arguments passed to the base algorithm for all subproblems} 31 | 32 | \item{cores}{The number of cores to parallelize the training. (Default: 33 | \code{options("utiml.cores", 1)})} 34 | 35 | \item{seed}{An optional integer used to set the seed. This is useful when 36 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 37 | } 38 | \value{ 39 | An object of class \code{ESLmodel} containing the set of fitted 40 | models, including: 41 | \describe{ 42 | \item{labels}{A vector with the labels' frequencies.} 43 | \item{models}{A list of the multi-class models.} 44 | } 45 | } 46 | \description{ 47 | Create an Ensemble of Single Label model for multilabel classification. 48 | } 49 | \details{ 50 | ESL is an ensemble of multi-class model that uses the less frequent labels. 51 | This is based on the label ignore approach different members of the ensemble. 52 | } 53 | \examples{ 54 | model <- esl(toyml, "RANDOM") 55 | pred <- predict(model, toyml) 56 | 57 | \donttest{ 58 | # Use SVM as base algorithm 59 | model <- esl(toyml, "SVM") 60 | pred <- predict(model, toyml) 61 | 62 | # Change the base algorithm and use 2 CORES 63 | model <- esl(toyml[1:50], 'RF', cores = 2, seed = 123) 64 | 65 | # Set a parameters for all subproblems 66 | model <- esl(toyml, 'KNN', k=5) 67 | } 68 | } 69 | \seealso{ 70 | Other Transformation methods: 71 | \code{\link{brplus}()}, 72 | \code{\link{br}()}, 73 | \code{\link{cc}()}, 74 | \code{\link{clr}()}, 75 | \code{\link{dbr}()}, 76 | \code{\link{ebr}()}, 77 | \code{\link{ecc}()}, 78 | \code{\link{eps}()}, 79 | \code{\link{homer}()}, 80 | \code{\link{lift}()}, 81 | \code{\link{lp}()}, 82 | \code{\link{mbr}()}, 83 | \code{\link{ns}()}, 84 | \code{\link{ppt}()}, 85 | \code{\link{prudent}()}, 86 | \code{\link{ps}()}, 87 | \code{\link{rakel}()}, 88 | \code{\link{rdbr}()}, 89 | \code{\link{rpc}()} 90 | } 91 | \concept{Transformation methods} 92 | -------------------------------------------------------------------------------- /man/multilabel_confusion_matrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/evaluation.R 3 | \name{multilabel_confusion_matrix} 4 | \alias{multilabel_confusion_matrix} 5 | \title{Compute the confusion matrix for a multi-label prediction} 6 | \usage{ 7 | multilabel_confusion_matrix(mdata, mlresult) 8 | } 9 | \arguments{ 10 | \item{mdata}{A mldr dataset} 11 | 12 | \item{mlresult}{A mlresult prediction} 13 | } 14 | \value{ 15 | A mlconfmat object that contains: 16 | \describe{ 17 | \item{Z}{The bipartition matrix prediction.} 18 | \item{Fx}{The score/probability matrix prediction.} 19 | \item{R}{The ranking matrix prediction.} 20 | \item{Y}{The expected matrix bipartition.} 21 | \item{TP}{The True Positive matrix values.} 22 | \item{FP}{The False Positive matrix values.} 23 | \item{TN}{The True Negative matrix values.} 24 | \item{FN}{The False Negative matrix values.} 25 | \item{Zi}{The total of positive predictions for each instance.} 26 | \item{Yi}{The total of positive expected for each instance.} 27 | \item{TPi}{The total of True Positive predictions for each instance.} 28 | \item{FPi}{The total of False Positive predictions for each instance.} 29 | \item{TNi}{The total of True Negative predictions for each instance.} 30 | \item{FNi}{The total False Negative predictions for each instance.} 31 | \item{Zl}{The total of positive predictions for each label.} 32 | \item{Yl}{The total of positive expected for each label.} 33 | \item{TPl}{The total of True Positive predictions for each label.} 34 | \item{FPl}{The total of False Positive predictions for each label.} 35 | \item{TNl}{The total of True Negative predictions for each label.} 36 | \item{FNl}{The total False Negative predictions for each label.} 37 | } 38 | } 39 | \description{ 40 | The multi-label confusion matrix is an object that contains the prediction, 41 | the expected values and also a lot of pre-processed information related with 42 | these data. 43 | } 44 | \examples{ 45 | \donttest{ 46 | prediction <- predict(br(toyml), toyml) 47 | 48 | mlconfmat <- multilabel_confusion_matrix(toyml, prediction) 49 | 50 | # Label with the most number of True Positive values 51 | which.max(mlconfmat$TPl) 52 | 53 | # Number of wrong predictions for each label 54 | errors <- mlconfmat$FPl + mlconfmat$FNl 55 | 56 | # Examples predict with all labels 57 | which(mlconfmat$Zi == toyml$measures$num.labels) 58 | 59 | # You can join one or more mlconfmat 60 | part1 <- create_subset(toyml, 1:50) 61 | part2 <- create_subset(toyml, 51:100) 62 | confmatp1 <- multilabel_confusion_matrix(part1, prediction[1:50, ]) 63 | confmatp2 <- multilabel_confusion_matrix(part2, prediction[51:100, ]) 64 | mlconfmat <- confmatp1 + confmatp2 65 | } 66 | } 67 | \seealso{ 68 | Other evaluation: 69 | \code{\link{cv}()}, 70 | \code{\link{multilabel_evaluate}()}, 71 | \code{\link{multilabel_measures}()} 72 | } 73 | \concept{evaluation} 74 | -------------------------------------------------------------------------------- /man/cv.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cross_validation.R 3 | \name{cv} 4 | \alias{cv} 5 | \title{Multi-label cross-validation} 6 | \usage{ 7 | cv( 8 | mdata, 9 | method, 10 | ..., 11 | cv.folds = 10, 12 | cv.sampling = c("random", "iterative", "stratified"), 13 | cv.results = FALSE, 14 | cv.predictions = FALSE, 15 | cv.measures = "all", 16 | cv.cores = getOption("utiml.cores", 1), 17 | cv.seed = getOption("utiml.seed", NA) 18 | ) 19 | } 20 | \arguments{ 21 | \item{mdata}{A mldr dataset.} 22 | 23 | \item{method}{The multi-label classification method. It also accepts the name 24 | of the method as a string.} 25 | 26 | \item{...}{Additional parameters required by the method.} 27 | 28 | \item{cv.folds}{Number of folds. (Default: 10)} 29 | 30 | \item{cv.sampling}{The method to split the data. The default methods are: 31 | \describe{ 32 | \item{random}{Split randomly the folds.} 33 | \item{iterative}{Split the folds considering the labels proportions 34 | individually. Some specific label can not occurs in all 35 | folds.} 36 | \item{stratified}{Split the folds considering the labelset proportions.} 37 | } 38 | (Default: "random")} 39 | 40 | \item{cv.results}{Logical value indicating if the folds results should be 41 | reported (Default: FALSE).} 42 | 43 | \item{cv.predictions}{Logical value indicating if the predictions should be 44 | reported (Default: FALSE).} 45 | 46 | \item{cv.measures}{The measures names to be computed. Call 47 | \code{multilabel_measures()} to see the expected measures. You can also 48 | use \code{"bipartition"}, \code{"ranking"}, \code{"label-based"}, 49 | \code{"example-based"}, \code{"macro-based"}, \code{"micro-based"} and 50 | \code{"label-problem"} to include a set of measures. (Default: "all").} 51 | 52 | \item{cv.cores}{The number of cores to parallelize the cross validation 53 | procedure. (Default: \code{options("utiml.cores", 1)})} 54 | 55 | \item{cv.seed}{An optional integer used to set the seed. (Default: 56 | \code{options("utiml.seed", NA)})} 57 | } 58 | \value{ 59 | If cv.results and cv.prediction are FALSE, the return is a vector 60 | with the expected multi-label measures, otherwise, a list contained the 61 | multi-label and the other expected results (the label measures and/or the 62 | prediction object) for each fold. 63 | } 64 | \description{ 65 | Perform the cross validation procedure for multi-label learning. 66 | } 67 | \examples{ 68 | #Run 10 folds for BR method 69 | res1 <- cv(toyml, br, base.algorithm="RANDOM", cv.folds=10) 70 | 71 | #Run 3 folds for RAkEL method and get the fold results and the prediction 72 | res2 <- cv(mdata=toyml, method="rakel", base.algorithm="RANDOM", k=2, m=10, 73 | cv.folds=3, cv.results=TRUE, cv.predictions=TRUE) 74 | } 75 | \seealso{ 76 | Other evaluation: 77 | \code{\link{multilabel_confusion_matrix}()}, 78 | \code{\link{multilabel_evaluate}()}, 79 | \code{\link{multilabel_measures}()} 80 | } 81 | \concept{evaluation} 82 | -------------------------------------------------------------------------------- /R/data.R: -------------------------------------------------------------------------------- 1 | #' Toy multi-label dataset. 2 | #' 3 | #' A toy multi-label dataset is a synthetic dataset generated by the tool 4 | #' \url{http://sites.labic.icmc.usp.br/mldatagen/} using the Hyperspheres 5 | #' strategy. Its purpose is to be used for small tests and examples. 6 | #' 7 | #' @format A mldr object with 100 instances, 10 features and 5 labels: 8 | #' \describe{ 9 | #' \item{att1}{Relevant numeric attribute between (-1 and 1)} 10 | #' \item{att2}{Relevant numeric attribute between (-1 and 1)} 11 | #' \item{att3}{Relevant numeric attribute between (-1 and 1)} 12 | #' \item{att4}{Relevant numeric attribute between (-1 and 1)} 13 | #' \item{att5}{Relevant numeric attribute between (-1 and 1)} 14 | #' \item{att6}{Relevant numeric attribute between (-1 and 1)} 15 | #' \item{att7}{Relevant numeric attribute between (-1 and 1)} 16 | #' \item{iatt8}{Irrelevant numeric attribute between (-1 and 1)} 17 | #' \item{iatt9}{Irrelevant numeric attribute between (-1 and 1)} 18 | #' \item{ratt10}{Redundant numeric attribute between (-1 and 1)} 19 | #' \item{y1}{Label 'y1' - Frequency: 0.17} 20 | #' \item{y2}{Label 'y2' - Frequency: 0.78} 21 | #' \item{y3}{Label 'y3' - Frequency: 0.19} 22 | #' \item{y4}{Label 'y4' - Frequency: 0.69} 23 | #' \item{y5}{Label 'y5' - Frequency: 0.17} 24 | #' } 25 | #' 26 | #' @details General Information 27 | #' \itemize{ 28 | #' \item Cardinality: 2 29 | #' \item Density: 0.4 30 | #' \item Distinct multi-labels: 18 31 | #' \item Number of single labelsets: 5 32 | #' \item Max frequency: 23 33 | #' } 34 | #' 35 | #' @source Generated by \url{http://sites.labic.icmc.usp.br/mldatagen/} 36 | #' Configuration: 37 | #' \itemize{ 38 | #' \item Strategy: Hyperspheres 39 | #' \item Relevant Features: 7 40 | #' \item Irrelevant Features: 2 41 | #' \item Redundant Features: 1 42 | #' \item Number of Labels (q): 5 43 | #' \item Number of Instances: 100 44 | #' \item Noise (from 0 to 1): 0.05 45 | #' \item Maximum Radius/Half-Edge of the Hyperspheres/Hypercubes: 0.8 46 | #' \item Minimum Radius/Half-Edge of the Hyperspheres/Hypercubes: ((q/10)+1)/q 47 | #' } 48 | "toyml" 49 | 50 | #' Foodtruck multi-label dataset. 51 | #' 52 | #' The foodtruck multi-label dataset is a real multi-label dataset, which uses 53 | #' habits and personal information to predict food truck cuisines. 54 | #' 55 | #' @format A mldr object with 407 instances, 21 features and 12 labels: 56 | #' 57 | #' @details General Information 58 | #' \itemize{ 59 | #' \item Cardinality: 2.28 60 | #' \item Density: 0.19 61 | #' \item Distinct multi-labels: 117 62 | #' \item Number of single labelsets: 74 63 | #' \item Max frequency: 114 64 | #' } 65 | #' 66 | #' @source The dataset is described in: 67 | #' Rivolli A., Parker L.C., de Carvalho A.C.P.L.F. (2017) Food Truck 68 | #' Recommendation Using Multi-label Classification. In: Oliveira E., Gama J., 69 | #' Vale Z., Lopes Cardoso H. (eds) Progress in Artificial Intelligence. EPIA 70 | #' 2017. Lecture Notes in Computer Science, vol 10423. Springer, Cham 71 | "foodtruck" 72 | -------------------------------------------------------------------------------- /man/ns.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ns.R 3 | \name{ns} 4 | \alias{ns} 5 | \title{Nested Stacking for multi-label Classification} 6 | \usage{ 7 | ns( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | chain = NA, 11 | ..., 12 | predict.params = list(), 13 | cores = NULL, 14 | seed = getOption("utiml.seed", NA) 15 | ) 16 | } 17 | \arguments{ 18 | \item{mdata}{A mldr dataset used to train the binary models.} 19 | 20 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 21 | \code{options("utiml.base.algorithm", "SVM")})} 22 | 23 | \item{chain}{A vector with the label names to define the chain order. If 24 | empty the chain is the default label sequence of the dataset. (Default: 25 | \code{NA})} 26 | 27 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 28 | 29 | \item{predict.params}{A list of default arguments passed to the predict 30 | algorithm. (default: \code{list()})} 31 | 32 | \item{cores}{Ignored because this method does not support multi-core.} 33 | 34 | \item{seed}{An optional integer used to set the seed. 35 | (Default: \code{options("utiml.seed", NA)})} 36 | } 37 | \value{ 38 | An object of class \code{NSmodel} containing the set of fitted 39 | models, including: 40 | \describe{ 41 | \item{chain}{A vector with the chain order} 42 | \item{labels}{A vector with the label names in expected order} 43 | \item{labelset}{The matrix containing only labels values} 44 | \item{models}{A list of models named by the label names.} 45 | } 46 | } 47 | \description{ 48 | Create a Nested Stacking model for multilabel classification. 49 | } 50 | \details{ 51 | Nested Stacking is based on Classifier Chains transformation method to 52 | predict multi-label data. It differs from CC to predict the labels values in 53 | the training step and to regularize the output based on the labelsets 54 | available on training data. 55 | } 56 | \examples{ 57 | model <- ns(toyml, "RANDOM") 58 | pred <- predict(model, toyml) 59 | 60 | \donttest{ 61 | # Use a specific chain with C5.0 classifier 62 | mychain <- sample(rownames(toyml$labels)) 63 | model <- ns(toyml, 'C5.0', mychain) 64 | 65 | # Set a specific parameter 66 | model <- ns(toyml, 'KNN', k=5) 67 | } 68 | } 69 | \references{ 70 | Senge, R., Coz, J. J. del, & Hullermeier, E. (2013). Rectifying classifier 71 | chains for multi-label classification. In Workshop of Lernen, Wissen & 72 | Adaptivitat (LWA 2013) (pp. 162-169). Bamberg, Germany. 73 | } 74 | \seealso{ 75 | Other Transformation methods: 76 | \code{\link{brplus}()}, 77 | \code{\link{br}()}, 78 | \code{\link{cc}()}, 79 | \code{\link{clr}()}, 80 | \code{\link{dbr}()}, 81 | \code{\link{ebr}()}, 82 | \code{\link{ecc}()}, 83 | \code{\link{eps}()}, 84 | \code{\link{esl}()}, 85 | \code{\link{homer}()}, 86 | \code{\link{lift}()}, 87 | \code{\link{lp}()}, 88 | \code{\link{mbr}()}, 89 | \code{\link{ppt}()}, 90 | \code{\link{prudent}()}, 91 | \code{\link{ps}()}, 92 | \code{\link{rakel}()}, 93 | \code{\link{rdbr}()}, 94 | \code{\link{rpc}()} 95 | } 96 | \concept{Transformation methods} 97 | -------------------------------------------------------------------------------- /man/ppt.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ppt.R 3 | \name{ppt} 4 | \alias{ppt} 5 | \title{Pruned Problem Transformation for multi-label Classification} 6 | \usage{ 7 | ppt( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | p = 3, 11 | info.loss = FALSE, 12 | ..., 13 | cores = getOption("utiml.cores", 1), 14 | seed = getOption("utiml.seed", NA) 15 | ) 16 | } 17 | \arguments{ 18 | \item{mdata}{A mldr dataset used to train the binary models.} 19 | 20 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 21 | \code{options("utiml.base.algorithm", "SVM")})} 22 | 23 | \item{p}{Number of instances to prune. All labelsets that occurs p times or 24 | less in the training data is removed. (Default: 3)} 25 | 26 | \item{info.loss}{Logical value where \code{TRUE} means discard infrequent 27 | labelsets and \code{FALSE} means reintroduce infrequent labelsets via 28 | subsets. (Default: FALSE)} 29 | 30 | \item{...}{Others arguments passed to the base algorithm for all subproblems} 31 | 32 | \item{cores}{Not used} 33 | 34 | \item{seed}{An optional integer used to set the seed. (Default: 35 | \code{options("utiml.seed", NA)})} 36 | } 37 | \value{ 38 | An object of class \code{PPTmodel} containing the set of fitted 39 | models, including: 40 | \describe{ 41 | \item{labels}{A vector with the label names.} 42 | \item{model}{A LP model contained only the most common labelsets.} 43 | } 44 | } 45 | \description{ 46 | Create a Pruned Problem Transformation model for multilabel classification. 47 | } 48 | \details{ 49 | Pruned Problem Transformation (PPT) is a multi-class transformation that 50 | remove the less common classes to predict multi-label data. 51 | } 52 | \examples{ 53 | model <- ppt(toyml, "RANDOM") 54 | pred <- predict(model, toyml) 55 | 56 | \donttest{ 57 | ##Change default configurations 58 | model <- ppt(toyml, "RF", p=4, info.loss=TRUE) 59 | } 60 | } 61 | \references{ 62 | Read, J., Pfahringer, B., & Holmes, G. (2008). Multi-label classification 63 | using ensembles of pruned sets. In Proceedings - IEEE International 64 | Conference on Data Mining, ICDM (pp. 995–1000). 65 | Read, J. (2008). A pruned problem transformation method for multi-label 66 | classification. In Proceedings of the New Zealand Computer Science 67 | Research Student Conference (pp. 143-150). 68 | } 69 | \seealso{ 70 | Other Transformation methods: 71 | \code{\link{brplus}()}, 72 | \code{\link{br}()}, 73 | \code{\link{cc}()}, 74 | \code{\link{clr}()}, 75 | \code{\link{dbr}()}, 76 | \code{\link{ebr}()}, 77 | \code{\link{ecc}()}, 78 | \code{\link{eps}()}, 79 | \code{\link{esl}()}, 80 | \code{\link{homer}()}, 81 | \code{\link{lift}()}, 82 | \code{\link{lp}()}, 83 | \code{\link{mbr}()}, 84 | \code{\link{ns}()}, 85 | \code{\link{prudent}()}, 86 | \code{\link{ps}()}, 87 | \code{\link{rakel}()}, 88 | \code{\link{rdbr}()}, 89 | \code{\link{rpc}()} 90 | 91 | Other Powerset: 92 | \code{\link{eps}()}, 93 | \code{\link{lp}()}, 94 | \code{\link{ps}()}, 95 | \code{\link{rakel}()} 96 | } 97 | \concept{Powerset} 98 | \concept{Transformation methods} 99 | -------------------------------------------------------------------------------- /man/brplus.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_brplus.R 3 | \name{brplus} 4 | \alias{brplus} 5 | \title{BR+ or BRplus for multi-label Classification} 6 | \usage{ 7 | brplus( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | ..., 11 | cores = getOption("utiml.cores", 1), 12 | seed = getOption("utiml.seed", NA) 13 | ) 14 | } 15 | \arguments{ 16 | \item{mdata}{A mldr dataset used to train the binary models.} 17 | 18 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 19 | \code{options("utiml.base.algorithm", "SVM")})} 20 | 21 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 22 | 23 | \item{cores}{The number of cores to parallelize the training. Values higher 24 | than 1 require the \pkg{parallel} package. (Default: 25 | \code{options("utiml.cores", 1)})} 26 | 27 | \item{seed}{An optional integer used to set the seed. This is useful when 28 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 29 | } 30 | \value{ 31 | An object of class \code{BRPmodel} containing the set of fitted 32 | models, including: 33 | \describe{ 34 | \item{freq}{The label frequencies to use with the 'Stat' strategy} 35 | \item{initial}{The BR model to predict the values for the labels to 36 | initial step} 37 | \item{models}{A list of final models named by the label names.} 38 | } 39 | } 40 | \description{ 41 | Create a BR+ classifier to predict multi-label data. This is a simple approach 42 | that enables the binary classifiers to discover existing label dependency by 43 | themselves. The main idea of BR+ is to increment the feature space of the 44 | binary classifiers to let them discover existing label dependency by 45 | themselves. 46 | } 47 | \details{ 48 | This implementation has different strategy to predict the final set of labels 49 | for unlabeled examples, as proposed in original paper. 50 | } 51 | \examples{ 52 | # Use SVM as base algorithm 53 | model <- brplus(toyml, "RANDOM") 54 | pred <- predict(model, toyml) 55 | 56 | \donttest{ 57 | # Use Random Forest as base algorithm and 2 cores 58 | model <- brplus(toyml, 'RF', cores = 2, seed = 123) 59 | } 60 | } 61 | \references{ 62 | Cherman, E. A., Metz, J., & Monard, M. C. (2012). Incorporating label 63 | dependency into the binary relevance framework for multi-label 64 | classification. Expert Systems with Applications, 39(2), 1647-1655. 65 | } 66 | \seealso{ 67 | Other Transformation methods: 68 | \code{\link{br}()}, 69 | \code{\link{cc}()}, 70 | \code{\link{clr}()}, 71 | \code{\link{dbr}()}, 72 | \code{\link{ebr}()}, 73 | \code{\link{ecc}()}, 74 | \code{\link{eps}()}, 75 | \code{\link{esl}()}, 76 | \code{\link{homer}()}, 77 | \code{\link{lift}()}, 78 | \code{\link{lp}()}, 79 | \code{\link{mbr}()}, 80 | \code{\link{ns}()}, 81 | \code{\link{ppt}()}, 82 | \code{\link{prudent}()}, 83 | \code{\link{ps}()}, 84 | \code{\link{rakel}()}, 85 | \code{\link{rdbr}()}, 86 | \code{\link{rpc}()} 87 | 88 | Other Stacking methods: 89 | \code{\link{mbr}()} 90 | } 91 | \concept{Stacking methods} 92 | \concept{Transformation methods} 93 | -------------------------------------------------------------------------------- /man/mltrain.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/base_learner.R 3 | \name{mltrain} 4 | \alias{mltrain} 5 | \title{Build transformation models} 6 | \usage{ 7 | mltrain(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{A \code{mltransformation} object. This is used as a list and 11 | contains at least five values: 12 | \describe{ 13 | \item{object$data}{A data.frame with the train data, where the columns are 14 | the attributes and the rows are the examples.} 15 | \item{object$labelname}{The name of the class column.} 16 | \item{object$labelindex}{The column index of the class.} 17 | \item{object$mldataset}{The name of multi-label dataset.} 18 | \item{object$mlmethod}{The name of the multi-label method.} 19 | } 20 | Others values may be specified by the multi-label method.} 21 | 22 | \item{...}{Others arguments passed to the base method.} 23 | } 24 | \value{ 25 | A model object. The class of this model can be of any type, however, 26 | this object will be passed to the respective mlpredict method. 27 | } 28 | \description{ 29 | Base classifiers are used to build models to solve the the transformation 30 | problems. To create a new base classifier, two steps are necessary: 31 | \enumerate{ 32 | \item Create a train method 33 | \item Create a prediction method 34 | } 35 | This section is about how to create the first step: a train method. 36 | To create a new predict model see \code{\link{mlpredict}} documentation. 37 | } 38 | \section{How to create a new train base method}{ 39 | 40 | First, is necessary to define a name of your classifier, because this name 41 | determines the method name. The base method name must start with 42 | \code{mltrain.base} followed by the designed name, e.g. a \code{'FOO'} 43 | classify must be defined as \code{mltrain.baseFOO} (we suggest always use 44 | upper case names). 45 | 46 | Next, your method must receive at least two parameters (\code{object, ...}). 47 | Use \code{object$data[, object$labelindex]} or 48 | \code{object$data[, object$labelname]} to access the labels values and use 49 | \code{object$data[, -object$labelindex]} to access the predictive attributes. 50 | If you need to know which are the multi-label dataset and method, use 51 | \code{object$mldataset} and \code{object$mlmethod}, respectively. 52 | 53 | Finally, your method should return a model that will be used by the mlpredict 54 | method. Remember, that your method may be used to build binary and 55 | multi-class models. 56 | } 57 | 58 | \examples{ 59 | # Create a empty model of type FOO 60 | mltrain.baseFOO <- function (object, ...) { 61 | mymodel <- list( 62 | classes = as.character(unique(object$data[, object$labelindex])) 63 | ) 64 | class(mymodel) <- 'fooModel' 65 | mymodel 66 | } 67 | 68 | # Using this base method with Binary Relevance 69 | brmodel <- br(toyml, 'FOO') 70 | 71 | \donttest{ 72 | 73 | # Create a SVM method using the e1071 package 74 | library(e1071) 75 | mltrain.baseSVM <- function (object, ...) { 76 | traindata <- object$data[, -object$labelindex] 77 | labeldata <- object$data[, object$labelindex] 78 | model <- svm(traindata, labeldata, probability = TRUE, ...) 79 | model 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /man/homer.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_homer.R 3 | \name{homer} 4 | \alias{homer} 5 | \title{Hierarchy Of Multilabel classifiER (HOMER)} 6 | \usage{ 7 | homer( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | clusters = 3, 11 | method = c("balanced", "clustering", "random"), 12 | iteration = 100, 13 | ..., 14 | cores = getOption("utiml.cores", 1), 15 | seed = getOption("utiml.seed", NA) 16 | ) 17 | } 18 | \arguments{ 19 | \item{mdata}{A mldr dataset used to train the binary models.} 20 | 21 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 22 | \code{options("utiml.base.algorithm", "SVM")})} 23 | 24 | \item{clusters}{Number maximum of nodes in each level. (Default: 3)} 25 | 26 | \item{method}{The strategy used to organize the labels (create the 27 | meta-labels). The options are: "balanced", "clustering" and "random". 28 | (Default: "balanced").} 29 | 30 | \item{iteration}{The number max of iterations, used by balanced or clustering 31 | methods.} 32 | 33 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 34 | 35 | \item{cores}{The number of cores to parallelize the training. Values higher 36 | than 1 require the \pkg{parallel} package. (Default: 37 | \code{options("utiml.cores", 1)})} 38 | 39 | \item{seed}{An optional integer used to set the seed. (Default: 40 | \code{options("utiml.seed", NA)})} 41 | } 42 | \value{ 43 | An object of class \code{HOMERmodel} containing the set of fitted 44 | models, including: 45 | \describe{ 46 | \item{labels}{A vector with the label names.} 47 | \item{clusters}{The number of nodes in each level} 48 | \item{models}{The Hierarchy of BR models.} 49 | } 50 | } 51 | \description{ 52 | Create a Hierarchy Of Multilabel classifiER (HOMER). 53 | } 54 | \details{ 55 | HOMER is an algorithm for effective and computationally efficient multilabel 56 | classification in domains with many labels. It constructs a hierarchy of 57 | multilabel classifiers, each one dealing with a much smaller set of labels. 58 | } 59 | \examples{ 60 | model <- homer(toyml, "RANDOM") 61 | pred <- predict(model, toyml) 62 | 63 | \donttest{ 64 | ##Change default configurations 65 | model <- homer(toyml, "RF", clusters=5, method="clustering", iteration=10) 66 | } 67 | } 68 | \references{ 69 | Tsoumakas, G., Katakis, I., & Vlahavas, I. (2008). Effective and efficient 70 | multilabel classification in domains with large number of labels. In Proc. 71 | ECML/PKDD 2008 Workshop on Mining Multidimensional Data (MMD'08) 72 | (pp. 30-44). Antwerp, Belgium. 73 | } 74 | \seealso{ 75 | Other Transformation methods: 76 | \code{\link{brplus}()}, 77 | \code{\link{br}()}, 78 | \code{\link{cc}()}, 79 | \code{\link{clr}()}, 80 | \code{\link{dbr}()}, 81 | \code{\link{ebr}()}, 82 | \code{\link{ecc}()}, 83 | \code{\link{eps}()}, 84 | \code{\link{esl}()}, 85 | \code{\link{lift}()}, 86 | \code{\link{lp}()}, 87 | \code{\link{mbr}()}, 88 | \code{\link{ns}()}, 89 | \code{\link{ppt}()}, 90 | \code{\link{prudent}()}, 91 | \code{\link{ps}()}, 92 | \code{\link{rakel}()}, 93 | \code{\link{rdbr}()}, 94 | \code{\link{rpc}()} 95 | } 96 | \concept{Transformation methods} 97 | -------------------------------------------------------------------------------- /man/multilabel_evaluate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/evaluation.R 3 | \name{multilabel_evaluate} 4 | \alias{multilabel_evaluate} 5 | \alias{multilabel_evaluate.mldr} 6 | \alias{multilabel_evaluate.mlconfmat} 7 | \title{Evaluate multi-label predictions} 8 | \usage{ 9 | multilabel_evaluate(object, ...) 10 | 11 | \method{multilabel_evaluate}{mldr}(object, mlresult, measures = c("all"), labels = FALSE, ...) 12 | 13 | \method{multilabel_evaluate}{mlconfmat}(object, measures = c("all"), labels = FALSE, ...) 14 | } 15 | \arguments{ 16 | \item{object}{A mldr dataset or a mlconfmat confusion matrix} 17 | 18 | \item{...}{Extra parameters to specific measures.} 19 | 20 | \item{mlresult}{The prediction result (Optional, required only when the 21 | mldr is used).} 22 | 23 | \item{measures}{The measures names to be computed. Call 24 | \code{multilabel_measures()} to see the expected measures. You can also 25 | use \code{"bipartition"}, \code{"ranking"}, \code{"label-based"}, 26 | \code{"example-based"}, \code{"macro-based"}, \code{"micro-based"} and 27 | \code{"label-problem"} to include a set of measures. (Default: "all").} 28 | 29 | \item{labels}{Logical value defining if the label results should be also 30 | returned. (Default: \code{FALSE})} 31 | } 32 | \value{ 33 | If labels is FALSE return a vector with the expected multi-label 34 | measures, otherwise, a list contained the multi-label and label measures. 35 | } 36 | \description{ 37 | This method is used to evaluate multi-label predictions. You can create a 38 | confusion matrix object or use directly the test dataset and the predictions. 39 | You can also specify which measures do you desire use. 40 | } 41 | \section{Methods (by class)}{ 42 | \itemize{ 43 | \item \code{mldr}: Default S3 method 44 | 45 | \item \code{mlconfmat}: Default S3 method 46 | }} 47 | 48 | \examples{ 49 | \donttest{ 50 | prediction <- predict(br(toyml), toyml) 51 | 52 | # Compute all measures 53 | multilabel_evaluate(toyml, prediction) 54 | multilabel_evaluate(toyml, prediction, labels=TRUE) # Return a list 55 | 56 | # Compute bipartition measures 57 | multilabel_evaluate(toyml, prediction, "bipartition") 58 | 59 | # Compute multilples measures 60 | multilabel_evaluate(toyml, prediction, c("accuracy", "F1", "macro-based")) 61 | 62 | # Compute the confusion matrix before the measures 63 | cm <- multilabel_confusion_matrix(toyml, prediction) 64 | multilabel_evaluate(cm) 65 | multilabel_evaluate(cm, "example-based") 66 | multilabel_evaluate(cm, c("hamming-loss", "subset-accuracy", "F1")) 67 | } 68 | } 69 | \references{ 70 | Madjarov, G., Kocev, D., Gjorgjevikj, D., & Dzeroski, S. (2012). An 71 | extensive experimental comparison of methods for multi-label learning. 72 | Pattern Recognition, 45(9), 3084-3104. 73 | Zhang, M.-L., & Zhou, Z.-H. (2014). A Review on Multi-Label Learning 74 | Algorithms. IEEE Transactions on Knowledge and Data Engineering, 26(8), 75 | 1819-1837. 76 | Gibaja, E., & Ventura, S. (2015). A Tutorial on Multilabel Learning. 77 | ACM Comput. Surv., 47(3), 52:1-2:38. 78 | } 79 | \seealso{ 80 | Other evaluation: 81 | \code{\link{cv}()}, 82 | \code{\link{multilabel_confusion_matrix}()}, 83 | \code{\link{multilabel_measures}()} 84 | } 85 | \concept{evaluation} 86 | -------------------------------------------------------------------------------- /man/prudent.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_prudent.R 3 | \name{prudent} 4 | \alias{prudent} 5 | \title{PruDent classifier for multi-label Classification} 6 | \usage{ 7 | prudent( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | phi = 0, 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{mdata}{A mldr dataset used to train the binary models.} 18 | 19 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 20 | \code{options("utiml.base.algorithm", "SVM")})} 21 | 22 | \item{phi}{A value between 0 and 1 to determine the information gain. The 23 | value 0 include all labels in the second phase and the 1 none.} 24 | 25 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 26 | 27 | \item{cores}{The number of cores to parallelize the training. Values higher 28 | than 1 require the \pkg{parallel} package. (Default: 29 | \code{options("utiml.cores", 1)})} 30 | 31 | \item{seed}{An optional integer used to set the seed. This is useful when 32 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 33 | } 34 | \value{ 35 | An object of class \code{PruDentmodel} containing the set of fitted 36 | models, including: 37 | \describe{ 38 | \item{labels}{A vector with the label names.} 39 | \item{phi}{The value of \code{phi} parameter.} 40 | \item{IG}{The matrix of Information Gain used in combination 41 | with \code{phi} parameter to define the labels used in the second step. 42 | } 43 | \item{basemodel}{The BRModel used in the first iteration.} 44 | \item{metamodels}{A list of models named by the label names used in the 45 | second iteration. 46 | } 47 | } 48 | } 49 | \description{ 50 | Create a PruDent classifier to predict multi-label data. To this, two 51 | round of Binary Relevance is executed, such that, the first iteration 52 | generates new attributes to enrich the second prediction. 53 | } 54 | \details{ 55 | In the second phase only labels whose information gain is greater than a 56 | specific phi value is added. 57 | } 58 | \examples{ 59 | model <- prudent(toyml, "RANDOM") 60 | pred <- predict(model, toyml) 61 | 62 | \donttest{ 63 | # Use different phi correlation with C5.0 classifier 64 | model <- prudent(toyml, 'C5.0', 0.3) 65 | 66 | # Set a specific parameter 67 | model <- prudent(toyml, 'KNN', k=5) 68 | } 69 | } 70 | \references{ 71 | Alali, A., & Kubat, M. (2015). PruDent: A Pruned and Confident Stacking 72 | Approach for Multi-Label Classification. IEEE Transactions on Knowledge 73 | and Data Engineering, 27(9), 2480-2493. 74 | } 75 | \seealso{ 76 | Other Transformation methods: 77 | \code{\link{brplus}()}, 78 | \code{\link{br}()}, 79 | \code{\link{cc}()}, 80 | \code{\link{clr}()}, 81 | \code{\link{dbr}()}, 82 | \code{\link{ebr}()}, 83 | \code{\link{ecc}()}, 84 | \code{\link{eps}()}, 85 | \code{\link{esl}()}, 86 | \code{\link{homer}()}, 87 | \code{\link{lift}()}, 88 | \code{\link{lp}()}, 89 | \code{\link{mbr}()}, 90 | \code{\link{ns}()}, 91 | \code{\link{ppt}()}, 92 | \code{\link{ps}()}, 93 | \code{\link{rakel}()}, 94 | \code{\link{rdbr}()}, 95 | \code{\link{rpc}()} 96 | } 97 | \concept{Transformation methods} 98 | -------------------------------------------------------------------------------- /man/create_holdout_partition.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sampling.R 3 | \name{create_holdout_partition} 4 | \alias{create_holdout_partition} 5 | \title{Create a holdout partition based on the specified algorithm} 6 | \usage{ 7 | create_holdout_partition( 8 | mdata, 9 | partitions = c(train = 0.7, test = 0.3), 10 | method = c("random", "iterative", "stratified") 11 | ) 12 | } 13 | \arguments{ 14 | \item{mdata}{A mldr dataset.} 15 | 16 | \item{partitions}{A list of percentages or a single value. The sum of all 17 | values does not be greater than 1. If a single value is informed then the 18 | complement of them is applied to generated the second partition. If two or 19 | more values are informed and the sum of them is lower than 1 the partitions 20 | will be generated with the informed proportion. If partitions have names, 21 | they are used to name the return. (Default: \code{c(train=0.7, test=0.3)}).} 22 | 23 | \item{method}{The method to split the data. The default methods are: 24 | \describe{ 25 | \item{random}{Split randomly the folds.} 26 | \item{iterative}{Split the folds considering the labels proportions 27 | individually. Some specific label can not occurs in all 28 | folds.} 29 | \item{stratified}{Split the folds considering the labelset proportions.} 30 | } 31 | You can also create your own partition method. See the note and example 32 | sections to more details. (Default: "random")} 33 | } 34 | \value{ 35 | A list with at least two datasets sampled as specified in partitions 36 | parameter. 37 | } 38 | \description{ 39 | This method creates multi-label dataset for train, test, validation or other 40 | proposes the partition method defined in \code{method}. The number of 41 | partitions is defined in \code{partitions} parameter. Each instance is used 42 | in only one partition of division. 43 | } 44 | \note{ 45 | To create your own split method, you need to build a function that 46 | receive a mldr object and a list with the proportions of examples in each 47 | fold and return an other list with the index of the elements for each fold. 48 | } 49 | \examples{ 50 | dataset <- create_holdout_partition(toyml) 51 | names(dataset) 52 | ## [1] "train" "test" 53 | #dataset$train 54 | #dataset$test 55 | 56 | dataset <- create_holdout_partition(toyml, c(a=0.1, b=0.2, c=0.3, d=0.4)) 57 | #' names(dataset) 58 | #' ## [1] "a" "b" "c" "d" 59 | 60 | sequencial_split <- function (mdata, r) { 61 | S <- list() 62 | 63 | amount <- trunc(r * mdata$measures$num.instances) 64 | indexes <- c(0, cumsum(amount)) 65 | indexes[length(r)+1] <- mdata$measures$num.instances 66 | 67 | S <- lapply(seq(length(r)), function (i) { 68 | seq(indexes[i]+1, indexes[i+1]) 69 | }) 70 | 71 | S 72 | } 73 | dataset <- create_holdout_partition(toyml, method="sequencial_split") 74 | } 75 | \references{ 76 | Sechidis, K., Tsoumakas, G., & Vlahavas, I. (2011). On the 77 | stratification of multi-label data. In Proceedings of the Machine 78 | Learning and Knowledge Discovery in Databases - European Conference, 79 | ECML PKDD (pp. 145-158). 80 | } 81 | \seealso{ 82 | Other sampling: 83 | \code{\link{create_kfold_partition}()}, 84 | \code{\link{create_random_subset}()}, 85 | \code{\link{create_subset}()} 86 | } 87 | \concept{sampling} 88 | -------------------------------------------------------------------------------- /man/dbr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_dbr.R 3 | \name{dbr} 4 | \alias{dbr} 5 | \title{Dependent Binary Relevance (DBR) for multi-label Classification} 6 | \usage{ 7 | dbr( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | estimate.models = TRUE, 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{mdata}{A mldr dataset used to train the binary models.} 18 | 19 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 20 | \code{options("utiml.base.algorithm", "SVM")})} 21 | 22 | \item{estimate.models}{Logical value indicating whether is necessary build 23 | Binary Relevance classifier for estimate process. The default implementation 24 | use BR as estimators, however when other classifier is desirable then use 25 | the value \code{FALSE} to skip this process. (Default: \code{TRUE}).} 26 | 27 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 28 | 29 | \item{cores}{The number of cores to parallelize the training. Values higher 30 | than 1 require the \pkg{parallel} package. (Default: 31 | \code{options("utiml.cores", 1)})} 32 | 33 | \item{seed}{An optional integer used to set the seed. This is useful when 34 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 35 | } 36 | \value{ 37 | An object of class \code{DBRmodel} containing the set of fitted 38 | models, including: 39 | \describe{ 40 | \item{labels}{A vector with the label names.} 41 | \item{estimation}{The BR model to estimate the values for the labels. 42 | Only when the \code{estimate.models = TRUE}.} 43 | \item{models}{A list of final models named by the label names.} 44 | } 45 | } 46 | \description{ 47 | Create a DBR classifier to predict multi-label data. This is a simple approach 48 | that enables the binary classifiers to discover existing label dependency by 49 | themselves. The idea of DBR is exactly the same used in BR+ (the training 50 | method is the same, excepted by the argument \code{estimate.models} that 51 | indicate if the estimated models must be created). 52 | } 53 | \examples{ 54 | model <- dbr(toyml, "RANDOM") 55 | pred <- predict(model, toyml) 56 | 57 | \donttest{ 58 | # Use Random Forest as base algorithm and 2 cores 59 | model <- dbr(toyml, 'RF', cores = 2) 60 | } 61 | } 62 | \references{ 63 | Montanes, E., Senge, R., Barranquero, J., Ramon Quevedo, J., Jose Del Coz, 64 | J., & Hullermeier, E. (2014). Dependent binary relevance models for 65 | multi-label classification. Pattern Recognition, 47(3), 1494-1508. 66 | } 67 | \seealso{ 68 | \code{\link[=rdbr]{Recursive Dependent Binary Relevance}} 69 | 70 | Other Transformation methods: 71 | \code{\link{brplus}()}, 72 | \code{\link{br}()}, 73 | \code{\link{cc}()}, 74 | \code{\link{clr}()}, 75 | \code{\link{ebr}()}, 76 | \code{\link{ecc}()}, 77 | \code{\link{eps}()}, 78 | \code{\link{esl}()}, 79 | \code{\link{homer}()}, 80 | \code{\link{lift}()}, 81 | \code{\link{lp}()}, 82 | \code{\link{mbr}()}, 83 | \code{\link{ns}()}, 84 | \code{\link{ppt}()}, 85 | \code{\link{prudent}()}, 86 | \code{\link{ps}()}, 87 | \code{\link{rakel}()}, 88 | \code{\link{rdbr}()}, 89 | \code{\link{rpc}()} 90 | } 91 | \concept{Transformation methods} 92 | -------------------------------------------------------------------------------- /man/rdbr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_rdbr.R 3 | \name{rdbr} 4 | \alias{rdbr} 5 | \title{Recursive Dependent Binary Relevance (RDBR) for multi-label Classification} 6 | \usage{ 7 | rdbr( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | estimate.models = TRUE, 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{mdata}{A mldr dataset used to train the binary models.} 18 | 19 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 20 | \code{options("utiml.base.algorithm", "SVM")})} 21 | 22 | \item{estimate.models}{Logical value indicating whether is necessary build 23 | Binary Relevance classifier for estimate process. The default implementation 24 | use BR as estimators, however when other classifier is desirable then use 25 | the value \code{FALSE} to skip this process. (Default: \code{TRUE}).} 26 | 27 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 28 | 29 | \item{cores}{The number of cores to parallelize the training. Values higher 30 | than 1 require the \pkg{parallel} package. (Default: 31 | \code{options("utiml.cores", 1)})} 32 | 33 | \item{seed}{An optional integer used to set the seed. This is useful when 34 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 35 | } 36 | \value{ 37 | An object of class \code{RDBRmodel} containing the set of fitted 38 | models, including: 39 | \describe{ 40 | \item{labels}{A vector with the label names.} 41 | \item{estimation}{The BR model to estimate the values for the labels. 42 | Only when the \code{estimate.models = TRUE}.} 43 | \item{models}{A list of final models named by the label names.} 44 | } 45 | } 46 | \description{ 47 | Create a RDBR classifier to predict multi-label data. This is a recursive 48 | approach that enables the binary classifiers to discover existing label 49 | dependency by themselves. The idea of RDBR is running DBR recursively until 50 | the results stabilization of the result. 51 | } 52 | \details{ 53 | The train method is exactly the same of DBR the recursion is in the predict 54 | method. 55 | } 56 | \examples{ 57 | model <- rdbr(toyml, "RANDOM") 58 | pred <- predict(model, toyml) 59 | 60 | \donttest{ 61 | # Use Random Forest as base algorithm and 2 cores 62 | model <- rdbr(toyml, 'RF', cores = 2, seed = 123) 63 | } 64 | } 65 | \references{ 66 | Rauber, T. W., Mello, L. H., Rocha, V. F., Luchi, D., & Varejao, F. M. 67 | (2014). Recursive Dependent Binary Relevance Model for Multi-label 68 | Classification. In Advances in Artificial Intelligence - IBERAMIA, 206-217. 69 | } 70 | \seealso{ 71 | \code{\link[=dbr]{Dependent Binary Relevance (DBR)}} 72 | 73 | Other Transformation methods: 74 | \code{\link{brplus}()}, 75 | \code{\link{br}()}, 76 | \code{\link{cc}()}, 77 | \code{\link{clr}()}, 78 | \code{\link{dbr}()}, 79 | \code{\link{ebr}()}, 80 | \code{\link{ecc}()}, 81 | \code{\link{eps}()}, 82 | \code{\link{esl}()}, 83 | \code{\link{homer}()}, 84 | \code{\link{lift}()}, 85 | \code{\link{lp}()}, 86 | \code{\link{mbr}()}, 87 | \code{\link{ns}()}, 88 | \code{\link{ppt}()}, 89 | \code{\link{prudent}()}, 90 | \code{\link{ps}()}, 91 | \code{\link{rakel}()}, 92 | \code{\link{rpc}()} 93 | } 94 | \concept{Transformation methods} 95 | -------------------------------------------------------------------------------- /man/predict.RDBRmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_rdbr.R 3 | \name{predict.RDBRmodel} 4 | \alias{predict.RDBRmodel} 5 | \title{Predict Method for RDBR} 6 | \usage{ 7 | \method{predict}{RDBRmodel}( 8 | object, 9 | newdata, 10 | estimative = NULL, 11 | max.iterations = 5, 12 | batch.mode = FALSE, 13 | probability = getOption("utiml.use.probs", TRUE), 14 | ..., 15 | cores = getOption("utiml.cores", 1), 16 | seed = getOption("utiml.seed", NA) 17 | ) 18 | } 19 | \arguments{ 20 | \item{object}{Object of class '\code{RDBRmodel}'.} 21 | 22 | \item{newdata}{An object containing the new input data. This must be a 23 | matrix, data.frame or a mldr object.} 24 | 25 | \item{estimative}{A matrix containing the bipartition result of other 26 | multi-label classification algorithm or an mlresult object with the 27 | predictions.} 28 | 29 | \item{max.iterations}{The maximum allowed iterations of the RDBR technique. 30 | (Default: 5)} 31 | 32 | \item{batch.mode}{Logical value to determine if use the batch re-estimation. 33 | If \code{FALSE} then use the stochastic re-estimation strategy. 34 | (Default: \code{FALSE})} 35 | 36 | \item{probability}{Logical indicating whether class probabilities should be 37 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 38 | 39 | \item{...}{Others arguments passed to the base algorithm prediction for all 40 | subproblems.} 41 | 42 | \item{cores}{The number of cores to parallelize the training. Values higher 43 | than 1 require the \pkg{parallel} package. (Default: 44 | \code{options("utiml.cores", 1)})} 45 | 46 | \item{seed}{An optional integer used to set the seed. This is useful when 47 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 48 | } 49 | \value{ 50 | An object of type mlresult, based on the parameter probability. 51 | } 52 | \description{ 53 | This function predicts values based upon a model trained by \code{rdbr}. 54 | In general this method is a recursive version of 55 | \code{\link{predict.DBRmodel}}. 56 | } 57 | \details{ 58 | Two versions of the update strategy of the estimated labels are implemented. 59 | The batch re-estimates the labels only when a complete current label vector 60 | is available. The stochastic uses re-estimated labels as soon as they become 61 | available. This second does not support parallelize the prediction, however 62 | stabilizes earlier than batch mode. 63 | } 64 | \examples{ 65 | \donttest{ 66 | # Predict SVM scores 67 | model <- rdbr(toyml) 68 | pred <- predict(model, toyml) 69 | 70 | # Passing a specif parameter for SVM predict algorithm 71 | pred <- predict(model, toyml, na.action = na.fail) 72 | 73 | # Use the batch mode and increase the max number of iteration to 10 74 | pred <- predict(model, toyml, max.iterations = 10, batch.mode = TRUE) 75 | 76 | # Using other classifier (EBR) to made the labels estimatives 77 | estimative <- predict(ebr(toyml), toyml, probability = FALSE) 78 | model <- rdbr(toyml, estimate.models = FALSE) 79 | pred <- predict(model, toyml, estimative = estimative) 80 | } 81 | } 82 | \references{ 83 | Rauber, T. W., Mello, L. H., Rocha, V. F., Luchi, D., & Varejao, F. M. 84 | (2014). Recursive Dependent Binary Relevance Model for Multi-label 85 | Classification. In Advances in Artificial Intelligence - IBERAMIA, 206-217. 86 | } 87 | \seealso{ 88 | \code{\link[=rdbr]{Recursive Dependent Binary Relevance (RDBR)}} 89 | } 90 | -------------------------------------------------------------------------------- /man/scut_threshold.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/threshold.R 3 | \name{scut_threshold} 4 | \alias{scut_threshold} 5 | \alias{scut_threshold.default} 6 | \alias{scut_threshold.mlresult} 7 | \title{SCut Score-based method} 8 | \usage{ 9 | scut_threshold( 10 | prediction, 11 | expected, 12 | loss.function = NA, 13 | cores = getOption("utiml.cores", 1) 14 | ) 15 | 16 | \method{scut_threshold}{default}( 17 | prediction, 18 | expected, 19 | loss.function = NA, 20 | cores = getOption("utiml.cores", 1) 21 | ) 22 | 23 | \method{scut_threshold}{mlresult}( 24 | prediction, 25 | expected, 26 | loss.function = NA, 27 | cores = getOption("utiml.cores", 1) 28 | ) 29 | } 30 | \arguments{ 31 | \item{prediction}{A matrix or mlresult.} 32 | 33 | \item{expected}{The expected labels for the prediction. May be a matrix with 34 | the label values or a mldr object.} 35 | 36 | \item{loss.function}{A loss function to be optimized. If you want to use your 37 | own error function see the notes and example. (Default: Mean Squared Error)} 38 | 39 | \item{cores}{The number of cores to parallelize the computation Values higher 40 | than 1 require the \pkg{parallel} package. (Default: 41 | \code{options("utiml.cores", 1)})} 42 | } 43 | \value{ 44 | A numeric vector with the threshold values for each label 45 | } 46 | \description{ 47 | This is a label-wise method that adjusts the threshold for each label to 48 | achieve a specific loss function using a validation set or cross validation. 49 | } 50 | \details{ 51 | Different from the others threshold methods instead of return the bipartition 52 | results, it returns the threshold values for each label. 53 | } 54 | \section{Methods (by class)}{ 55 | \itemize{ 56 | \item \code{default}: Default scut_threshold 57 | 58 | \item \code{mlresult}: Mlresult scut_threshold 59 | }} 60 | 61 | \note{ 62 | The loss function is a R method that receive two vectors, the expected 63 | values of the label and the predicted values, respectively. Positive values 64 | are represented by the 1 and the negative by the 0. 65 | } 66 | \examples{ 67 | names <- list(1:10, c("a", "b", "c")) 68 | prediction <- matrix(runif(30), ncol = 3, dimnames = names) 69 | classes <- matrix(sample(0:1, 30, rep = TRUE), ncol = 3, dimnames = names) 70 | thresholds <- scut_threshold(prediction, classes) 71 | fixed_threshold(prediction, thresholds) 72 | 73 | \donttest{ 74 | # Penalizes only FP predictions 75 | mylossfunc <- function (real, predicted) { 76 | mean(predicted - real * predicted) 77 | } 78 | prediction <- predict(br(toyml, "RANDOM"), toyml) 79 | scut_threshold(prediction, toyml, loss.function = mylossfunc, cores = 2) 80 | } 81 | } 82 | \references{ 83 | Fan, R.-E., & Lin, C.-J. (2007). A study on threshold selection for 84 | multi-label classification. Department of Computer Science, National 85 | Taiwan University. 86 | 87 | Al-Otaibi, R., Flach, P., & Kull, M. (2014). Multi-label Classification: A 88 | Comparative Study on Threshold Selection Methods. In First International 89 | Workshop on Learning over Multiple Contexts (LMCE) at ECML-PKDD 2014. 90 | } 91 | \seealso{ 92 | Other threshold: 93 | \code{\link{fixed_threshold}()}, 94 | \code{\link{lcard_threshold}()}, 95 | \code{\link{mcut_threshold}()}, 96 | \code{\link{pcut_threshold}()}, 97 | \code{\link{rcut_threshold}()}, 98 | \code{\link{subset_correction}()} 99 | } 100 | \concept{threshold} 101 | -------------------------------------------------------------------------------- /man/cc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_cc.R 3 | \name{cc} 4 | \alias{cc} 5 | \title{Classifier Chains for multi-label Classification} 6 | \usage{ 7 | cc( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | chain = NA, 11 | ..., 12 | cores = getOption("utiml.cores", 1), 13 | seed = getOption("utiml.seed", NA) 14 | ) 15 | } 16 | \arguments{ 17 | \item{mdata}{A mldr dataset used to train the binary models.} 18 | 19 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 20 | \code{options("utiml.base.algorithm", "SVM")})} 21 | 22 | \item{chain}{A vector with the label names to define the chain order. If 23 | empty the chain is the default label sequence of the dataset. (Default: 24 | \code{NA})} 25 | 26 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 27 | 28 | \item{cores}{The number of cores to parallelize the training. Values higher 29 | than 1 require the \pkg{parallel} package. (Default: 30 | \code{options("utiml.cores", 1)})} 31 | 32 | \item{seed}{An optional integer used to set the seed. This is useful when 33 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 34 | } 35 | \value{ 36 | An object of class \code{CCmodel} containing the set of fitted 37 | models, including: \describe{ 38 | \item{chain}{A vector with the chain order.} 39 | \item{labels}{A vector with the label names in expected order.} 40 | \item{models}{A list of models named by the label names.} 41 | } 42 | } 43 | \description{ 44 | Create a Classifier Chains model for multilabel classification. 45 | } 46 | \details{ 47 | Classifier Chains is a Binary Relevance transformation method based to 48 | predict multi-label data. This is based on the one-versus-all approach to 49 | build a specific model for each label. It is different from BR method due the 50 | strategy of extended the attribute space with the 0/1 label relevances of all 51 | previous classifiers, forming a classifier chain. 52 | } 53 | \examples{ 54 | model <- cc(toyml, "RANDOM") 55 | pred <- predict(model, toyml) 56 | 57 | \donttest{ 58 | # Use a specific chain with C5.0 classifier 59 | mychain <- sample(rownames(toyml$labels)) 60 | model <- cc(toyml, 'C5.0', mychain) 61 | 62 | # Set a specific parameter 63 | model <- cc(toyml, 'KNN', k=5) 64 | 65 | #Run with multiple-cores 66 | model <- cc(toyml, 'RF', cores = 2, seed = 123) 67 | } 68 | } 69 | \references{ 70 | Read, J., Pfahringer, B., Holmes, G., & Frank, E. (2011). Classifier chains 71 | for multi-label classification. Machine Learning, 85(3), 333-359. 72 | 73 | Read, J., Pfahringer, B., Holmes, G., & Frank, E. (2009). Classifier Chains 74 | for Multi-label Classification. Machine Learning and Knowledge Discovery 75 | in Databases, Lecture Notes in Computer Science, 5782, 254-269. 76 | } 77 | \seealso{ 78 | Other Transformation methods: 79 | \code{\link{brplus}()}, 80 | \code{\link{br}()}, 81 | \code{\link{clr}()}, 82 | \code{\link{dbr}()}, 83 | \code{\link{ebr}()}, 84 | \code{\link{ecc}()}, 85 | \code{\link{eps}()}, 86 | \code{\link{esl}()}, 87 | \code{\link{homer}()}, 88 | \code{\link{lift}()}, 89 | \code{\link{lp}()}, 90 | \code{\link{mbr}()}, 91 | \code{\link{ns}()}, 92 | \code{\link{ppt}()}, 93 | \code{\link{prudent}()}, 94 | \code{\link{ps}()}, 95 | \code{\link{rakel}()}, 96 | \code{\link{rdbr}()}, 97 | \code{\link{rpc}()} 98 | } 99 | \concept{Transformation methods} 100 | -------------------------------------------------------------------------------- /man/rakel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_rakel.R 3 | \name{rakel} 4 | \alias{rakel} 5 | \title{Random k-labelsets for multilabel classification} 6 | \usage{ 7 | rakel( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | k = 3, 11 | m = 2 * mdata$measures$num.labels, 12 | overlapping = TRUE, 13 | ..., 14 | cores = getOption("utiml.cores", 1), 15 | seed = getOption("utiml.seed", NA) 16 | ) 17 | } 18 | \arguments{ 19 | \item{mdata}{A mldr dataset used to train the binary models.} 20 | 21 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 22 | \code{options("utiml.base.algorithm", "SVM")})} 23 | 24 | \item{k}{The number of labels used in each labelset. (Default: \code{3})} 25 | 26 | \item{m}{The number of LP models. Used when overlapping is TRUE, otherwise it 27 | is ignored. (Default: \code{2 * length(labels)})} 28 | 29 | \item{overlapping}{Logical value, that defines if the method must overlapping 30 | the labelsets. If FALSE the method uses disjoint labelsets. 31 | (Default: \code{TRUE})} 32 | 33 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 34 | 35 | \item{cores}{The number of cores to parallelize the training. Values higher 36 | than 1 require the \pkg{parallel} package. (Default: 37 | \code{options("utiml.cores", 1)})} 38 | 39 | \item{seed}{An optional integer used to set the seed. This is useful when 40 | the method is running in parallel. (Default: 41 | \code{options("utiml.seed", NA)})} 42 | } 43 | \value{ 44 | An object of class \code{RAkELmodel} containing the set of fitted 45 | models, including: 46 | \describe{ 47 | \item{labels}{A vector with the label names.} 48 | \item{labelsets}{A list with the labelsets used to build the LP models.} 49 | \item{model}{A list of the generated models, named by the label names.} 50 | } 51 | } 52 | \description{ 53 | Create a RAkEL model for multilabel classification. 54 | } 55 | \details{ 56 | RAndom k labELsets is an ensemble of LP models where each classifier is 57 | trained with a small set of labels, called labelset. Two different strategies 58 | for constructing the labelsets are the disjoint and overlapping labelsets. 59 | } 60 | \examples{ 61 | model <- rakel(toyml, "RANDOM") 62 | pred <- predict(model, toyml) 63 | \donttest{ 64 | ## SVM using k = 4 and m = 100 65 | model <- rakel(toyml, "SVM", k=4, m=100) 66 | 67 | ## Random Forest using disjoint labelsets 68 | model <- rakel(toyml, "RF", overlapping=FALSE) 69 | } 70 | } 71 | \references{ 72 | Tsoumakas, G., Katakis, I., & Vlahavas, I. (2011). Random k-labelsets for 73 | multilabel classification. IEEE Transactions on Knowledge and Data 74 | Engineering, 23(7), 1079-1089. 75 | } 76 | \seealso{ 77 | Other Transformation methods: 78 | \code{\link{brplus}()}, 79 | \code{\link{br}()}, 80 | \code{\link{cc}()}, 81 | \code{\link{clr}()}, 82 | \code{\link{dbr}()}, 83 | \code{\link{ebr}()}, 84 | \code{\link{ecc}()}, 85 | \code{\link{eps}()}, 86 | \code{\link{esl}()}, 87 | \code{\link{homer}()}, 88 | \code{\link{lift}()}, 89 | \code{\link{lp}()}, 90 | \code{\link{mbr}()}, 91 | \code{\link{ns}()}, 92 | \code{\link{ppt}()}, 93 | \code{\link{prudent}()}, 94 | \code{\link{ps}()}, 95 | \code{\link{rdbr}()}, 96 | \code{\link{rpc}()} 97 | 98 | Other Powerset: 99 | \code{\link{eps}()}, 100 | \code{\link{lp}()}, 101 | \code{\link{ppt}()}, 102 | \code{\link{ps}()} 103 | } 104 | \concept{Powerset} 105 | \concept{Transformation methods} 106 | -------------------------------------------------------------------------------- /man/eps.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_eps.R 3 | \name{eps} 4 | \alias{eps} 5 | \title{Ensemble of Pruned Set for multi-label Classification} 6 | \usage{ 7 | eps( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | m = 10, 11 | subsample = 0.75, 12 | p = 3, 13 | strategy = c("A", "B"), 14 | b = 2, 15 | ..., 16 | cores = getOption("utiml.cores", 1), 17 | seed = getOption("utiml.seed", NA) 18 | ) 19 | } 20 | \arguments{ 21 | \item{mdata}{A mldr dataset used to train the binary models.} 22 | 23 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 24 | \code{options("utiml.base.algorithm", "SVM")})} 25 | 26 | \item{m}{The number of Pruned Set models used in the ensemble.} 27 | 28 | \item{subsample}{A value between 0.1 and 1 to determine the percentage of 29 | training instances that must be used for each classifier. (Default: 0.63)} 30 | 31 | \item{p}{Number of instances to prune. All labelsets that occurs p times or 32 | less in the training data is removed. (Default: 3)} 33 | 34 | \item{strategy}{The strategy (A or B) for processing infrequent labelsets. 35 | (Default: A).} 36 | 37 | \item{b}{The number used by the strategy for processing infrequent labelsets.} 38 | 39 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 40 | 41 | \item{cores}{The number of cores to parallelize the training. Values higher 42 | than 1 require the \pkg{parallel} package. (Default: 43 | \code{options("utiml.cores", 1)})} 44 | 45 | \item{seed}{An optional integer used to set the seed. (Default: 46 | \code{options("utiml.seed", NA)})} 47 | } 48 | \value{ 49 | An object of class \code{EPSmodel} containing the set of fitted 50 | models, including: 51 | \describe{ 52 | \item{rounds}{The number of interactions} 53 | \item{models}{A list of PS models.} 54 | } 55 | } 56 | \description{ 57 | Create an Ensemble of Pruned Set model for multilabel classification. 58 | } 59 | \details{ 60 | Pruned Set (PS) is a multi-class transformation that remove the less common 61 | classes to predict multi-label data. The ensemble is created with different 62 | subsets of the original multi-label data. 63 | } 64 | \examples{ 65 | model <- eps(toyml, "RANDOM") 66 | pred <- predict(model, toyml) 67 | 68 | \donttest{ 69 | ##Change default configurations 70 | model <- eps(toyml, "RF", m=15, subsample=0.4, p=4, strategy="B", b=1) 71 | } 72 | } 73 | \references{ 74 | Read, J. (2008). A pruned problem transformation method for multi-label 75 | classification. In Proceedings of the New Zealand Computer Science Research 76 | Student Conference (pp. 143-150). 77 | } 78 | \seealso{ 79 | Other Transformation methods: 80 | \code{\link{brplus}()}, 81 | \code{\link{br}()}, 82 | \code{\link{cc}()}, 83 | \code{\link{clr}()}, 84 | \code{\link{dbr}()}, 85 | \code{\link{ebr}()}, 86 | \code{\link{ecc}()}, 87 | \code{\link{esl}()}, 88 | \code{\link{homer}()}, 89 | \code{\link{lift}()}, 90 | \code{\link{lp}()}, 91 | \code{\link{mbr}()}, 92 | \code{\link{ns}()}, 93 | \code{\link{ppt}()}, 94 | \code{\link{prudent}()}, 95 | \code{\link{ps}()}, 96 | \code{\link{rakel}()}, 97 | \code{\link{rdbr}()}, 98 | \code{\link{rpc}()} 99 | 100 | Other Powerset: 101 | \code{\link{lp}()}, 102 | \code{\link{ppt}()}, 103 | \code{\link{ps}()}, 104 | \code{\link{rakel}()} 105 | 106 | Other Ensemble methods: 107 | \code{\link{ebr}()}, 108 | \code{\link{ecc}()} 109 | } 110 | \concept{Ensemble methods} 111 | \concept{Powerset} 112 | \concept{Transformation methods} 113 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # utiml: Utilities for Multi-label Learning 2 | [![Travis-CI Build Status](https://travis-ci.org/rivolli/utiml.svg?branch=master)](https://travis-ci.org/rivolli/utiml) 3 | 4 | The utiml package is a framework to support multi-label processing, like Mulan 5 | on Weka. 6 | 7 | The main methods available on this package are organized in the groups: 8 | - Classification methods 9 | - Evaluation methods 10 | - Pre-process utilities 11 | - Sampling methods 12 | - Threshold methods 13 | 14 | # Instalation 15 | The installation process is similar to other packages available on CRAN: 16 | ```r 17 | install.packages("utiml") 18 | ``` 19 | 20 | This will also install [mldr](https://cran.r-project.org/package=mldr). 21 | To run the examples in this document, you also need to install the packages: 22 | ```r 23 | # Base classifiers (SVM and Random Forest) 24 | install.packages(c("e1071", "randomForest")) 25 | ``` 26 | 27 | ## Install via github (development version) 28 | ```r 29 | devtools::install_github("rivolli/utiml") 30 | ``` 31 | 32 | # Multi-label Classification 33 | ## Running Binary Relevance Method 34 | ```{r} 35 | library(utiml) 36 | 37 | # Create two partitions (train and test) of toyml multi-label dataset 38 | ds <- create_holdout_partition(toyml, c(train=0.65, test=0.35)) 39 | 40 | # Create a Binary Relevance Model using e1071::svm method 41 | brmodel <- br(ds$train, "SVM", seed=123) 42 | 43 | # Predict 44 | prediction <- predict(brmodel, ds$test) 45 | 46 | # Show the predictions 47 | head(as.bipartition(prediction)) 48 | head(as.ranking(prediction)) 49 | 50 | # Apply a threshold 51 | newpred <- rcut_threshold(prediction, 2) 52 | 53 | # Evaluate the models 54 | result <- multilabel_evaluate(ds$tes, prediction, "bipartition") 55 | thresres <- multilabel_evaluate(ds$tes, newpred, "bipartition") 56 | 57 | # Print the result 58 | print(round(cbind(Default=result, RCUT=thresres), 3)) 59 | ``` 60 | 61 | ## Running Ensemble of Classifier Chains 62 | ```{r} 63 | library(utiml) 64 | 65 | # Create three partitions (train, val, test) of emotions dataset 66 | partitions <- c(train = 0.6, val = 0.2, test = 0.2) 67 | ds <- create_holdout_partition(emotions, partitions, method="iterative") 68 | 69 | # Create an Ensemble of Classifier Chains using Random Forest (randomForest package) 70 | eccmodel <- ecc(ds$train, "RF", m=3, cores=parallel::detectCores(), seed=123) 71 | 72 | # Predict 73 | val <- predict(eccmodel, ds$val, cores=parallel::detectCores()) 74 | test <- predict(eccmodel, ds$test, cores=parallel::detectCores()) 75 | 76 | # Apply a threshold 77 | thresholds <- scut_threshold(val, ds$val, cores=parallel::detectCores()) 78 | new.val <- fixed_threshold(val, thresholds) 79 | new.test <- fixed_threshold(test, thresholds) 80 | 81 | # Evaluate the models 82 | measures <- c("subset-accuracy", "F1", "hamming-loss", "macro-based") 83 | 84 | result <- cbind( 85 | Test = multilabel_evaluate(ds$tes, test, measures), 86 | TestWithThreshold = multilabel_evaluate(ds$tes, new.test, measures), 87 | Validation = multilabel_evaluate(ds$val, val, measures), 88 | ValidationWithThreshold = multilabel_evaluate(ds$val, new.val, measures) 89 | ) 90 | 91 | print(round(result, 3)) 92 | ``` 93 | 94 | More examples and details are available on functions documentations and vignettes, please refer to the documentation. 95 | 96 | ## How to cite? 97 | ``` 98 | @article{RJ-2018-041, 99 | author = {Adriano Rivolli and Andre C. P. L. F. de Carvalho}, 100 | title = {{The utiml Package: Multi-label Classification in R}}, 101 | year = {2018}, 102 | journal = {{The R Journal}}, 103 | doi = {10.32614/RJ-2018-041}, 104 | url = {https://doi.org/10.32614/RJ-2018-041}, 105 | pages = {24--37}, 106 | volume = {10}, 107 | number = {2} 108 | } 109 | ``` 110 | -------------------------------------------------------------------------------- /R/cross_validation.R: -------------------------------------------------------------------------------- 1 | #' Multi-label cross-validation 2 | #' 3 | #' Perform the cross validation procedure for multi-label learning. 4 | #' 5 | #' @family evaluation 6 | #' @param mdata A mldr dataset. 7 | #' @param method The multi-label classification method. It also accepts the name 8 | #' of the method as a string. 9 | #' @param ... Additional parameters required by the method. 10 | #' @param cv.folds Number of folds. (Default: 10) 11 | #' @param cv.sampling The method to split the data. The default methods are: 12 | #' \describe{ 13 | #' \item{random}{Split randomly the folds.} 14 | #' \item{iterative}{Split the folds considering the labels proportions 15 | #' individually. Some specific label can not occurs in all 16 | #' folds.} 17 | #' \item{stratified}{Split the folds considering the labelset proportions.} 18 | #' } 19 | #' (Default: "random") 20 | #' @param cv.results Logical value indicating if the folds results should be 21 | #' reported (Default: FALSE). 22 | #' @param cv.predictions Logical value indicating if the predictions should be 23 | #' reported (Default: FALSE). 24 | #' @param cv.measures The measures names to be computed. Call 25 | #' \code{multilabel_measures()} to see the expected measures. You can also 26 | #' use \code{"bipartition"}, \code{"ranking"}, \code{"label-based"}, 27 | #' \code{"example-based"}, \code{"macro-based"}, \code{"micro-based"} and 28 | #' \code{"label-problem"} to include a set of measures. (Default: "all"). 29 | #' @param cv.cores The number of cores to parallelize the cross validation 30 | #' procedure. (Default: \code{options("utiml.cores", 1)}) 31 | #' @param cv.seed An optional integer used to set the seed. (Default: 32 | #' \code{options("utiml.seed", NA)}) 33 | #' 34 | #' @return If cv.results and cv.prediction are FALSE, the return is a vector 35 | #' with the expected multi-label measures, otherwise, a list contained the 36 | #' multi-label and the other expected results (the label measures and/or the 37 | #' prediction object) for each fold. 38 | #' 39 | #' @export 40 | #' 41 | #' @examples 42 | #' #Run 10 folds for BR method 43 | #' res1 <- cv(toyml, br, base.algorithm="RANDOM", cv.folds=10) 44 | #' 45 | #' #Run 3 folds for RAkEL method and get the fold results and the prediction 46 | #' res2 <- cv(mdata=toyml, method="rakel", base.algorithm="RANDOM", k=2, m=10, 47 | #' cv.folds=3, cv.results=TRUE, cv.predictions=TRUE) 48 | cv <- function(mdata, method, ..., cv.folds=10, 49 | cv.sampling=c("random", "iterative", "stratified"), 50 | cv.results=FALSE, cv.predictions=FALSE, cv.measures="all", 51 | cv.cores=getOption("utiml.cores", 1), 52 | cv.seed=getOption("utiml.seed", NA)) { 53 | if (!is.na(cv.seed)) { 54 | set.seed(cv.seed) 55 | } 56 | 57 | cvdata <- create_kfold_partition(mdata, cv.folds, cv.sampling) 58 | results <- parallel::mclapply(seq(cv.folds), function (k){ 59 | ds <- partition_fold(cvdata, k) 60 | model <- do.call(method, c(list(mdata=ds$train), ...)) 61 | pred <- stats::predict(model, ds$test, ...) 62 | 63 | c( 64 | list(pred=pred), 65 | multilabel_evaluate(ds$test, pred, cv.measures, labels=TRUE) 66 | ) 67 | }, mc.cores = cv.cores) 68 | 69 | obj = list(multilabel=do.call(rbind, lapply(results, "[[", "multilabel"))) 70 | 71 | if (cv.results) { 72 | labels <- rownames(mdata$labels) 73 | lfolds <- lapply(results, "[[", "labels") 74 | obj$labels <- sapply(labels, 75 | function(lbl) t(sapply(lfolds, function(x) x[lbl,])), 76 | simplify = FALSE) 77 | } 78 | 79 | if (cv.predictions) { 80 | obj$predictions <- lapply(results, "[[", "pred") 81 | } 82 | 83 | if (length(obj) == 1) { 84 | return(colMeans(obj[[1]])) 85 | } else { 86 | obj 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /tests/testfiles/flags-expected.csv: -------------------------------------------------------------------------------- 1 | "red","green","blue","yellow","white","black","orange" 2 | 1,1,0,1,1,1,0 3 | 1,0,0,1,0,1,0 4 | 1,1,0,0,1,0,0 5 | 1,0,1,1,1,0,1 6 | 1,0,1,1,0,0,0 7 | 1,0,0,1,0,1,0 8 | 0,0,1,0,1,0,1 9 | 1,0,1,1,1,1,0 10 | 0,0,1,0,1,0,0 11 | 0,0,1,1,1,0,0 12 | 1,0,1,0,1,0,0 13 | 1,0,0,0,1,0,0 14 | 0,0,1,1,0,1,0 15 | 1,0,0,0,1,0,0 16 | 1,1,0,0,0,0,0 17 | 0,0,1,1,0,1,0 18 | 1,0,0,1,0,1,0 19 | 1,1,1,1,1,1,1 20 | 1,1,0,0,0,0,0 21 | 1,1,1,1,1,1,0 22 | 1,0,0,0,1,1,1 23 | 1,1,0,1,0,0,0 24 | 0,0,1,0,1,1,0 25 | 0,1,1,1,1,0,0 26 | 1,1,1,1,1,0,1 27 | 1,0,0,1,1,1,0 28 | 1,1,1,1,1,0,0 29 | 1,1,0,1,0,0,0 30 | 1,0,1,0,1,0,0 31 | 1,1,0,0,1,0,0 32 | 1,1,0,1,0,0,0 33 | 1,0,0,0,1,0,0 34 | 1,1,0,1,0,1,1 35 | 1,1,1,1,1,0,1 36 | 1,1,1,1,1,0,0 37 | 1,0,1,1,0,0,0 38 | 1,0,1,0,1,0,0 39 | 1,0,0,1,0,0,0 40 | 1,0,1,1,0,0,0 41 | 0,1,0,0,1,0,0 42 | 1,1,0,1,0,0,0 43 | 1,0,1,0,1,0,0 44 | 1,0,1,0,1,0,0 45 | 1,0,1,0,1,0,0 46 | 0,1,0,1,1,0,0 47 | 1,0,1,0,1,0,0 48 | 1,0,0,0,1,0,0 49 | 1,1,1,0,1,0,0 50 | 1,1,1,1,1,1,0 51 | 1,0,1,0,1,0,0 52 | 1,0,1,1,0,0,0 53 | 1,0,0,1,1,1,0 54 | 0,0,1,0,1,0,0 55 | 1,1,1,0,1,0,0 56 | 1,1,0,1,0,0,0 57 | 1,0,1,0,1,0,0 58 | 1,1,1,1,1,0,0 59 | 1,1,1,1,1,0,1 60 | 0,0,1,0,1,0,0 61 | 1,0,1,0,1,0,0 62 | 1,0,1,0,1,0,0 63 | 1,0,1,1,1,1,0 64 | 0,1,1,1,0,0,0 65 | 1,1,1,0,1,0,0 66 | 1,0,0,1,0,1,0 67 | 1,0,0,1,0,1,0 68 | 1,1,0,1,0,1,0 69 | 1,0,0,1,1,0,0 70 | 0,0,1,0,1,0,0 71 | 1,0,0,0,1,0,0 72 | 1,1,0,1,0,0,0 73 | 1,1,1,1,1,0,1 74 | 0,0,1,0,1,0,0 75 | 1,1,0,1,0,0,0 76 | 1,1,0,1,0,1,0 77 | 1,1,0,1,1,1,0 78 | 1,0,0,0,0,1,0 79 | 0,0,1,0,1,0,0 80 | 1,1,1,1,1,0,1 81 | 1,1,0,0,1,0,0 82 | 1,0,1,0,1,0,0 83 | 0,1,1,0,1,0,1 84 | 1,0,0,0,1,0,0 85 | 1,1,0,0,1,0,0 86 | 1,1,0,0,1,1,0 87 | 0,1,0,0,1,0,1 88 | 0,0,1,0,1,0,0 89 | 1,1,0,0,1,0,0 90 | 1,1,0,0,1,0,0 91 | 0,1,0,1,0,1,0 92 | 1,0,0,0,1,0,0 93 | 1,1,0,0,1,1,0 94 | 1,0,0,1,0,0,0 95 | 1,1,0,0,1,1,0 96 | 1,0,1,1,1,0,0 97 | 1,1,0,0,1,1,0 98 | 1,0,1,0,1,0,0 99 | 1,1,0,0,1,0,1 100 | 1,1,1,0,1,0,0 101 | 1,0,1,0,1,0,0 102 | 0,1,0,0,0,0,0 103 | 1,0,1,1,0,0,0 104 | 1,0,1,0,1,0,0 105 | 1,1,0,0,1,0,0 106 | 1,1,0,0,0,1,0 107 | 1,0,1,1,1,0,0 108 | 1,1,0,0,1,0,0 109 | 1,1,0,1,0,0,0 110 | 1,0,0,0,1,1,0 111 | 0,0,1,0,1,0,0 112 | 0,1,0,1,0,0,0 113 | 1,1,1,1,0,0,0 114 | 1,1,0,0,1,0,1 115 | 0,0,1,0,1,0,0 116 | 1,0,0,0,1,0,0 117 | 1,0,1,1,0,0,0 118 | 1,1,1,1,1,1,0 119 | 1,1,0,0,0,0,0 120 | 1,1,0,1,1,1,0 121 | 0,0,1,1,1,0,0 122 | 0,0,1,0,1,0,1 123 | 1,0,1,0,1,0,0 124 | 1,0,1,0,1,0,0 125 | 1,0,1,0,1,0,0 126 | 0,0,1,0,1,0,0 127 | 0,1,0,0,1,0,1 128 | 0,1,0,0,1,0,0 129 | 1,0,1,1,1,0,0 130 | 1,0,1,0,1,0,0 131 | 1,1,0,0,1,1,0 132 | 1,0,1,0,1,0,0 133 | 1,1,0,0,1,0,0 134 | 0,1,0,0,1,0,0 135 | 1,0,1,0,1,0,0 136 | 1,0,0,1,1,1,0 137 | 1,1,1,1,1,1,0 138 | 1,0,0,0,1,0,0 139 | 1,0,1,1,1,0,0 140 | 1,0,0,0,1,0,0 141 | 1,1,1,1,1,0,0 142 | 1,0,1,0,1,0,0 143 | 0,0,0,0,1,0,1 144 | 1,1,1,1,1,0,1 145 | 1,1,0,1,0,1,0 146 | 0,0,1,0,1,0,0 147 | 1,1,0,1,0,1,0 148 | 0,1,0,0,1,0,0 149 | 1,1,0,1,0,0,0 150 | 1,1,0,0,1,0,0 151 | 0,1,1,0,1,0,0 152 | 1,0,0,0,1,0,0 153 | 0,1,1,1,1,0,0 154 | 0,0,1,0,1,0,0 155 | 1,1,1,0,1,0,1 156 | 1,0,1,0,1,1,0 157 | 1,0,1,0,1,1,0 158 | 1,0,0,1,0,0,0 159 | 0,1,0,1,0,0,1 160 | 1,1,1,1,1,0,1 161 | 1,1,0,1,1,1,0 162 | 0,0,1,1,1,1,0 163 | 0,1,1,1,1,0,0 164 | 1,1,0,0,1,1,0 165 | 1,1,0,1,1,0,0 166 | 1,0,1,1,1,1,1 167 | 0,0,1,1,0,0,0 168 | 1,0,0,0,1,0,0 169 | 1,1,0,0,1,1,0 170 | 1,0,1,0,1,0,0 171 | 0,1,1,1,0,1,0 172 | 1,0,1,0,1,0,0 173 | 1,1,0,1,1,0,0 174 | 1,0,0,0,1,0,0 175 | 1,0,0,0,1,1,0 176 | 1,0,0,0,1,0,0 177 | 1,0,0,0,1,0,0 178 | 1,1,1,1,1,0,1 179 | 1,0,1,1,1,0,0 180 | 1,1,0,0,1,1,0 181 | 1,0,0,1,1,1,0 182 | 1,0,1,0,1,0,0 183 | 0,0,1,1,1,0,0 184 | 1,1,1,1,1,0,0 185 | 1,0,1,0,1,0,0 186 | 1,0,0,1,0,0,0 187 | 1,1,0,1,0,1,0 188 | 1,0,0,1,1,1,0 189 | 1,1,1,1,1,1,1 190 | 1,0,0,1,0,0,0 191 | 1,0,1,0,1,0,0 192 | 1,0,1,1,1,0,0 193 | 1,1,0,1,0,0,1 194 | 1,1,0,0,0,1,1 195 | 1,1,0,1,1,1,0 196 | -------------------------------------------------------------------------------- /tests/testfiles/flags-bipartition.csv: -------------------------------------------------------------------------------- 1 | "red","green","blue","yellow","white","black","orange" 2 | 1,1,0,1,1,1,0 3 | 1,0,0,1,0,0,0 4 | 1,1,0,0,1,0,0 5 | 1,0,1,1,1,0,1 6 | 1,0,1,1,1,0,0 7 | 1,1,0,1,0,0,0 8 | 1,0,1,0,1,0,1 9 | 1,0,1,1,1,0,0 10 | 1,0,1,0,1,0,0 11 | 1,0,1,1,1,0,0 12 | 1,0,1,0,1,0,0 13 | 1,0,1,0,1,0,0 14 | 1,0,1,1,0,0,0 15 | 1,0,0,0,1,0,0 16 | 1,0,0,0,1,0,0 17 | 1,0,1,1,0,0,0 18 | 1,0,1,1,1,0,0 19 | 1,1,1,1,1,1,1 20 | 1,1,0,0,0,0,0 21 | 1,1,1,1,1,0,1 22 | 1,1,0,0,1,1,1 23 | 1,0,1,1,1,0,0 24 | 1,0,1,0,1,0,0 25 | 1,1,1,1,1,0,0 26 | 1,1,1,1,1,0,1 27 | 1,1,0,1,1,0,0 28 | 1,1,1,1,1,0,0 29 | 1,1,0,1,0,0,0 30 | 1,0,1,0,1,0,0 31 | 1,1,0,0,1,0,0 32 | 1,1,0,1,0,0,0 33 | 1,0,0,0,1,0,1 34 | 1,1,0,1,1,1,0 35 | 1,1,1,1,1,0,1 36 | 1,1,0,1,1,0,0 37 | 1,1,1,1,0,0,0 38 | 1,0,1,0,1,0,0 39 | 1,0,0,0,0,0,0 40 | 1,0,1,1,1,0,0 41 | 1,1,0,0,1,0,0 42 | 1,1,0,0,0,0,0 43 | 1,0,1,0,1,0,0 44 | 1,0,1,0,1,0,0 45 | 1,0,1,0,1,0,0 46 | 1,0,0,1,1,0,1 47 | 1,0,1,0,1,0,0 48 | 1,0,1,0,1,0,0 49 | 1,1,0,1,1,0,0 50 | 1,1,1,1,1,1,0 51 | 1,0,1,0,1,0,0 52 | 1,0,1,1,1,0,0 53 | 1,1,0,0,1,1,0 54 | 1,0,1,0,1,0,0 55 | 1,1,1,0,0,0,0 56 | 1,1,0,1,0,0,0 57 | 1,0,1,0,1,0,0 58 | 1,1,1,1,1,0,1 59 | 1,1,1,1,1,0,1 60 | 1,0,1,0,1,0,0 61 | 1,0,1,1,1,0,0 62 | 1,0,1,1,1,0,0 63 | 1,0,1,1,1,1,0 64 | 1,1,1,0,0,0,0 65 | 1,1,1,1,1,0,0 66 | 1,0,0,1,0,0,0 67 | 1,0,1,1,0,0,0 68 | 1,1,0,1,0,1,0 69 | 1,0,0,1,1,0,0 70 | 1,0,1,0,1,0,0 71 | 1,0,0,0,1,0,0 72 | 1,1,0,1,0,0,0 73 | 1,1,1,1,1,0,1 74 | 1,0,1,0,1,0,0 75 | 1,1,0,1,0,0,0 76 | 1,1,0,1,0,0,0 77 | 1,1,1,1,1,0,0 78 | 1,0,1,0,1,0,0 79 | 1,0,1,0,1,0,0 80 | 1,1,1,1,1,0,1 81 | 1,0,0,0,1,0,0 82 | 1,0,1,0,1,0,0 83 | 1,1,1,1,1,0,0 84 | 1,0,0,0,1,0,0 85 | 1,1,0,1,1,0,0 86 | 1,1,0,0,1,1,0 87 | 1,0,1,0,1,0,0 88 | 1,0,1,0,1,0,0 89 | 1,0,1,1,1,0,0 90 | 1,1,0,1,0,0,0 91 | 1,1,0,1,0,0,0 92 | 1,0,1,0,1,0,0 93 | 1,1,0,0,1,1,0 94 | 1,0,0,1,0,0,0 95 | 1,1,0,0,1,1,0 96 | 1,0,1,1,1,0,0 97 | 1,1,0,0,1,1,0 98 | 1,0,1,0,1,0,0 99 | 1,1,0,0,1,0,1 100 | 1,1,1,0,0,0,0 101 | 1,0,1,0,1,0,0 102 | 1,1,0,0,1,0,0 103 | 1,0,1,1,1,0,0 104 | 1,0,1,1,1,0,0 105 | 1,1,0,0,0,0,0 106 | 1,1,0,0,0,0,0 107 | 1,1,1,0,1,0,0 108 | 1,0,0,0,1,0,0 109 | 1,1,0,1,0,0,0 110 | 1,0,1,0,1,0,0 111 | 1,0,1,0,1,0,0 112 | 1,1,0,0,0,0,0 113 | 1,1,1,1,1,0,0 114 | 1,1,0,0,1,0,1 115 | 1,0,1,0,1,0,0 116 | 1,0,1,0,1,0,0 117 | 1,0,1,1,0,0,0 118 | 1,1,1,1,1,0,1 119 | 1,1,0,0,0,0,0 120 | 1,1,0,1,1,1,0 121 | 1,0,1,0,1,0,0 122 | 1,0,1,0,1,0,0 123 | 1,0,1,1,1,0,0 124 | 1,0,1,1,1,0,0 125 | 1,0,1,0,1,0,0 126 | 1,0,1,0,1,0,0 127 | 1,1,0,1,1,0,0 128 | 1,1,0,0,1,0,0 129 | 1,0,1,0,1,0,0 130 | 1,0,1,0,1,0,0 131 | 1,1,0,0,1,1,0 132 | 1,0,1,0,1,0,0 133 | 1,0,0,0,1,0,0 134 | 1,0,0,0,1,0,0 135 | 1,0,1,0,1,0,0 136 | 1,0,0,1,1,1,0 137 | 1,1,1,1,1,1,0 138 | 1,0,1,0,1,0,0 139 | 1,0,1,0,1,0,0 140 | 1,0,0,0,1,0,0 141 | 1,1,1,1,1,0,0 142 | 1,0,1,0,1,0,0 143 | 1,0,0,0,1,0,0 144 | 1,1,1,1,1,0,1 145 | 1,1,0,1,0,1,0 146 | 1,0,1,0,1,0,0 147 | 1,1,1,1,1,1,0 148 | 1,1,0,1,1,0,0 149 | 1,1,0,1,0,0,0 150 | 1,1,0,0,1,0,0 151 | 1,1,1,0,0,0,0 152 | 1,0,0,0,1,0,0 153 | 1,0,1,1,1,0,0 154 | 1,1,0,0,1,0,0 155 | 1,1,0,1,1,0,0 156 | 1,1,1,0,1,1,0 157 | 1,1,0,0,1,1,0 158 | 1,0,1,0,1,0,0 159 | 1,1,0,0,0,1,1 160 | 1,1,1,1,1,0,1 161 | 1,0,1,1,1,0,0 162 | 1,0,1,1,1,0,0 163 | 1,1,1,1,1,0,0 164 | 1,1,0,0,1,1,0 165 | 1,1,0,1,1,0,0 166 | 1,1,1,1,1,0,1 167 | 1,0,1,0,0,0,0 168 | 1,0,1,0,1,0,0 169 | 1,1,0,0,1,1,0 170 | 1,0,1,0,1,0,0 171 | 1,1,0,1,0,1,0 172 | 1,0,0,0,1,0,0 173 | 1,1,1,1,1,0,0 174 | 1,0,1,0,1,0,0 175 | 1,0,0,1,0,0,0 176 | 1,1,0,0,1,0,0 177 | 1,0,0,0,1,0,0 178 | 1,1,1,1,1,0,1 179 | 1,0,1,1,1,0,0 180 | 1,1,0,0,1,1,0 181 | 1,1,0,1,1,1,1 182 | 1,0,1,0,1,0,0 183 | 1,0,1,1,1,0,0 184 | 1,1,1,1,1,0,0 185 | 1,0,1,0,1,0,0 186 | 1,0,0,1,0,0,0 187 | 1,0,1,1,0,0,1 188 | 1,0,1,1,1,0,0 189 | 1,1,1,1,1,1,1 190 | 1,0,0,0,0,0,0 191 | 1,0,1,0,1,0,0 192 | 1,0,1,1,0,0,0 193 | 1,1,0,1,0,1,1 194 | 1,1,0,0,0,1,1 195 | 1,1,0,1,1,1,0 196 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method("+",mlconfmat) 4 | S3method("[",mlresult) 5 | S3method(as.matrix,mlconfmat) 6 | S3method(as.matrix,mlresult) 7 | S3method(as.mlresult,default) 8 | S3method(as.mlresult,mlresult) 9 | S3method(fixed_threshold,default) 10 | S3method(fixed_threshold,mlresult) 11 | S3method(lcard_threshold,default) 12 | S3method(lcard_threshold,mlresult) 13 | S3method(mcut_threshold,default) 14 | S3method(mcut_threshold,mlresult) 15 | S3method(multilabel_evaluate,mlconfmat) 16 | S3method(multilabel_evaluate,mldr) 17 | S3method(pcut_threshold,default) 18 | S3method(pcut_threshold,mlresult) 19 | S3method(predict,BASELINEmodel) 20 | S3method(predict,BRPmodel) 21 | S3method(predict,BRmodel) 22 | S3method(predict,CCmodel) 23 | S3method(predict,CLRmodel) 24 | S3method(predict,DBRmodel) 25 | S3method(predict,EBRmodel) 26 | S3method(predict,ECCmodel) 27 | S3method(predict,EPSmodel) 28 | S3method(predict,ESLmodel) 29 | S3method(predict,HOMERmodel) 30 | S3method(predict,LIFTmodel) 31 | S3method(predict,LPmodel) 32 | S3method(predict,MBRmodel) 33 | S3method(predict,MLKNNmodel) 34 | S3method(predict,NSmodel) 35 | S3method(predict,PPTmodel) 36 | S3method(predict,PSmodel) 37 | S3method(predict,PruDentmodel) 38 | S3method(predict,RAkELmodel) 39 | S3method(predict,RDBRmodel) 40 | S3method(predict,RPCmodel) 41 | S3method(print,BRPmodel) 42 | S3method(print,BRmodel) 43 | S3method(print,CCmodel) 44 | S3method(print,CLRmodel) 45 | S3method(print,DBRmodel) 46 | S3method(print,EBRmodel) 47 | S3method(print,ECCmodel) 48 | S3method(print,EPSmodel) 49 | S3method(print,ESLmodel) 50 | S3method(print,LIFTmodel) 51 | S3method(print,LPmodel) 52 | S3method(print,MBRmodel) 53 | S3method(print,MLKNNmodel) 54 | S3method(print,NSmodel) 55 | S3method(print,PPTmodel) 56 | S3method(print,PSmodel) 57 | S3method(print,PruDentmodel) 58 | S3method(print,RAkELmodel) 59 | S3method(print,RDBRmodel) 60 | S3method(print,RPCmodel) 61 | S3method(print,kFoldPartition) 62 | S3method(print,majorityModel) 63 | S3method(print,mlconfmat) 64 | S3method(print,mlresult) 65 | S3method(print,randomModel) 66 | S3method(rcut_threshold,default) 67 | S3method(rcut_threshold,mlresult) 68 | S3method(scut_threshold,default) 69 | S3method(scut_threshold,mlresult) 70 | S3method(summary,mltransformation) 71 | export(as.bipartition) 72 | export(as.mlresult) 73 | export(as.probability) 74 | export(as.ranking) 75 | export(baseline) 76 | export(br) 77 | export(brplus) 78 | export(cc) 79 | export(clr) 80 | export(compute_multilabel_predictions) 81 | export(create_holdout_partition) 82 | export(create_kfold_partition) 83 | export(create_random_subset) 84 | export(create_subset) 85 | export(cv) 86 | export(dbr) 87 | export(ebr) 88 | export(ecc) 89 | export(eps) 90 | export(esl) 91 | export(fill_sparse_mldata) 92 | export(fixed_threshold) 93 | export(homer) 94 | export(is.bipartition) 95 | export(is.probability) 96 | export(lcard_threshold) 97 | export(lift) 98 | export(lp) 99 | export(mbr) 100 | export(mcut_threshold) 101 | export(merge_mlconfmat) 102 | export(mldata) 103 | export(mlknn) 104 | export(mlpredict) 105 | export(mltrain) 106 | export(multilabel_confusion_matrix) 107 | export(multilabel_evaluate) 108 | export(multilabel_measures) 109 | export(multilabel_prediction) 110 | export(normalize_mldata) 111 | export(ns) 112 | export(partition_fold) 113 | export(pcut_threshold) 114 | export(ppt) 115 | export(prudent) 116 | export(ps) 117 | export(rakel) 118 | export(rcut_threshold) 119 | export(rdbr) 120 | export(remove_attributes) 121 | export(remove_labels) 122 | export(remove_skewness_labels) 123 | export(remove_unique_attributes) 124 | export(remove_unlabeled_instances) 125 | export(replace_nominal_attributes) 126 | export(rpc) 127 | export(scut_threshold) 128 | export(subset_correction) 129 | export(utiml_measure_names) 130 | import(ROCR) 131 | import(mldr) 132 | import(parallel) 133 | importFrom(methods,is) 134 | -------------------------------------------------------------------------------- /man/predict.BRPmodel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_brplus.R 3 | \name{predict.BRPmodel} 4 | \alias{predict.BRPmodel} 5 | \title{Predict Method for BR+ (brplus)} 6 | \usage{ 7 | \method{predict}{BRPmodel}( 8 | object, 9 | newdata, 10 | strategy = c("Dyn", "Stat", "Ord", "NU"), 11 | order = list(), 12 | probability = getOption("utiml.use.probs", TRUE), 13 | ..., 14 | cores = getOption("utiml.cores", 1), 15 | seed = getOption("utiml.seed", NA) 16 | ) 17 | } 18 | \arguments{ 19 | \item{object}{Object of class '\code{BRPmodel}'.} 20 | 21 | \item{newdata}{An object containing the new input data. This must be a 22 | matrix, data.frame or a mldr object.} 23 | 24 | \item{strategy}{The strategy prefix to determine how to estimate the values 25 | of the augmented features of unlabeled examples. 26 | 27 | The possible values are: \code{'Dyn'}, \code{'Stat'}, \code{'Ord'} or 28 | \code{'NU'}. See the description for more details. (Default: \code{'Dyn'}).} 29 | 30 | \item{order}{The label sequence used to update the initial labels results 31 | based on the final results. This argument is used only when the 32 | \code{strategy = 'Ord'} (Default: \code{list()})} 33 | 34 | \item{probability}{Logical indicating whether class probabilities should be 35 | returned. (Default: \code{getOption("utiml.use.probs", TRUE)})} 36 | 37 | \item{...}{Others arguments passed to the base algorithm prediction for all 38 | subproblems.} 39 | 40 | \item{cores}{The number of cores to parallelize the training. Values higher 41 | than 1 require the \pkg{parallel} package. (Default: 42 | \code{options("utiml.cores", 1)})} 43 | 44 | \item{seed}{An optional integer used to set the seed. This is useful when 45 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 46 | } 47 | \value{ 48 | An object of type mlresult, based on the parameter probability. 49 | } 50 | \description{ 51 | This function predicts values based upon a model trained by \code{brplus}. 52 | } 53 | \details{ 54 | The strategies of estimate the values of the new features are separated in 55 | two groups: 56 | \describe{ 57 | \item{No Update (\code{NU})}{This use the initial prediction of BR to all 58 | labels. This name is because no modification is made to the initial 59 | estimates of the augmented features during the prediction phase} 60 | \item{With Update}{This strategy update the initial prediction in that the 61 | final predict occurs. There are three possibilities to define the order of 62 | label sequences: 63 | \describe{ 64 | \item{Specific order (\code{Ord})}{The order is define by the user, 65 | require a new argument called \code{order}.} 66 | \item{Static order (\code{Stat})}{Use the frequency of single labels in 67 | the training set to define the sequence, where the least frequent 68 | labels are predicted first} 69 | \item{Dinamic order (\code{Dyn})}{Takes into account the confidence of 70 | the initial prediction for each independent single label, to define a 71 | sequence, where the labels predicted with less confidence are updated 72 | first.} 73 | } 74 | } 75 | } 76 | } 77 | \examples{ 78 | # Predict SVM scores 79 | model <- brplus(toyml, "RANDOM") 80 | pred <- predict(model, toyml) 81 | 82 | \donttest{ 83 | # Predict SVM bipartitions and change the method to use No Update strategy 84 | pred <- predict(model, toyml, strategy = 'NU', probability = FALSE) 85 | 86 | # Predict using a random sequence to update the labels 87 | labels <- sample(rownames(toyml$labels)) 88 | pred <- predict(model, toyml, strategy = 'Ord', order = labels) 89 | 90 | # Passing a specif parameter for SVM predict method 91 | pred <- predict(model, toyml, na.action = na.fail) 92 | } 93 | } 94 | \references{ 95 | Cherman, E. A., Metz, J., & Monard, M. C. (2012). Incorporating label 96 | dependency into the binary relevance framework for multi-label 97 | classification. Expert Systems with Applications, 39(2), 1647-1655. 98 | } 99 | \seealso{ 100 | \code{\link[=brplus]{BR+}} 101 | } 102 | -------------------------------------------------------------------------------- /man/ebr.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/method_ebr.R 3 | \name{ebr} 4 | \alias{ebr} 5 | \title{Ensemble of Binary Relevance for multi-label Classification} 6 | \usage{ 7 | ebr( 8 | mdata, 9 | base.algorithm = getOption("utiml.base.algorithm", "SVM"), 10 | m = 10, 11 | subsample = 0.75, 12 | attr.space = 0.5, 13 | replacement = TRUE, 14 | ..., 15 | cores = getOption("utiml.cores", 1), 16 | seed = getOption("utiml.seed", NA) 17 | ) 18 | } 19 | \arguments{ 20 | \item{mdata}{A mldr dataset used to train the binary models.} 21 | 22 | \item{base.algorithm}{A string with the name of the base algorithm. (Default: 23 | \code{options("utiml.base.algorithm", "SVM")})} 24 | 25 | \item{m}{The number of Binary Relevance models used in the ensemble. 26 | (Default: 10)} 27 | 28 | \item{subsample}{A value between 0.1 and 1 to determine the percentage of 29 | training instances that must be used for each classifier. (Default: 0.75)} 30 | 31 | \item{attr.space}{A value between 0.1 and 1 to determine the percentage of 32 | attributes that must be used for each classifier. (Default: 0.50)} 33 | 34 | \item{replacement}{Boolean value to define if use sampling with replacement 35 | to create the data of the models of the ensemble. (Default: TRUE)} 36 | 37 | \item{...}{Others arguments passed to the base algorithm for all subproblems.} 38 | 39 | \item{cores}{The number of cores to parallelize the training. Values higher 40 | than 1 require the \pkg{parallel} package. (Default: 41 | \code{options("utiml.cores", 1)})} 42 | 43 | \item{seed}{An optional integer used to set the seed. This is useful when 44 | the method is run in parallel. (Default: \code{options("utiml.seed", NA)})} 45 | } 46 | \value{ 47 | An object of class \code{EBRmodel} containing the set of fitted 48 | BR models, including: 49 | \describe{ 50 | \item{models}{A list of BR models.} 51 | \item{nrow}{The number of instances used in each training dataset.} 52 | \item{ncol}{The number of attributes used in each training dataset.} 53 | \item{rounds}{The number of interactions.} 54 | } 55 | } 56 | \description{ 57 | Create an Ensemble of Binary Relevance model for multilabel classification. 58 | } 59 | \details{ 60 | This model is composed by a set of Binary Relevance models. Binary Relevance 61 | is a simple and effective transformation method to predict multi-label data. 62 | } 63 | \note{ 64 | If you want to reproduce the same classification and obtain the same 65 | result will be necessary set a flag utiml.mc.set.seed to FALSE. 66 | } 67 | \examples{ 68 | model <- ebr(toyml, "RANDOM") 69 | pred <- predict(model, toyml) 70 | 71 | \donttest{ 72 | # Use C5.0 with 90\% of instances and only 5 rounds 73 | model <- ebr(toyml, 'C5.0', m = 5, subsample = 0.9) 74 | 75 | # Use 75\% of attributes 76 | model <- ebr(toyml, attr.space = 0.75) 77 | 78 | # Running in 2 cores and define a specific seed 79 | model1 <- ebr(toyml, cores=2, seed = 312) 80 | } 81 | } 82 | \references{ 83 | Read, J., Pfahringer, B., Holmes, G., & Frank, E. (2011). Classifier 84 | chains for multi-label classification. Machine Learning, 85(3), 333-359. 85 | 86 | Read, J., Pfahringer, B., Holmes, G., & Frank, E. (2009). 87 | Classifier Chains for Multi-label Classification. Machine Learning and 88 | Knowledge Discovery in Databases, Lecture Notes in Computer Science, 89 | 5782, 254-269. 90 | } 91 | \seealso{ 92 | Other Transformation methods: 93 | \code{\link{brplus}()}, 94 | \code{\link{br}()}, 95 | \code{\link{cc}()}, 96 | \code{\link{clr}()}, 97 | \code{\link{dbr}()}, 98 | \code{\link{ecc}()}, 99 | \code{\link{eps}()}, 100 | \code{\link{esl}()}, 101 | \code{\link{homer}()}, 102 | \code{\link{lift}()}, 103 | \code{\link{lp}()}, 104 | \code{\link{mbr}()}, 105 | \code{\link{ns}()}, 106 | \code{\link{ppt}()}, 107 | \code{\link{prudent}()}, 108 | \code{\link{ps}()}, 109 | \code{\link{rakel}()}, 110 | \code{\link{rdbr}()}, 111 | \code{\link{rpc}()} 112 | 113 | Other Ensemble methods: 114 | \code{\link{ecc}()}, 115 | \code{\link{eps}()} 116 | } 117 | \concept{Ensemble methods} 118 | \concept{Transformation methods} 119 | --------------------------------------------------------------------------------