Esempio n. 1
0
 def _setup_delegate_discrete(self, delegate):
     colors = [QtGui.QColor(*rgb) for rgb in self.class_var.colors]
     fmt = []
     if self.show_probabilities:
         fmt.append(" : ".join("{{dist[{}]:.2f}}".format(i)
                               for i in sorted(self.selected_classes)))
     if self.show_predictions:
         fmt.append("{value!s}")
     delegate.setFormat(" \N{RIGHTWARDS ARROW} ".join(fmt))
     if self.draw_dist and colors is not None:
         delegate.setColors(colors)
     return delegate
Esempio n. 2
0
 def __getitem__(self, key):
     if not self:
         for tpe, char, col in ((vartype(ContinuousVariable("c")), "N",
                                 (202, 0,
                                  32)), (vartype(DiscreteVariable("d")),
                                         "C", (26, 150, 65)),
                                (vartype(StringVariable("s")), "S",
                                 (0, 0, 0)), (vartype(TimeVariable("t")),
                                              "T", (68, 170, 255)),
                                (-1, "?", (128, 128, 128))):
             self[tpe] = createAttributePixmap(char, QtGui.QColor(*col))
     if key not in self:
         key = vartype(key) if isinstance(key, Variable) else -1
     return super().__getitem__(key)
Esempio n. 3
0
 def __init__(self, parent=None, color=QtGui.QColor(255, 170, 127),
              color_schema=None):
     """
     :param QObject parent: Parent object.
     :param QColor color: Default color of the distribution bar.
     :param color_schema:
         If not None it must be an instance of
         :class:`OWColorPalette.ColorPaletteGenerator` (note: this
         parameter, if set, overrides the ``color``)
     :type color_schema: :class:`OWColorPalette.ColorPaletteGenerator`
     """
     super().__init__(parent)
     self.color = color
     self.color_schema = color_schema
Esempio n. 4
0
    def _update_prediction_delegate(self):
        """Update the predicted probability visibility state"""
        delegate = PredictionsItemDelegate()
        colors = None
        if self.class_var is not None:
            if self.class_var.is_discrete:
                colors = [QtGui.QColor(*rgb) for rgb in self.class_var.colors]
                dist_fmt = ""
                pred_fmt = ""
                if self.show_probabilities:
                    decimals = 2
                    float_fmt = "{{dist[{}]:.{}f}}"
                    dist_fmt = " : ".join(
                        float_fmt.format(i, decimals)
                        for i in range(len(self.class_var.values))
                        if i in self.selected_classes)
                if self.show_predictions:
                    pred_fmt = "{value!s}"
                if pred_fmt and dist_fmt:
                    fmt = dist_fmt + " \N{RIGHTWARDS ARROW} " + pred_fmt
                else:
                    fmt = dist_fmt or pred_fmt
            else:
                assert isinstance(self.class_var, ContinuousVariable)
                fmt = "{{value:.{}f}}".format(
                    self.class_var.number_of_decimals)

            delegate.setFormat(fmt)
            if self.draw_dist and colors is not None:
                delegate.setColors(colors)
            self.predictionsview.setItemDelegate(delegate)
            self.predictionsview.resizeColumnsToContents()

        if self.class_var is not None and self.class_var.is_discrete:
            proxy = self.predictionsview.model()
            if proxy is not None:
                proxy.setProbInd(numpy.array(self.selected_classes, dtype=int))
        self._update_spliter()