Lan Zagar avatar Lan Zagar committed 2d04b46

Tasks do not need to be indices.

Comments (0)

Files changed (2)

_multitask/__init__.py

     
     :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)

_multitask/mtfeat.py

 
     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]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.