Skip to content

Commit

Permalink
Preprocess: Add missing __repr__methods
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Nov 19, 2022
1 parent f1726c2 commit 9a6b9fc
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Orange/widgets/data/owpreprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from Orange.preprocess import Continuize, ProjectPCA, RemoveNaNRows, \
ProjectCUR, Scale as _Scale, Randomize as _Randomize, RemoveSparse
from Orange.widgets import widget, gui
from Orange.widgets.utils.localization import pl
from Orange.widgets.settings import Setting
from Orange.widgets.utils.overlay import OverlayWidget
from Orange.widgets.utils.sql import check_sql_input
Expand Down Expand Up @@ -255,7 +256,7 @@ def __repr__(self):

class RemoveSparseEditor(BaseEditor):

options = ["missing", "zeros"]
options = ["missing values", "zeros"]

def __init__(self, parent=None, **kwargs):
super().__init__(parent, **kwargs)
Expand All @@ -266,11 +267,9 @@ def __init__(self, parent=None, **kwargs):
self.setLayout(QVBoxLayout())

self.layout().addWidget(QLabel("Remove features with too many"))
options = ["missing values",
"zeros"]
self.filter_buttons = QButtonGroup(exclusive=True)
self.filter_buttons.buttonClicked.connect(self.filterByClicked)
for idx, option, in enumerate(options):
for idx, option, in enumerate(self.options):
btn = QRadioButton(self, text=option, checked=idx == 0)
self.filter_buttons.addButton(btn, id=idx)
self.layout().addWidget(btn)
Expand Down Expand Up @@ -354,6 +353,15 @@ def createinstance(params):
threshold = params.pop('percThresh', 5) / 100
return RemoveSparse(threshold, filter0)

def __repr__(self):
desc = f"remove features with too many {self.options[self.filter0]}, threshold: "
if self.useFixedThreshold:
desc += f"{self.fixedThresh} {pl(self.fixedThresh, 'instance')}"
else:
desc += f"{self.percThresh} %"
return desc


class ImputeEditor(BaseEditor):
(NoImputation, Constant, Average,
Model, Random, DropRows, DropColumns) = 0, 1, 2, 3, 4, 5, 6
Expand Down Expand Up @@ -727,6 +735,12 @@ def createinstance(params):
# further implementations
raise NotImplementedError

def __repr__(self):
if self.__strategy == self.Fixed:
return f"select {self.__k} {pl(self.__k,'feature')}"
else:
return f"select {self.__p} % features"


def index_to_enum(enum, i):
"""Enums, by default, are not int-comparable, so use an ad-hoc mapping of
Expand Down

0 comments on commit 9a6b9fc

Please sign in to comment.