|
12 | 12 | QSortFilterProxyModel
|
13 | 13 | from sklearn.exceptions import UndefinedMetricWarning
|
14 | 14 |
|
15 |
| -from Orange.data import Table, DiscreteVariable, ContinuousVariable |
| 15 | +from Orange.data import Table, DiscreteVariable, ContinuousVariable, Variable |
16 | 16 | from Orange.evaluation import scoring
|
17 | 17 | from Orange.widgets import gui
|
18 | 18 | from Orange.widgets.utils.tableview import table_selection_to_mime_data
|
@@ -79,17 +79,22 @@ def learner_name(learner):
|
79 | 79 | return getattr(learner, "name", type(learner).__name__)
|
80 | 80 |
|
81 | 81 |
|
82 |
| -def usable_scorers(data: Table): |
83 |
| - if not data: |
| 82 | +def usable_scorers(data_or_var: Union[Table, Variable]): |
| 83 | + if not data_or_var: |
84 | 84 | return []
|
85 | 85 |
|
86 |
| - problem_type = data.attributes.get("problem_type", None) |
87 |
| - target = data.domain.class_var |
88 |
| - |
89 | 86 | # 'abstract' is retrieved from __dict__ to avoid inheriting
|
90 | 87 | scorer_candidates = [cls for cls in scoring.Score.registry.values()
|
91 | 88 | if cls.is_scalar and not cls.__dict__.get("abstract")]
|
92 | 89 |
|
| 90 | + data, problem_type = None, None |
| 91 | + if isinstance(data_or_var, Table): |
| 92 | + data = data_or_var |
| 93 | + problem_type = data.attributes.get("problem_type", None) |
| 94 | + target = data.domain.class_var |
| 95 | + else: |
| 96 | + target = data_or_var |
| 97 | + |
93 | 98 | # If problem_type is not specified and 'domain.class_var' is set
|
94 | 99 | # use builtin scorers and don't brake the default behaviour.
|
95 | 100 | usable = []
|
|
0 commit comments