From f9f4e59d016fb4e52f6480dcb0bc69a49ed0d831 Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 6 Sep 2024 13:44:48 +0200 Subject: [PATCH] Logistic regression: Fix penalty ('none' -> None) --- Orange/widgets/model/owlogisticregression.py | 6 +++--- Orange/widgets/model/tests/test_owlogisticregression.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Orange/widgets/model/owlogisticregression.py b/Orange/widgets/model/owlogisticregression.py index 63c401b7797..95db40a6207 100644 --- a/Orange/widgets/model/owlogisticregression.py +++ b/Orange/widgets/model/owlogisticregression.py @@ -49,7 +49,7 @@ class Outputs(OWBaseLearner.Outputs): max_iter = 10000 penalty_types = ("Lasso (L1)", "Ridge (L2)", "None") - penalty_types_short = ["l1", "l2", "none"] + penalty_types_short = ["l1", "l2", None] class Warning(OWBaseLearner.Warning): class_weights_used = Msg("Weighting by class may decrease performance.") @@ -86,7 +86,7 @@ def add_main_layout(self): def set_c(self): self.strength_C = self.C_s[self.C_index] penalty = self.penalty_types_short[self.penalty_type] - enable_c = penalty != "none" + enable_c = penalty is not None self.c_box.setEnabled(enable_c) if enable_c: fmt = "C={}" if self.strength_C >= 1 else "C={:.3f}" @@ -110,7 +110,7 @@ def create_learner(self): self.Warning.class_weights_used() else: class_weight = None - if penalty == "none": + if penalty is None: C = 1.0 else: C = self.strength_C diff --git a/Orange/widgets/model/tests/test_owlogisticregression.py b/Orange/widgets/model/tests/test_owlogisticregression.py index c604817e411..47139172f20 100644 --- a/Orange/widgets/model/tests/test_owlogisticregression.py +++ b/Orange/widgets/model/tests/test_owlogisticregression.py @@ -125,10 +125,10 @@ def test_class_weights(self): self.assertTrue(self.widget.Warning.class_weights_used.is_shown()) def test_no_penalty(self): - self.widget.set_penalty("none") + self.widget.set_penalty(None) self.click_apply() lr = self.get_output(self.widget.Outputs.learner) - self.assertEqual(lr.penalty, "none") + self.assertEqual(lr.penalty, None) self.assertEqual(lr.C, 1.0) self.assertEqual(self.widget.c_label.text(), "N/A") self.assertFalse(self.widget.c_slider.isEnabledTo(self.widget))