Skip to content

Commit

Permalink
make usable scorers backward compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
JakaKokosar committed Mar 8, 2022
1 parent d3dc522 commit d9b8d98
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Orange/widgets/evaluate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
QSortFilterProxyModel
from sklearn.exceptions import UndefinedMetricWarning

from Orange.data import Table, DiscreteVariable, ContinuousVariable
from Orange.data import Table, DiscreteVariable, ContinuousVariable, Variable
from Orange.evaluation import scoring
from Orange.widgets import gui
from Orange.widgets.utils.tableview import table_selection_to_mime_data
Expand Down Expand Up @@ -79,17 +79,22 @@ def learner_name(learner):
return getattr(learner, "name", type(learner).__name__)


def usable_scorers(data: Table):
if not data:
def usable_scorers(data_or_var: Union[Table, Variable]):
if not data_or_var:
return []

problem_type = data.attributes.get("problem_type", None)
target = data.domain.class_var

# 'abstract' is retrieved from __dict__ to avoid inheriting
scorer_candidates = [cls for cls in scoring.Score.registry.values()
if cls.is_scalar and not cls.__dict__.get("abstract")]

data, problem_type = None, None
if isinstance(data_or_var, Table):
data = data_or_var
problem_type = data.attributes.get("problem_type", None)
target = data.domain.class_var
else:
target = data_or_var

# If problem_type is not specified and 'domain.class_var' is set
# use builtin scorers and don't brake the default behaviour.
usable = []
Expand Down

0 comments on commit d9b8d98

Please sign in to comment.