1. Lan Zagar
  2. orange-multitask


Lan Zagar  committed 2d04b46

Tasks do not need to be indices.

  • Participants
  • Parent commits a258dff
  • Branches default

Comments (0)

Files changed (2)

File _multitask/__init__.py

View file
     :return: Dictionary with task identifiers and corresponding data sets.
-    task_indices = [int(ins[task_id]) for ins in data]
-    return {ind: data.select(task_indices, ind)
-            for ind in sorted(set(task_indices))}
+    tasks = [ins[task_id].value for ins in data]
+    t2i = {t: ind for ind, t in enumerate(sorted(set(tasks)))}
+    task_indices = [t2i[t] for t in tasks]
+    return {t: data.select(task_indices, t2i[t])
+            for t in sorted(t2i.keys())}
 def get_groups(domain, feat_att=None):
     if feat_att is None and domain.features and domain.features[0].attributes:
         self.classifiers = classifiers
     def __call__(self, instance, return_type=Orange.core.GetValue):
-        return self.classifiers[int(instance['task'])](instance, return_type)
+        return self.classifiers[instance['task'].value](instance, return_type)

File _multitask/mtfeat.py

View file
     def __call__(self, instance, return_type=Orange.core.GetValue):
         ins = Orange.data.Instance(self.domain, instance)
-        t = int(ins['task'])
+        t = self.tasks.index(ins['task'].value)
         f = dot(self.W[:, t], ins.native()[:-1])
         if self.intercepts:
             f += self.intercepts[t]