From d0f433eecfdf36498bd19565f3e884fa3b27543f Mon Sep 17 00:00:00 2001 From: Dongli He Date: Thu, 30 Nov 2023 23:12:20 +0400 Subject: [PATCH] rewrite for reproduction purpose only --- libmultilabel/linear/linear.py | 9 --------- linear_trainer.py | 14 +------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/libmultilabel/linear/linear.py b/libmultilabel/linear/linear.py index 00799f26d..c7e2b70c6 100644 --- a/libmultilabel/linear/linear.py +++ b/libmultilabel/linear/linear.py @@ -186,9 +186,6 @@ def train_thresholding( Returns: A model which can be used in predict_values. """ - if not is_multilabel: - raise ValueError("thresholding method doesn't support binary/multiclass datasets.") - x, options, bias = _prepare_options(x, options) y = y.tocsc() @@ -413,9 +410,6 @@ def train_cost_sensitive( Returns: A model which can be used in predict_values. """ - if not is_multilabel: - raise ValueError("cost_sensitive method doesn't support binary/multiclass datasets.") - # Follows the MATLAB implementation at https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/multilabel/ x, options, bias = _prepare_options(x, options) @@ -520,9 +514,6 @@ def train_cost_sensitive_micro( Returns: A model which can be used in predict_values. """ - if not is_multilabel: - raise ValueError("cost_sensitive_micro method doesn't support binary/multiclass datasets.") - # Follows the MATLAB implementation at https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/multilabel/ x, options, bias = _prepare_options(x, options) diff --git a/linear_trainer.py b/linear_trainer.py index d0602eabc..449868be6 100644 --- a/linear_trainer.py +++ b/linear_trainer.py @@ -40,19 +40,7 @@ def linear_test(config, model, datasets, label_mapping): def linear_train(datasets, config): # detect task type - is_multilabel = config.get("is_multilabel", "auto") - if is_multilabel == "auto": - is_multilabel = not is_multiclass_dataset(datasets["train"], "y") - elif not isinstance(is_multilabel, bool): - raise ValueError( - f'"is_multilabel" is expected to be either "auto", "True", or "False". But got "{is_multilabel}" instead.' - ) - - task_type = "multilabel" if is_multilabel else "binary/multiclass" - logging.info( - f'is_multilabel is set to "{config.get("is_multilabel", "auto")}". ' - f"Model will be trained in {task_type} mode." - ) + is_multilabel = not is_multiclass_dataset(datasets["train"], "y") # train if config.linear_technique == "tree":