Skip to content

[BUG] Can't set positive_class for tabular predictor #5114

@justinfinkle

Description

@justinfinkle

Bug Report Checklist

  • I provided code that demonstrates a minimal reproducible example.
  • I confirmed bug exists on the latest mainline of AutoGluon via source install.
  • I confirmed bug exists on the latest stable version of AutoGluon.

Describe the bug

Users can't set the positive_class for the TabularPredictor.

positive_class isn't in the set of kwargs since it is directly specified in the init. You can probably update

if positive_class is not None:
learner_kwargs["positive_class"] = kwargs["positive_class"]

To just:

learner_kwargs["positive_class"] = positive_class

or pass it directly to the AbstractTabularLearner type in the downstream call

Expected behavior

User's should be able to set the positive_class

To Reproduce

from autogluon.tabular import TabularDataset, TabularPredictor

data_root = 'https://autogluon.s3.amazonaws.com/datasets/Inc/'
train_data = TabularDataset(data_root + 'train.csv')
test_data = TabularDataset(data_root + 'test.csv')

predictor = TabularPredictor(label='class', positive_class='<=50K').fit(train_data=train_data)
predictions = predictor.predict(test_data)

Screenshots / Logs

in TabularPredictor.__init__(self, label, problem_type, eval_metric, path, verbosity, log_to_file, log_file_path, sample_weight, weight_evaluation, groups, positive_class, **kwargs)
    208 quantile_levels = kwargs.get("quantile_levels", None)
    209 if positive_class is not None:
--> 210     learner_kwargs["positive_class"] = kwargs["positive_class"]
    212 self._learner: AbstractTabularLearner = learner_type(
    213     path_context=path,
    214     label=label,
   (...)    222     **learner_kwargs,
    223 )
    224 self._learner_type = type(self._learner)

KeyError: 'positive_class'

Installed Versions

# Replace this code with the output of the following:
from autogluon.core.utils import show_versions
show_versions()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions