How to use the jupyter-innotater.jupyter_innotater.data.MultiClassInnotation function in jupyter-innotater

To help you get started, we’ve selected a few jupyter-innotater examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ideonate / jupyter-innotater / jupyter-innotater / jupyter_innotater / data.py View on Github external
def update_data(self, uindex):
        newval = self._get_widget_value()
        old_class_index = self._calc_class_index(uindex)
        if newval != self.classes[old_class_index]:
            class_index = self.classes.index(newval)
            if self.datadepth == 'onehot':
                self._set_data(uindex, old_class_index, 0)
                self._set_data(uindex, class_index, 1)
            elif self.datadepth == 'simple':
                self._set_data(uindex, class_index)
            else:
                # colvector
                self._set_data(uindex, 0, class_index)


class BinaryClassInnotation(MultiClassInnotation):

    def _guess_classes(self):
        self.classes = ['False', 'True']

    def _create_widget(self):
        return Checkbox(description=self.desc, layout=self.layout, disabled=self.disabled)

    def update_ui(self, uindex):
        self.get_widget().value = bool(self._calc_class_index(uindex) == 1)

    def _get_widget_value(self):
        return self.classes[self.get_widget().value and 1 or 0]


class TextInnotation(Innotation, DataMixin):