6b1a0130950ece66b22c9b0985220182b347f681,Orange/widgets/evaluate/owconfusionmatrix.py,OWConfusionMatrix,set_results,#OWConfusionMatrix#Any#,137

Before Change


            self.tablemodel.setRowCount(len(class_values) + 3)
            self.tablemodel.setColumnCount(len(class_values) + 3)
            self.selected_learner = [0]
            self._update()

    def clear(self):
        self.results = None
        self.data = None

After Change


    def _set_item(self, i, j, item):
        self.tablemodel.setItem(i, j, item)

    def set_results(self, results):
        Set the input results.

        prev_sel_learner = self.selected_learner[:]
        self.clear()
        self.warning([0, 1])
        self.closeContext()

        data = None
        if results is not None:
            if results.data is not None:
                data = results.data

        if data is not None and not data.domain.has_discrete_class:
            data = None
            results = None
            self.warning(
                0, "Confusion Matrix cannot be used for regression results.")

        self.results = results
        self.data = data

        if data is not None:
            class_values = data.domain.class_var.values
        elif results is not None:
            raise NotImplementedError

        if results is None:
            self.report_button.setDisabled(True)
        else:
            self.report_button.setDisabled(False)

            nmodels, ntests = results.predicted.shape
            self.headers = class_values + \
                           [unicodedata.lookup("N-ARY SUMMATION")]

            // NOTE: The "learner_names" is set in
            //  "Test Learners" widget.
            if hasattr(results, "learner_names"):
                self.learners = results.learner_names
            else:
                self.learners = ["Learner //%i" % (i + 1)
                                 for i in range(nmodels)]

            item = self._item(0, 2)
            item.setData("Predicted", Qt.DisplayRole)
            item.setTextAlignment(Qt.AlignCenter)
            item.setFlags(Qt.NoItemFlags)

            self._set_item(0, 2, item)
            item = self._item(2, 0)
            item.setData("Actual", Qt.DisplayRole)
            item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)
            item.setFlags(Qt.NoItemFlags)
            self.tableview.setItemDelegateForColumn(
                0, gui.VerticalItemDelegate())
            self._set_item(2, 0, item)
            self.tableview.setSpan(0, 2, 1, len(class_values))
            self.tableview.setSpan(2, 0, len(class_values), 1)

            font = self.tablemodel.invisibleRootItem().font()
            bold_font = QFont(font)
            bold_font.setBold(True)

            for i in (0, 1):
                for j in (0, 1):
                    item = self._item(i, j)
                    item.setFlags(Qt.NoItemFlags)
                    self._set_item(i, j, item)

            for p, label in enumerate(self.headers):
                for i, j in ((1, p + 2), (p + 2, 1)):
                    item = self._item(i, j)
                    item.setData(label, Qt.DisplayRole)
                    item.setFont(bold_font)
                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
                    item.setFlags(Qt.ItemIsEnabled)
                    if p < len(self.headers) - 1:
                        item.setData("br"[j == 1], BorderRole)
                        item.setData(QColor(192, 192, 192), BorderColorRole)
                    self._set_item(i, j, item)

            hor_header = self.tableview.horizontalHeader()
            if len(" ".join(self.headers)) < 120:
                hor_header.setResizeMode(QHeaderView.ResizeToContents)
            else:
                hor_header.setDefaultSectionSize(60)
            self.tablemodel.setRowCount(len(class_values) + 3)
            self.tablemodel.setColumnCount(len(class_values) + 3)
            self.openContext(data.domain.class_var)
            if not prev_sel_learner or \
                    prev_sel_learner[0] >= len(self.learners):
                self.selected_learner[:] = [0]
            else:
                self.selected_learner[:] = prev_sel_learner

    def clear(self):
        self.results = None
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: biolab/orange3
Commit Name: 6b1a0130950ece66b22c9b0985220182b347f681
Time: 2016-04-26
Author: janez.demsar@fri.uni-lj.si
File Name: Orange/widgets/evaluate/owconfusionmatrix.py
Class Name: OWConfusionMatrix
Method Name: set_results


Project Name: rusty1s/pytorch_geometric
Commit Name: c27c6fabf3ab76db73ae58970f04255cd1d9394d
Time: 2017-11-25
Author: matthias.fey@tu-dortmund.de
File Name: torch_geometric/datasets/utils/progress.py
Class Name: Progress
Method Name: update


Project Name: Kaixhin/Rainbow
Commit Name: 1203e6a3f3550228f760a4373e81c836e339dce3
Time: 2017-11-26
Author: design@kaixhin.com
File Name: memory.py
Class Name: SumTree
Method Name: update


Project Name: biolab/orange3
Commit Name: 6b1a0130950ece66b22c9b0985220182b347f681
Time: 2016-04-26
Author: janez.demsar@fri.uni-lj.si
File Name: Orange/widgets/evaluate/owconfusionmatrix.py
Class Name: OWConfusionMatrix
Method Name: set_results