Skip to content

Commit

Permalink
Logistic regression: Fix penalty ('none' -> None)
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Sep 6, 2024
1 parent 6c742f7 commit f9f4e59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Orange/widgets/model/owlogisticregression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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}"
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Orange/widgets/model/tests/test_owlogisticregression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit f9f4e59

Please sign in to comment.