{
    "file_diffs": [
        {
            "old_file_content": "\"\"\"Confusion matrix widget\"\"\"\n\nfrom math import isnan, isinf\nfrom itertools import chain\nimport unicodedata\n\nfrom AnyQt.QtWidgets import QTableView, QHeaderView, QStyledItemDelegate, \\\n    QSizePolicy\nfrom AnyQt.QtGui import QFont, QBrush, QColor, QStandardItemModel, QStandardItem\nfrom AnyQt.QtCore import Qt, QSize, QItemSelectionModel, QItemSelection\nimport numpy as np\nimport sklearn.metrics as skl_metrics\n\nimport Orange\nfrom Orange.data.util import get_unique_names\nimport Orange.evaluation\nfrom Orange.widgets import widget, gui\nfrom Orange.widgets.settings import \\\n    Setting, ContextSetting, ClassValuesContextHandler\nfrom Orange.widgets.utils.annotated_data import (create_annotated_table,\n                                                 ANNOTATED_DATA_SIGNAL_NAME)\nfrom Orange.widgets.utils.widgetpreview import WidgetPreview\nfrom Orange.widgets.widget import Msg, Input, Output\n\n\ndef confusion_matrix(res, index):\n    \"\"\"\n    Compute confusion matrix\n\n    Args:\n        res (Orange.evaluation.Results): evaluation results\n        index (int): model index\n\n    Returns: Confusion matrix\n    \"\"\"\n    labels = np.arange(len(res.domain.class_var.values))\n    if not res.actual.size:\n        # scikit-learn will not return an zero matrix\n        return np.zeros((len(labels), len(labels)))\n    else:\n        return skl_metrics.confusion_matrix(\n            res.actual, res.predicted[index], labels=labels)\n\n\nBorderRole = next(gui.OrangeUserRole)\nBorderColorRole = next(gui.OrangeUserRole)\n\n\nclass BorderedItemDelegate(QStyledItemDelegate):\n    \"\"\"Item delegate that paints border at the specified sides\n\n    Data for `BorderRole` is a string containing letters t, r, b and/or l,\n    which defines the sides at which the border is drawn.\n\n    Role `BorderColorRole` sets the color for the cell. If not color is given,\n    `self.color` is used as default.\n\n    Args:\n        color (QColor): default color (default default is black)\n    \"\"\"\n    def __init__(self, color=Qt.black):\n        super().__init__()\n        self.color = color\n\n    def paint(self, painter, option, index):\n        \"\"\"Overloads `paint` to draw borders\"\"\"\n        QStyledItemDelegate.paint(self, painter, option, index)\n        borders = index.data(BorderRole)\n        if borders:\n            color = index.data(BorderColorRole) or self.color\n            painter.save()\n            painter.setPen(color)\n            rect = option.rect\n            for side, p1, p2 in ((\"t\", rect.topLeft(), rect.topRight()),\n                                 (\"r\", rect.topRight(), rect.bottomRight()),\n                                 (\"b\", rect.bottomLeft(), rect.bottomRight()),\n                                 (\"l\", rect.topLeft(), rect.bottomLeft())):\n                if side in borders:\n                    painter.drawLine(p1, p2)\n            painter.restore()\n\n\nclass OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    from Orange.widgets.evaluate.utils import results_for_preview\n    WidgetPreview(OWConfusionMatrix).run(results_for_preview(\"iris\"))\n",
            "new_file_content": "\"\"\"Confusion matrix widget\"\"\"\n\nfrom math import isnan, isinf\nfrom itertools import chain\nimport unicodedata\n\nfrom AnyQt.QtWidgets import QTableView, QHeaderView, QStyledItemDelegate, \\\n    QSizePolicy\nfrom AnyQt.QtGui import QFont, QBrush, QColor, QStandardItemModel, QStandardItem\nfrom AnyQt.QtCore import Qt, QSize, QItemSelectionModel, QItemSelection\nimport numpy as np\nimport sklearn.metrics as skl_metrics\n\nimport Orange\nfrom Orange.data.util import get_unique_names\nimport Orange.evaluation\nfrom Orange.widgets import widget, gui\nfrom Orange.widgets.settings import \\\n    Setting, ContextSetting, ClassValuesContextHandler\nfrom Orange.widgets.utils.annotated_data import (create_annotated_table,\n                                                 ANNOTATED_DATA_SIGNAL_NAME)\nfrom Orange.widgets.utils.widgetpreview import WidgetPreview\nfrom Orange.widgets.widget import Msg, Input, Output\n\n\ndef confusion_matrix(res, index):\n    \"\"\"\n    Compute confusion matrix\n\n    Args:\n        res (Orange.evaluation.Results): evaluation results\n        index (int): model index\n\n    Returns: Confusion matrix\n    \"\"\"\n    labels = np.arange(len(res.domain.class_var.values))\n    if not res.actual.size:\n        # scikit-learn will not return an zero matrix\n        return np.zeros((len(labels), len(labels)))\n    else:\n        return skl_metrics.confusion_matrix(\n            res.actual, res.predicted[index], labels=labels)\n\n\nBorderRole = next(gui.OrangeUserRole)\nBorderColorRole = next(gui.OrangeUserRole)\n\n\nclass BorderedItemDelegate(QStyledItemDelegate):\n    \"\"\"Item delegate that paints border at the specified sides\n\n    Data for `BorderRole` is a string containing letters t, r, b and/or l,\n    which defines the sides at which the border is drawn.\n\n    Role `BorderColorRole` sets the color for the cell. If not color is given,\n    `self.color` is used as default.\n\n    Args:\n        color (QColor): default color (default default is black)\n    \"\"\"\n    def __init__(self, color=Qt.black):\n        super().__init__()\n        self.color = color\n\n    def paint(self, painter, option, index):\n        \"\"\"Overloads `paint` to draw borders\"\"\"\n        QStyledItemDelegate.paint(self, painter, option, index)\n        borders = index.data(BorderRole)\n        if borders:\n            color = index.data(BorderColorRole) or self.color\n            painter.save()\n            painter.setPen(color)\n            rect = option.rect\n            for side, p1, p2 in ((\"t\", rect.topLeft(), rect.topRight()),\n                                 (\"r\", rect.topRight(), rect.bottomRight()),\n                                 (\"b\", rect.bottomLeft(), rect.bottomRight()),\n                                 (\"l\", rect.topLeft(), rect.bottomLeft())):\n                if side in borders:\n                    painter.drawLine(p1, p2)\n            painter.restore()\n\n\nclass OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\",\n                  \"Sum of probabilities\"]\n    qu_tooltips = [\"Number of correctly and incorrectly classified instances\",\n                   \"Proportion of predicted\",\n                   \"Proportion of actual\",\n                   \"Number of instances, distributed across columns \"\n                   \"according to predicted probabilities\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\", label=\"Show: \",\n                     items=self.quantities, tooltips=self.qu_tooltips,\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            learner_index = self.selected_learner[0]\n            if self.selected_quantity != 3:\n                cmatrix = confusion_matrix(self.results, learner_index)\n                colsum = cmatrix.sum(axis=0)\n                rowsum = cmatrix.sum(axis=1)\n\n            else:\n                probabilities = self.results.probabilities[learner_index]\n                n = probabilities.shape[1]\n                cmatrix = np.zeros((n, n), dtype=float)\n                for index in np.unique(self.results.actual).astype(int):\n                    mask = self.results.actual == index\n                    cmatrix[index] = np.sum(probabilities[mask], axis=0)\n                colsum = cmatrix.sum(axis=0)\n                rowsum = cmatrix.sum(axis=1)\n\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            elif self.selected_quantity == 1:\n                normalized = 100 * cmatrix / colsum\n                div = colors.max(axis=0)\n                formatstr = \"{:2.1f} %\"\n            elif self.selected_quantity == 2:\n                normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            elif self.selected_quantity == 3:\n                normalized = cmatrix\n                formatstr = \"{:2.1f}\"\n                div = np.array([colors.max()])\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                value = int(round(value))\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(colsum[i], \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(rowsum[i], \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(rowsum.sum()))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    from Orange.widgets.evaluate.utils import results_for_preview\n    WidgetPreview(OWConfusionMatrix).run(results_for_preview(\"iris\"))\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/evaluate/owconfusionmatrix.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "3f28eb3ea",
                "new_commit_hash": "8716ee812",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/evaluate/owconfusionmatrix.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/evaluate/owconfusionmatrix.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 99,
                            "length": 7
                        },
                        "new_range": {
                            "start": 99,
                            "length": 13
                        },
                        "section": "class OWConfusionMatrix(widget.OWWidget):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    quantities = [\"Number of instances\",",
                                "type": "context"
                            },
                            {
                                "content": "                  \"Proportion of predicted\",",
                                "type": "context"
                            },
                            {
                                "content": "                  \"Proportion of actual\"]",
                                "type": "deleted"
                            },
                            {
                                "content": "                  \"Proportion of actual\",",
                                "type": "added"
                            },
                            {
                                "content": "                  \"Sum of probabilities\"]",
                                "type": "added"
                            },
                            {
                                "content": "    qu_tooltips = [\"Number of correctly and incorrectly classified instances\",",
                                "type": "added"
                            },
                            {
                                "content": "                   \"Proportion of predicted\",",
                                "type": "added"
                            },
                            {
                                "content": "                   \"Proportion of actual\",",
                                "type": "added"
                            },
                            {
                                "content": "                   \"Number of instances, distributed across columns \"",
                                "type": "added"
                            },
                            {
                                "content": "                   \"according to predicted probabilities\"]",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    settings_version = 1",
                                "type": "context"
                            },
                            {
                                "content": "    settingsHandler = ClassValuesContextHandler()",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "class",
                            "name": "OWConfusionMatrix",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 83,
                            "end_lineno": 531,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 149,
                            "length": 8
                        },
                        "new_range": {
                            "start": 155,
                            "length": 8
                        },
                        "section": "class OWConfusionMatrix(widget.OWWidget):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        sbox = gui.hBox(box)",
                                "type": "context"
                            },
                            {
                                "content": "        gui.rubber(sbox)",
                                "type": "context"
                            },
                            {
                                "content": "        gui.comboBox(sbox, self, \"selected_quantity\",",
                                "type": "deleted"
                            },
                            {
                                "content": "                     items=self.quantities, label=\"Show: \",",
                                "type": "deleted"
                            },
                            {
                                "content": "        gui.comboBox(sbox, self, \"selected_quantity\", label=\"Show: \",",
                                "type": "added"
                            },
                            {
                                "content": "                     items=self.quantities, tooltips=self.qu_tooltips,",
                                "type": "added"
                            },
                            {
                                "content": "                     orientation=Qt.Horizontal, callback=self._update)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        self.tablemodel = QStandardItemModel(self)",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "class",
                            "name": "OWConfusionMatrix",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 83,
                            "end_lineno": 531,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "method",
                            "name": "OWConfusionMatrix.__init__",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 125,
                            "end_lineno": 177,
                            "parent": {
                                "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                                "type": "class",
                                "name": "OWConfusionMatrix",
                                "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 83,
                                "end_lineno": 531,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 445,
                            "length": 9
                        },
                        "new_range": {
                            "start": 451,
                            "length": 22
                        },
                        "section": "class OWConfusionMatrix(widget.OWWidget):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        # Update the displayed confusion matrix",
                                "type": "context"
                            },
                            {
                                "content": "        if self.results is not None and self.selected_learner:",
                                "type": "context"
                            },
                            {
                                "content": "            cmatrix = confusion_matrix(self.results, self.selected_learner[0])",
                                "type": "deleted"
                            },
                            {
                                "content": "            colsum = cmatrix.sum(axis=0)",
                                "type": "deleted"
                            },
                            {
                                "content": "            rowsum = cmatrix.sum(axis=1)",
                                "type": "deleted"
                            },
                            {
                                "content": "            learner_index = self.selected_learner[0]",
                                "type": "added"
                            },
                            {
                                "content": "            if self.selected_quantity != 3:",
                                "type": "added"
                            },
                            {
                                "content": "                cmatrix = confusion_matrix(self.results, learner_index)",
                                "type": "added"
                            },
                            {
                                "content": "                colsum = cmatrix.sum(axis=0)",
                                "type": "added"
                            },
                            {
                                "content": "                rowsum = cmatrix.sum(axis=1)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "            else:",
                                "type": "added"
                            },
                            {
                                "content": "                probabilities = self.results.probabilities[learner_index]",
                                "type": "added"
                            },
                            {
                                "content": "                n = probabilities.shape[1]",
                                "type": "added"
                            },
                            {
                                "content": "                cmatrix = np.zeros((n, n), dtype=float)",
                                "type": "added"
                            },
                            {
                                "content": "                for index in np.unique(self.results.actual).astype(int):",
                                "type": "added"
                            },
                            {
                                "content": "                    mask = self.results.actual == index",
                                "type": "added"
                            },
                            {
                                "content": "                    cmatrix[index] = np.sum(probabilities[mask], axis=0)",
                                "type": "added"
                            },
                            {
                                "content": "                colsum = cmatrix.sum(axis=0)",
                                "type": "added"
                            },
                            {
                                "content": "                rowsum = cmatrix.sum(axis=1)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "            n = len(cmatrix)",
                                "type": "context"
                            },
                            {
                                "content": "            diag = np.diag_indices(n)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "class",
                            "name": "OWConfusionMatrix",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 83,
                            "end_lineno": 531,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "method",
                            "name": "OWConfusionMatrix._update",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 442,
                            "end_lineno": 511,
                            "parent": {
                                "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                                "type": "class",
                                "name": "OWConfusionMatrix",
                                "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 83,
                                "end_lineno": 531,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 457,
                            "length": 14
                        },
                        "new_range": {
                            "start": 476,
                            "length": 18
                        },
                        "section": "class OWConfusionMatrix(widget.OWWidget):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                normalized = cmatrix.astype(int)",
                                "type": "context"
                            },
                            {
                                "content": "                formatstr = \"{}\"",
                                "type": "context"
                            },
                            {
                                "content": "                div = np.array([colors.max()])",
                                "type": "context"
                            },
                            {
                                "content": "            else:",
                                "type": "deleted"
                            },
                            {
                                "content": "                if self.selected_quantity == 1:",
                                "type": "deleted"
                            },
                            {
                                "content": "                    normalized = 100 * cmatrix / colsum",
                                "type": "deleted"
                            },
                            {
                                "content": "                    div = colors.max(axis=0)",
                                "type": "deleted"
                            },
                            {
                                "content": "                else:",
                                "type": "deleted"
                            },
                            {
                                "content": "                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]",
                                "type": "deleted"
                            },
                            {
                                "content": "                    div = colors.max(axis=1)[:, np.newaxis]",
                                "type": "deleted"
                            },
                            {
                                "content": "            elif self.selected_quantity == 1:",
                                "type": "added"
                            },
                            {
                                "content": "                normalized = 100 * cmatrix / colsum",
                                "type": "added"
                            },
                            {
                                "content": "                div = colors.max(axis=0)",
                                "type": "added"
                            },
                            {
                                "content": "                formatstr = \"{:2.1f} %\"",
                                "type": "added"
                            },
                            {
                                "content": "            elif self.selected_quantity == 2:",
                                "type": "added"
                            },
                            {
                                "content": "                normalized = 100 * cmatrix / rowsum[:, np.newaxis]",
                                "type": "added"
                            },
                            {
                                "content": "                div = colors.max(axis=1)[:, np.newaxis]",
                                "type": "added"
                            },
                            {
                                "content": "                formatstr = \"{:2.1f} %\"",
                                "type": "context"
                            },
                            {
                                "content": "            elif self.selected_quantity == 3:",
                                "type": "added"
                            },
                            {
                                "content": "                normalized = cmatrix",
                                "type": "added"
                            },
                            {
                                "content": "                formatstr = \"{:2.1f}\"",
                                "type": "added"
                            },
                            {
                                "content": "                div = np.array([colors.max()])",
                                "type": "added"
                            },
                            {
                                "content": "            div[div == 0] = 1",
                                "type": "context"
                            },
                            {
                                "content": "            colors /= div",
                                "type": "context"
                            },
                            {
                                "content": "            maxval = normalized[diag].max()",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "class",
                            "name": "OWConfusionMatrix",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 83,
                            "end_lineno": 531,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "method",
                            "name": "OWConfusionMatrix._update",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 442,
                            "end_lineno": 511,
                            "parent": {
                                "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                                "type": "class",
                                "name": "OWConfusionMatrix",
                                "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 83,
                                "end_lineno": 531,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 496,
                            "length": 6
                        },
                        "new_range": {
                            "start": 519,
                            "length": 7
                        },
                        "section": "class OWConfusionMatrix(widget.OWWidget):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "            bold_font.setBold(True)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "            def _sum_item(value, border=\"\"):",
                                "type": "context"
                            },
                            {
                                "content": "                value = int(round(value))",
                                "type": "added"
                            },
                            {
                                "content": "                item = QStandardItem()",
                                "type": "context"
                            },
                            {
                                "content": "                item.setData(value, Qt.DisplayRole)",
                                "type": "context"
                            },
                            {
                                "content": "                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "class",
                            "name": "OWConfusionMatrix",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\",\n                  \"Sum of probabilities\"]\n    qu_tooltips = [\"Number of correctly and incorrectly classified instances\",\n                   \"Proportion of predicted\",\n                   \"Proportion of actual\",\n                   \"Number of instances, distributed across columns \"\n                   \"according to predicted probabilities\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\", label=\"Show: \",\n                     items=self.quantities, tooltips=self.qu_tooltips,\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            learner_index = self.selected_learner[0]\n            if self.selected_quantity != 3:\n                cmatrix = confusion_matrix(self.results, learner_index)\n                colsum = cmatrix.sum(axis=0)\n                rowsum = cmatrix.sum(axis=1)\n\n            else:\n                probabilities = self.results.probabilities[learner_index]\n                n = probabilities.shape[1]\n                cmatrix = np.zeros((n, n), dtype=float)\n                for index in np.unique(self.results.actual).astype(int):\n                    mask = self.results.actual == index\n                    cmatrix[index] = np.sum(probabilities[mask], axis=0)\n                colsum = cmatrix.sum(axis=0)\n                rowsum = cmatrix.sum(axis=1)\n\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            elif self.selected_quantity == 1:\n                normalized = 100 * cmatrix / colsum\n                div = colors.max(axis=0)\n                formatstr = \"{:2.1f} %\"\n            elif self.selected_quantity == 2:\n                normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            elif self.selected_quantity == 3:\n                normalized = cmatrix\n                formatstr = \"{:2.1f}\"\n                div = np.array([colors.max()])\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                value = int(round(value))\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(colsum[i], \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(rowsum[i], \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(rowsum.sum()))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 83,
                            "end_lineno": 555,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "method",
                            "name": "OWConfusionMatrix._update",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\",\n                  \"Sum of probabilities\"]\n    qu_tooltips = [\"Number of correctly and incorrectly classified instances\",\n                   \"Proportion of predicted\",\n                   \"Proportion of actual\",\n                   \"Number of instances, distributed across columns \"\n                   \"according to predicted probabilities\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\", label=\"Show: \",\n                     items=self.quantities, tooltips=self.qu_tooltips,\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            learner_index = self.selected_learner[0]\n            if self.selected_quantity != 3:\n                cmatrix = confusion_matrix(self.results, learner_index)\n                colsum = cmatrix.sum(axis=0)\n                rowsum = cmatrix.sum(axis=1)\n\n            else:\n                probabilities = self.results.probabilities[learner_index]\n                n = probabilities.shape[1]\n                cmatrix = np.zeros((n, n), dtype=float)\n                for index in np.unique(self.results.actual).astype(int):\n                    mask = self.results.actual == index\n                    cmatrix[index] = np.sum(probabilities[mask], axis=0)\n                colsum = cmatrix.sum(axis=0)\n                rowsum = cmatrix.sum(axis=1)\n\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            elif self.selected_quantity == 1:\n                normalized = 100 * cmatrix / colsum\n                div = colors.max(axis=0)\n                formatstr = \"{:2.1f} %\"\n            elif self.selected_quantity == 2:\n                normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            elif self.selected_quantity == 3:\n                normalized = cmatrix\n                formatstr = \"{:2.1f}\"\n                div = np.array([colors.max()])\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                value = int(round(value))\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(colsum[i], \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(rowsum[i], \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(rowsum.sum()))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 448,
                            "end_lineno": 535,
                            "parent": {
                                "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                                "type": "class",
                                "name": "OWConfusionMatrix",
                                "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\",\n                  \"Sum of probabilities\"]\n    qu_tooltips = [\"Number of correctly and incorrectly classified instances\",\n                   \"Proportion of predicted\",\n                   \"Proportion of actual\",\n                   \"Number of instances, distributed across columns \"\n                   \"according to predicted probabilities\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\", label=\"Show: \",\n                     items=self.quantities, tooltips=self.qu_tooltips,\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            learner_index = self.selected_learner[0]\n            if self.selected_quantity != 3:\n                cmatrix = confusion_matrix(self.results, learner_index)\n                colsum = cmatrix.sum(axis=0)\n                rowsum = cmatrix.sum(axis=1)\n\n            else:\n                probabilities = self.results.probabilities[learner_index]\n                n = probabilities.shape[1]\n                cmatrix = np.zeros((n, n), dtype=float)\n                for index in np.unique(self.results.actual).astype(int):\n                    mask = self.results.actual == index\n                    cmatrix[index] = np.sum(probabilities[mask], axis=0)\n                colsum = cmatrix.sum(axis=0)\n                rowsum = cmatrix.sum(axis=1)\n\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            elif self.selected_quantity == 1:\n                normalized = 100 * cmatrix / colsum\n                div = colors.max(axis=0)\n                formatstr = \"{:2.1f} %\"\n            elif self.selected_quantity == 2:\n                normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            elif self.selected_quantity == 3:\n                normalized = cmatrix\n                formatstr = \"{:2.1f}\"\n                div = np.array([colors.max()])\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                value = int(round(value))\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(colsum[i], \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(rowsum[i], \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(rowsum.sum()))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 83,
                                "end_lineno": 555,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 506,
                            "length": 9
                        },
                        "new_range": {
                            "start": 530,
                            "length": 9
                        },
                        "section": "class OWConfusionMatrix(widget.OWWidget):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                return item",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "            for i in range(n):",
                                "type": "context"
                            },
                            {
                                "content": "                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))",
                                "type": "deleted"
                            },
                            {
                                "content": "                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))",
                                "type": "deleted"
                            },
                            {
                                "content": "            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))",
                                "type": "deleted"
                            },
                            {
                                "content": "                self._set_item(n + 2, i + 2, _sum_item(colsum[i], \"t\"))",
                                "type": "added"
                            },
                            {
                                "content": "                self._set_item(i + 2, n + 2, _sum_item(rowsum[i], \"l\"))",
                                "type": "added"
                            },
                            {
                                "content": "            self._set_item(n + 2, n + 2, _sum_item(rowsum.sum()))",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def send_report(self):",
                                "type": "context"
                            },
                            {
                                "content": "        \"\"\"Send report\"\"\"",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "class",
                            "name": "OWConfusionMatrix",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 83,
                            "end_lineno": 531,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                            "type": "method",
                            "name": "OWConfusionMatrix._update",
                            "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 442,
                            "end_lineno": 511,
                            "parent": {
                                "file_name": "Orange/widgets/evaluate/owconfusionmatrix.py",
                                "type": "class",
                                "name": "OWConfusionMatrix",
                                "content": "class OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 83,
                                "end_lineno": 531,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "# pylint: disable=missing-docstring, protected-access\nimport unittest\nimport numpy as np\n\nfrom Orange.data import Table, Domain\nfrom Orange.classification import NaiveBayesLearner, TreeLearner\nfrom Orange.regression import MeanLearner\nfrom Orange.evaluation.testing import CrossValidation, TestOnTrainingData, \\\n    ShuffleSplit, Results\nfrom Orange.widgets.evaluate.owconfusionmatrix import OWConfusionMatrix\nfrom Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin\nfrom Orange.widgets.tests.utils import possible_duplicate_table\n\n\nclass TestOWConfusionMatrix(WidgetTest, WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n\n        bayes = NaiveBayesLearner()\n        tree = TreeLearner()\n        # `data` is defined in WidgetOutputsTestMixin, pylint: disable=no-member\n        cls.iris = cls.data\n        titanic = Table(\"titanic\")\n        cv = CrossValidation(k=3, store_data=True)\n        cls.results_1_iris = cv(cls.iris, [bayes])\n        cls.results_2_iris = cv(cls.iris, [bayes, tree])\n        cls.results_2_titanic = cv(titanic, [bayes, tree])\n\n        cls.signal_name = \"Evaluation Results\"\n        cls.signal_data = cls.results_1_iris\n        cls.same_input_output_domain = False\n\n    def setUp(self):\n        self.widget = self.create_widget(OWConfusionMatrix,\n                                         stored_settings={\"auto_apply\": False})\n\n    def test_selected_learner(self):\n        \"\"\"Check learner and model for various values of all parameters\n        when pruning parameters are not checked\n        \"\"\"\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_iris)\n        self.assertEqual(self.widget.selected_learner, [0])\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_titanic)\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n\n    def _select_data(self):\n        self.widget.select_correct()\n        indices = self.widget.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        selected = [i for i, t in enumerate(zip(\n            self.widget.results.actual, self.widget.results.predicted[0]))\n                    if t in indices]\n        return self.widget.results.row_indices[selected]\n\n    def test_show_error_on_regression(self):\n        \"\"\"On regression data, the widget must show error\"\"\"\n        housing = Table(\"housing\")\n        results = TestOnTrainingData(store_data=True)(housing, [MeanLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n\n    def test_row_indices(self):\n        \"\"\"Map data instances when using random shuffling\"\"\"\n        results = ShuffleSplit(store_data=True\n                               )(self.iris, [NaiveBayesLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.widget.select_correct()\n        selected = self.get_output(self.widget.Outputs.selected_data)\n        # pylint: disable=unsubscriptable-object\n        correct = np.equal(results.actual, results.predicted)[0]\n        correct_indices = results.row_indices[correct]\n        self.assertSetEqual(set(self.iris[correct_indices].ids),\n                            set(selected.ids))\n\n    def test_empty_results(self):\n        \"\"\"Test on empty results.\"\"\"\n        res = Results(data=self.iris[:0], store_data=True)\n        res.row_indices = np.array([], dtype=int)\n        res.actual = np.array([])\n        res.predicted = np.array([[]])\n        res.probabilities = np.zeros((1, 0, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.widget.select_correct()\n        self.widget.select_wrong()\n\n    def test_nan_results(self):\n        \"\"\"Test on results with nan values in actual/predicted\"\"\"\n        res = Results(data=self.iris, nmethods=2, store_data=True)\n        res.row_indices = np.array([0, 50, 100], dtype=int)\n        res.actual = np.array([0., np.nan, 2.])\n        res.predicted = np.array([[np.nan, 1, 2],\n                                  [np.nan, np.nan, np.nan]])\n        res.probabilities = np.zeros((1, 3, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.assertTrue(self.widget.Error.invalid_values.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.invalid_values.is_shown())\n\n    def test_not_append_extra_meta_columns(self):\n        \"\"\"\n        When a user does not want append extra meta column, the widget\n        should not crash.\n        GH-2386\n        \"\"\"\n        self.widget.append_predictions = False\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n\n    def test_unique_output_domain(self):\n        bayes = NaiveBayesLearner()\n        data = possible_duplicate_table('iris(Learner #1)')\n        input_data = CrossValidation(k=3, store_data=True)(data, [bayes])\n        self.send_signal(self.widget.Inputs.evaluation_results, input_data)\n        output = self.get_output(self.widget.Outputs.annotated_data)\n        self.assertEqual(output.domain.metas[0].name, 'iris(Learner #1) (1)')\n\n    def test_unique_var_names(self):\n        bayes = NaiveBayesLearner()\n        domain = self.iris.domain\n        results = CrossValidation(k=3, store_data=True)(self.iris, [bayes])\n        self.widget.append_probabilities = True\n        self.widget.append_predictions = True\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        out_data = self.get_output(self.widget.Outputs.annotated_data)\n\n        widget2 = self.create_widget(OWConfusionMatrix)\n        data2 = out_data.transform(\n            Domain(domain.attributes, domain.class_vars,\n                   [meta for meta in out_data.domain.metas if \"versicolor\" not in meta.name]))\n        results2 = CrossValidation(k=3, store_data=True)(data2, [bayes])\n        widget2.append_probabilities = True\n        widget2.append_predictions = True\n        self.send_signal(widget2.Inputs.evaluation_results, results2)\n        out_data2 = self.get_output(widget2.Outputs.annotated_data)\n        self.assertEqual({meta.name for meta in out_data2.domain.metas},\n                         {'Selected', 'Selected (1)',\n                          'iris(Learner #1)', 'iris(Learner #1) (1)',\n                          'p(Iris-setosa)', 'p(Iris-virginica)',\n                          'p(Iris-setosa) (1)', 'p(Iris-versicolor) (1)',\n                          'p(Iris-virginica) (1)'})\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n",
            "new_file_content": "# pylint: disable=missing-docstring, protected-access\nimport unittest\nimport numpy as np\n\nfrom Orange.data import Table, Domain\nfrom Orange.classification import NaiveBayesLearner, TreeLearner\nfrom Orange.regression import MeanLearner\nfrom Orange.evaluation.testing import CrossValidation, TestOnTrainingData, \\\n    ShuffleSplit, Results\nfrom Orange.widgets.evaluate.owconfusionmatrix import OWConfusionMatrix\nfrom Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin\nfrom Orange.widgets.tests.utils import possible_duplicate_table, simulate\n\n\nclass TestOWConfusionMatrix(WidgetTest, WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n\n        bayes = NaiveBayesLearner()\n        tree = TreeLearner()\n        # `data` is defined in WidgetOutputsTestMixin, pylint: disable=no-member\n        cls.iris = cls.data\n        titanic = Table(\"titanic\")\n        cv = CrossValidation(k=3, store_data=True)\n        cls.results_1_iris = cv(cls.iris, [bayes])\n        cls.results_2_iris = cv(cls.iris, [bayes, tree])\n        cls.results_2_titanic = cv(titanic, [bayes, tree])\n\n        cls.signal_name = \"Evaluation Results\"\n        cls.signal_data = cls.results_1_iris\n        cls.same_input_output_domain = False\n\n    def setUp(self):\n        self.widget = self.create_widget(OWConfusionMatrix,\n                                         stored_settings={\"auto_apply\": False})\n\n    def test_selected_learner(self):\n        \"\"\"Check learner and model for various values of all parameters\n        when pruning parameters are not checked\n        \"\"\"\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_iris)\n        self.assertEqual(self.widget.selected_learner, [0])\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_titanic)\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n\n    def _select_data(self):\n        self.widget.select_correct()\n        indices = self.widget.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        selected = [i for i, t in enumerate(zip(\n            self.widget.results.actual, self.widget.results.predicted[0]))\n                    if t in indices]\n        return self.widget.results.row_indices[selected]\n\n    def test_show_error_on_regression(self):\n        \"\"\"On regression data, the widget must show error\"\"\"\n        housing = Table(\"housing\")\n        results = TestOnTrainingData(store_data=True)(housing, [MeanLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n\n    def test_row_indices(self):\n        \"\"\"Map data instances when using random shuffling\"\"\"\n        results = ShuffleSplit(store_data=True\n                               )(self.iris, [NaiveBayesLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.widget.select_correct()\n        selected = self.get_output(self.widget.Outputs.selected_data)\n        # pylint: disable=unsubscriptable-object\n        correct = np.equal(results.actual, results.predicted)[0]\n        correct_indices = results.row_indices[correct]\n        self.assertSetEqual(set(self.iris[correct_indices].ids),\n                            set(selected.ids))\n\n    def test_empty_results(self):\n        \"\"\"Test on empty results.\"\"\"\n        res = Results(data=self.iris[:0], store_data=True)\n        res.row_indices = np.array([], dtype=int)\n        res.actual = np.array([])\n        res.predicted = np.array([[]])\n        res.probabilities = np.zeros((1, 0, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.widget.select_correct()\n        self.widget.select_wrong()\n\n    def test_nan_results(self):\n        \"\"\"Test on results with nan values in actual/predicted\"\"\"\n        res = Results(data=self.iris, nmethods=2, store_data=True)\n        res.row_indices = np.array([0, 50, 100], dtype=int)\n        res.actual = np.array([0., np.nan, 2.])\n        res.predicted = np.array([[np.nan, 1, 2],\n                                  [np.nan, np.nan, np.nan]])\n        res.probabilities = np.zeros((1, 3, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.assertTrue(self.widget.Error.invalid_values.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.invalid_values.is_shown())\n\n    def test_not_append_extra_meta_columns(self):\n        \"\"\"\n        When a user does not want append extra meta column, the widget\n        should not crash.\n        GH-2386\n        \"\"\"\n        self.widget.append_predictions = False\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n\n    def test_unique_output_domain(self):\n        bayes = NaiveBayesLearner()\n        data = possible_duplicate_table('iris(Learner #1)')\n        input_data = CrossValidation(k=3, store_data=True)(data, [bayes])\n        self.send_signal(self.widget.Inputs.evaluation_results, input_data)\n        output = self.get_output(self.widget.Outputs.annotated_data)\n        self.assertEqual(output.domain.metas[0].name, 'iris(Learner #1) (1)')\n\n    def test_unique_var_names(self):\n        bayes = NaiveBayesLearner()\n        domain = self.iris.domain\n        results = CrossValidation(k=3, store_data=True)(self.iris, [bayes])\n        self.widget.append_probabilities = True\n        self.widget.append_predictions = True\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        out_data = self.get_output(self.widget.Outputs.annotated_data)\n\n        widget2 = self.create_widget(OWConfusionMatrix)\n        data2 = out_data.transform(\n            Domain(domain.attributes, domain.class_vars,\n                   [meta for meta in out_data.domain.metas if \"versicolor\" not in meta.name]))\n        results2 = CrossValidation(k=3, store_data=True)(data2, [bayes])\n        widget2.append_probabilities = True\n        widget2.append_predictions = True\n        self.send_signal(widget2.Inputs.evaluation_results, results2)\n        out_data2 = self.get_output(widget2.Outputs.annotated_data)\n        self.assertEqual({meta.name for meta in out_data2.domain.metas},\n                         {'Selected', 'Selected (1)',\n                          'iris(Learner #1)', 'iris(Learner #1) (1)',\n                          'p(Iris-setosa)', 'p(Iris-virginica)',\n                          'p(Iris-setosa) (1)', 'p(Iris-versicolor) (1)',\n                          'p(Iris-virginica) (1)'})\n\n    def test_sum_of_probabilities(self):\n        results: Results = self.results_1_iris\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        model = self.widget.tablemodel\n        n = model.rowCount() - 3\n        matrix = np.zeros((n, n))\n        probabilities = results.probabilities[0]\n        for label_index in np.unique(results.actual).astype(int):\n            mask = results.actual == label_index\n            prob_sum = np.sum(probabilities[mask], axis=0)\n            matrix[label_index] = prob_sum\n        colsum = matrix.sum(axis=0)\n        rowsum = matrix.sum(axis=1)\n\n        simulate.combobox_activate_index(\n            self.widget.controls.selected_quantity, 3)\n        # matrix\n        for i in range(n):\n            for j in range(n):\n                value = model.data(model.index(i + 2, j + 2))\n                self.assertAlmostEqual(float(value), matrix[i, j], 1)\n        # rowsum\n        for i in range(n):\n            value = model.data(model.index(i + 2, n + 2))\n            self.assertAlmostEqual(float(value), rowsum[i], 0)\n        # colsum\n        for i in range(n):\n            value = model.data(model.index(n + 2, i + 2))\n            self.assertAlmostEqual(float(value), colsum[i], 0)\n        # total\n        value = model.data(model.index(n + 2, n + 2))\n        self.assertAlmostEqual(float(value), colsum.sum(), 0)\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/evaluate/tests/test_owconfusionmatrix.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "1261e03ef",
                "new_commit_hash": "82939cd84",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/evaluate/tests/test_owconfusionmatrix.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/evaluate/tests/test_owconfusionmatrix.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 9,
                            "length": 7
                        },
                        "new_range": {
                            "start": 9,
                            "length": 7
                        },
                        "section": "from Orange.evaluation.testing import CrossValidation, TestOnTrainingData, \\"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "    ShuffleSplit, Results",
                                "type": "context"
                            },
                            {
                                "content": "from Orange.widgets.evaluate.owconfusionmatrix import OWConfusionMatrix",
                                "type": "context"
                            },
                            {
                                "content": "from Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin",
                                "type": "context"
                            },
                            {
                                "content": "from Orange.widgets.tests.utils import possible_duplicate_table",
                                "type": "deleted"
                            },
                            {
                                "content": "from Orange.widgets.tests.utils import possible_duplicate_table, simulate",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "class TestOWConfusionMatrix(WidgetTest, WidgetOutputsTestMixin):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/tests/test_owconfusionmatrix.py",
                            "type": "statement",
                            "name": "",
                            "content": "from Orange.widgets.tests.utils import possible_duplicate_table, simulate",
                            "ast_type_str": "ImportFrom",
                            "start_lineno": 12,
                            "end_lineno": 12,
                            "parent": null
                        }
                    ],
                    "deleted_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/tests/test_owconfusionmatrix.py",
                            "type": "statement",
                            "name": "",
                            "content": "from Orange.widgets.tests.utils import possible_duplicate_table",
                            "ast_type_str": "ImportFrom",
                            "start_lineno": 12,
                            "end_lineno": 12,
                            "parent": null
                        }
                    ]
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 153,
                            "length": 6
                        },
                        "new_range": {
                            "start": 153,
                            "length": 40
                        },
                        "section": "class TestOWConfusionMatrix(WidgetTest, WidgetOutputsTestMixin):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                          'p(Iris-setosa) (1)', 'p(Iris-versicolor) (1)',",
                                "type": "context"
                            },
                            {
                                "content": "                          'p(Iris-virginica) (1)'})",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_sum_of_probabilities(self):",
                                "type": "added"
                            },
                            {
                                "content": "        results: Results = self.results_1_iris",
                                "type": "added"
                            },
                            {
                                "content": "        self.send_signal(self.widget.Inputs.evaluation_results, results)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        model = self.widget.tablemodel",
                                "type": "added"
                            },
                            {
                                "content": "        n = model.rowCount() - 3",
                                "type": "added"
                            },
                            {
                                "content": "        matrix = np.zeros((n, n))",
                                "type": "added"
                            },
                            {
                                "content": "        probabilities = results.probabilities[0]",
                                "type": "added"
                            },
                            {
                                "content": "        for label_index in np.unique(results.actual).astype(int):",
                                "type": "added"
                            },
                            {
                                "content": "            mask = results.actual == label_index",
                                "type": "added"
                            },
                            {
                                "content": "            prob_sum = np.sum(probabilities[mask], axis=0)",
                                "type": "added"
                            },
                            {
                                "content": "            matrix[label_index] = prob_sum",
                                "type": "added"
                            },
                            {
                                "content": "        colsum = matrix.sum(axis=0)",
                                "type": "added"
                            },
                            {
                                "content": "        rowsum = matrix.sum(axis=1)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        simulate.combobox_activate_index(",
                                "type": "added"
                            },
                            {
                                "content": "            self.widget.controls.selected_quantity, 3)",
                                "type": "added"
                            },
                            {
                                "content": "        # matrix",
                                "type": "added"
                            },
                            {
                                "content": "        for i in range(n):",
                                "type": "added"
                            },
                            {
                                "content": "            for j in range(n):",
                                "type": "added"
                            },
                            {
                                "content": "                value = model.data(model.index(i + 2, j + 2))",
                                "type": "added"
                            },
                            {
                                "content": "                self.assertAlmostEqual(float(value), matrix[i, j], 1)",
                                "type": "added"
                            },
                            {
                                "content": "        # rowsum",
                                "type": "added"
                            },
                            {
                                "content": "        for i in range(n):",
                                "type": "added"
                            },
                            {
                                "content": "            value = model.data(model.index(i + 2, n + 2))",
                                "type": "added"
                            },
                            {
                                "content": "            self.assertAlmostEqual(float(value), rowsum[i], 0)",
                                "type": "added"
                            },
                            {
                                "content": "        # colsum",
                                "type": "added"
                            },
                            {
                                "content": "        for i in range(n):",
                                "type": "added"
                            },
                            {
                                "content": "            value = model.data(model.index(n + 2, i + 2))",
                                "type": "added"
                            },
                            {
                                "content": "            self.assertAlmostEqual(float(value), colsum[i], 0)",
                                "type": "added"
                            },
                            {
                                "content": "        # total",
                                "type": "added"
                            },
                            {
                                "content": "        value = model.data(model.index(n + 2, n + 2))",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertAlmostEqual(float(value), colsum.sum(), 0)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "if __name__ == \"__main__\":",
                                "type": "context"
                            },
                            {
                                "content": "    unittest.main()",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/tests/test_owconfusionmatrix.py",
                            "type": "class",
                            "name": "TestOWConfusionMatrix",
                            "content": "class TestOWConfusionMatrix(WidgetTest, WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n\n        bayes = NaiveBayesLearner()\n        tree = TreeLearner()\n        # `data` is defined in WidgetOutputsTestMixin, pylint: disable=no-member\n        cls.iris = cls.data\n        titanic = Table(\"titanic\")\n        cv = CrossValidation(k=3, store_data=True)\n        cls.results_1_iris = cv(cls.iris, [bayes])\n        cls.results_2_iris = cv(cls.iris, [bayes, tree])\n        cls.results_2_titanic = cv(titanic, [bayes, tree])\n\n        cls.signal_name = \"Evaluation Results\"\n        cls.signal_data = cls.results_1_iris\n        cls.same_input_output_domain = False\n\n    def setUp(self):\n        self.widget = self.create_widget(OWConfusionMatrix,\n                                         stored_settings={\"auto_apply\": False})\n\n    def test_selected_learner(self):\n        \"\"\"Check learner and model for various values of all parameters\n        when pruning parameters are not checked\n        \"\"\"\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_iris)\n        self.assertEqual(self.widget.selected_learner, [0])\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_titanic)\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n\n    def _select_data(self):\n        self.widget.select_correct()\n        indices = self.widget.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        selected = [i for i, t in enumerate(zip(\n            self.widget.results.actual, self.widget.results.predicted[0]))\n                    if t in indices]\n        return self.widget.results.row_indices[selected]\n\n    def test_show_error_on_regression(self):\n        \"\"\"On regression data, the widget must show error\"\"\"\n        housing = Table(\"housing\")\n        results = TestOnTrainingData(store_data=True)(housing, [MeanLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n\n    def test_row_indices(self):\n        \"\"\"Map data instances when using random shuffling\"\"\"\n        results = ShuffleSplit(store_data=True\n                               )(self.iris, [NaiveBayesLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.widget.select_correct()\n        selected = self.get_output(self.widget.Outputs.selected_data)\n        # pylint: disable=unsubscriptable-object\n        correct = np.equal(results.actual, results.predicted)[0]\n        correct_indices = results.row_indices[correct]\n        self.assertSetEqual(set(self.iris[correct_indices].ids),\n                            set(selected.ids))\n\n    def test_empty_results(self):\n        \"\"\"Test on empty results.\"\"\"\n        res = Results(data=self.iris[:0], store_data=True)\n        res.row_indices = np.array([], dtype=int)\n        res.actual = np.array([])\n        res.predicted = np.array([[]])\n        res.probabilities = np.zeros((1, 0, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.widget.select_correct()\n        self.widget.select_wrong()\n\n    def test_nan_results(self):\n        \"\"\"Test on results with nan values in actual/predicted\"\"\"\n        res = Results(data=self.iris, nmethods=2, store_data=True)\n        res.row_indices = np.array([0, 50, 100], dtype=int)\n        res.actual = np.array([0., np.nan, 2.])\n        res.predicted = np.array([[np.nan, 1, 2],\n                                  [np.nan, np.nan, np.nan]])\n        res.probabilities = np.zeros((1, 3, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.assertTrue(self.widget.Error.invalid_values.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.invalid_values.is_shown())\n\n    def test_not_append_extra_meta_columns(self):\n        \"\"\"\n        When a user does not want append extra meta column, the widget\n        should not crash.\n        GH-2386\n        \"\"\"\n        self.widget.append_predictions = False\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n\n    def test_unique_output_domain(self):\n        bayes = NaiveBayesLearner()\n        data = possible_duplicate_table('iris(Learner #1)')\n        input_data = CrossValidation(k=3, store_data=True)(data, [bayes])\n        self.send_signal(self.widget.Inputs.evaluation_results, input_data)\n        output = self.get_output(self.widget.Outputs.annotated_data)\n        self.assertEqual(output.domain.metas[0].name, 'iris(Learner #1) (1)')\n\n    def test_unique_var_names(self):\n        bayes = NaiveBayesLearner()\n        domain = self.iris.domain\n        results = CrossValidation(k=3, store_data=True)(self.iris, [bayes])\n        self.widget.append_probabilities = True\n        self.widget.append_predictions = True\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        out_data = self.get_output(self.widget.Outputs.annotated_data)\n\n        widget2 = self.create_widget(OWConfusionMatrix)\n        data2 = out_data.transform(\n            Domain(domain.attributes, domain.class_vars,\n                   [meta for meta in out_data.domain.metas if \"versicolor\" not in meta.name]))\n        results2 = CrossValidation(k=3, store_data=True)(data2, [bayes])\n        widget2.append_probabilities = True\n        widget2.append_predictions = True\n        self.send_signal(widget2.Inputs.evaluation_results, results2)\n        out_data2 = self.get_output(widget2.Outputs.annotated_data)\n        self.assertEqual({meta.name for meta in out_data2.domain.metas},\n                         {'Selected', 'Selected (1)',\n                          'iris(Learner #1)', 'iris(Learner #1) (1)',\n                          'p(Iris-setosa)', 'p(Iris-virginica)',\n                          'p(Iris-setosa) (1)', 'p(Iris-versicolor) (1)',\n                          'p(Iris-virginica) (1)'})\n\n    def test_sum_of_probabilities(self):\n        results: Results = self.results_1_iris\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        model = self.widget.tablemodel\n        n = model.rowCount() - 3\n        matrix = np.zeros((n, n))\n        probabilities = results.probabilities[0]\n        for label_index in np.unique(results.actual).astype(int):\n            mask = results.actual == label_index\n            prob_sum = np.sum(probabilities[mask], axis=0)\n            matrix[label_index] = prob_sum\n        colsum = matrix.sum(axis=0)\n        rowsum = matrix.sum(axis=1)\n\n        simulate.combobox_activate_index(\n            self.widget.controls.selected_quantity, 3)\n        # matrix\n        for i in range(n):\n            for j in range(n):\n                value = model.data(model.index(i + 2, j + 2))\n                self.assertAlmostEqual(float(value), matrix[i, j], 1)\n        # rowsum\n        for i in range(n):\n            value = model.data(model.index(i + 2, n + 2))\n            self.assertAlmostEqual(float(value), rowsum[i], 0)\n        # colsum\n        for i in range(n):\n            value = model.data(model.index(n + 2, i + 2))\n            self.assertAlmostEqual(float(value), colsum[i], 0)\n        # total\n        value = model.data(model.index(n + 2, n + 2))\n        self.assertAlmostEqual(float(value), colsum.sum(), 0)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 15,
                            "end_lineno": 188,
                            "parent": null
                        }
                    ],
                    "added_entities": [
                        {
                            "file_name": "Orange/widgets/evaluate/tests/test_owconfusionmatrix.py",
                            "type": "method",
                            "name": "TestOWConfusionMatrix.test_sum_of_probabilities",
                            "content": "class TestOWConfusionMatrix(WidgetTest, WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n\n        bayes = NaiveBayesLearner()\n        tree = TreeLearner()\n        # `data` is defined in WidgetOutputsTestMixin, pylint: disable=no-member\n        cls.iris = cls.data\n        titanic = Table(\"titanic\")\n        cv = CrossValidation(k=3, store_data=True)\n        cls.results_1_iris = cv(cls.iris, [bayes])\n        cls.results_2_iris = cv(cls.iris, [bayes, tree])\n        cls.results_2_titanic = cv(titanic, [bayes, tree])\n\n        cls.signal_name = \"Evaluation Results\"\n        cls.signal_data = cls.results_1_iris\n        cls.same_input_output_domain = False\n\n    def setUp(self):\n        self.widget = self.create_widget(OWConfusionMatrix,\n                                         stored_settings={\"auto_apply\": False})\n\n    def test_selected_learner(self):\n        \"\"\"Check learner and model for various values of all parameters\n        when pruning parameters are not checked\n        \"\"\"\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_iris)\n        self.assertEqual(self.widget.selected_learner, [0])\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_titanic)\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n\n    def _select_data(self):\n        self.widget.select_correct()\n        indices = self.widget.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        selected = [i for i, t in enumerate(zip(\n            self.widget.results.actual, self.widget.results.predicted[0]))\n                    if t in indices]\n        return self.widget.results.row_indices[selected]\n\n    def test_show_error_on_regression(self):\n        \"\"\"On regression data, the widget must show error\"\"\"\n        housing = Table(\"housing\")\n        results = TestOnTrainingData(store_data=True)(housing, [MeanLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n\n    def test_row_indices(self):\n        \"\"\"Map data instances when using random shuffling\"\"\"\n        results = ShuffleSplit(store_data=True\n                               )(self.iris, [NaiveBayesLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.widget.select_correct()\n        selected = self.get_output(self.widget.Outputs.selected_data)\n        # pylint: disable=unsubscriptable-object\n        correct = np.equal(results.actual, results.predicted)[0]\n        correct_indices = results.row_indices[correct]\n        self.assertSetEqual(set(self.iris[correct_indices].ids),\n                            set(selected.ids))\n\n    def test_empty_results(self):\n        \"\"\"Test on empty results.\"\"\"\n        res = Results(data=self.iris[:0], store_data=True)\n        res.row_indices = np.array([], dtype=int)\n        res.actual = np.array([])\n        res.predicted = np.array([[]])\n        res.probabilities = np.zeros((1, 0, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.widget.select_correct()\n        self.widget.select_wrong()\n\n    def test_nan_results(self):\n        \"\"\"Test on results with nan values in actual/predicted\"\"\"\n        res = Results(data=self.iris, nmethods=2, store_data=True)\n        res.row_indices = np.array([0, 50, 100], dtype=int)\n        res.actual = np.array([0., np.nan, 2.])\n        res.predicted = np.array([[np.nan, 1, 2],\n                                  [np.nan, np.nan, np.nan]])\n        res.probabilities = np.zeros((1, 3, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.assertTrue(self.widget.Error.invalid_values.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.invalid_values.is_shown())\n\n    def test_not_append_extra_meta_columns(self):\n        \"\"\"\n        When a user does not want append extra meta column, the widget\n        should not crash.\n        GH-2386\n        \"\"\"\n        self.widget.append_predictions = False\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n\n    def test_unique_output_domain(self):\n        bayes = NaiveBayesLearner()\n        data = possible_duplicate_table('iris(Learner #1)')\n        input_data = CrossValidation(k=3, store_data=True)(data, [bayes])\n        self.send_signal(self.widget.Inputs.evaluation_results, input_data)\n        output = self.get_output(self.widget.Outputs.annotated_data)\n        self.assertEqual(output.domain.metas[0].name, 'iris(Learner #1) (1)')\n\n    def test_unique_var_names(self):\n        bayes = NaiveBayesLearner()\n        domain = self.iris.domain\n        results = CrossValidation(k=3, store_data=True)(self.iris, [bayes])\n        self.widget.append_probabilities = True\n        self.widget.append_predictions = True\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        out_data = self.get_output(self.widget.Outputs.annotated_data)\n\n        widget2 = self.create_widget(OWConfusionMatrix)\n        data2 = out_data.transform(\n            Domain(domain.attributes, domain.class_vars,\n                   [meta for meta in out_data.domain.metas if \"versicolor\" not in meta.name]))\n        results2 = CrossValidation(k=3, store_data=True)(data2, [bayes])\n        widget2.append_probabilities = True\n        widget2.append_predictions = True\n        self.send_signal(widget2.Inputs.evaluation_results, results2)\n        out_data2 = self.get_output(widget2.Outputs.annotated_data)\n        self.assertEqual({meta.name for meta in out_data2.domain.metas},\n                         {'Selected', 'Selected (1)',\n                          'iris(Learner #1)', 'iris(Learner #1) (1)',\n                          'p(Iris-setosa)', 'p(Iris-virginica)',\n                          'p(Iris-setosa) (1)', 'p(Iris-versicolor) (1)',\n                          'p(Iris-virginica) (1)'})\n\n    def test_sum_of_probabilities(self):\n        results: Results = self.results_1_iris\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        model = self.widget.tablemodel\n        n = model.rowCount() - 3\n        matrix = np.zeros((n, n))\n        probabilities = results.probabilities[0]\n        for label_index in np.unique(results.actual).astype(int):\n            mask = results.actual == label_index\n            prob_sum = np.sum(probabilities[mask], axis=0)\n            matrix[label_index] = prob_sum\n        colsum = matrix.sum(axis=0)\n        rowsum = matrix.sum(axis=1)\n\n        simulate.combobox_activate_index(\n            self.widget.controls.selected_quantity, 3)\n        # matrix\n        for i in range(n):\n            for j in range(n):\n                value = model.data(model.index(i + 2, j + 2))\n                self.assertAlmostEqual(float(value), matrix[i, j], 1)\n        # rowsum\n        for i in range(n):\n            value = model.data(model.index(i + 2, n + 2))\n            self.assertAlmostEqual(float(value), rowsum[i], 0)\n        # colsum\n        for i in range(n):\n            value = model.data(model.index(n + 2, i + 2))\n            self.assertAlmostEqual(float(value), colsum[i], 0)\n        # total\n        value = model.data(model.index(n + 2, n + 2))\n        self.assertAlmostEqual(float(value), colsum.sum(), 0)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 156,
                            "end_lineno": 188,
                            "parent": {
                                "file_name": "Orange/widgets/evaluate/tests/test_owconfusionmatrix.py",
                                "type": "class",
                                "name": "TestOWConfusionMatrix",
                                "content": "class TestOWConfusionMatrix(WidgetTest, WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n\n        bayes = NaiveBayesLearner()\n        tree = TreeLearner()\n        # `data` is defined in WidgetOutputsTestMixin, pylint: disable=no-member\n        cls.iris = cls.data\n        titanic = Table(\"titanic\")\n        cv = CrossValidation(k=3, store_data=True)\n        cls.results_1_iris = cv(cls.iris, [bayes])\n        cls.results_2_iris = cv(cls.iris, [bayes, tree])\n        cls.results_2_titanic = cv(titanic, [bayes, tree])\n\n        cls.signal_name = \"Evaluation Results\"\n        cls.signal_data = cls.results_1_iris\n        cls.same_input_output_domain = False\n\n    def setUp(self):\n        self.widget = self.create_widget(OWConfusionMatrix,\n                                         stored_settings={\"auto_apply\": False})\n\n    def test_selected_learner(self):\n        \"\"\"Check learner and model for various values of all parameters\n        when pruning parameters are not checked\n        \"\"\"\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_iris)\n        self.assertEqual(self.widget.selected_learner, [0])\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_titanic)\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n\n    def _select_data(self):\n        self.widget.select_correct()\n        indices = self.widget.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        selected = [i for i, t in enumerate(zip(\n            self.widget.results.actual, self.widget.results.predicted[0]))\n                    if t in indices]\n        return self.widget.results.row_indices[selected]\n\n    def test_show_error_on_regression(self):\n        \"\"\"On regression data, the widget must show error\"\"\"\n        housing = Table(\"housing\")\n        results = TestOnTrainingData(store_data=True)(housing, [MeanLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n\n    def test_row_indices(self):\n        \"\"\"Map data instances when using random shuffling\"\"\"\n        results = ShuffleSplit(store_data=True\n                               )(self.iris, [NaiveBayesLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.widget.select_correct()\n        selected = self.get_output(self.widget.Outputs.selected_data)\n        # pylint: disable=unsubscriptable-object\n        correct = np.equal(results.actual, results.predicted)[0]\n        correct_indices = results.row_indices[correct]\n        self.assertSetEqual(set(self.iris[correct_indices].ids),\n                            set(selected.ids))\n\n    def test_empty_results(self):\n        \"\"\"Test on empty results.\"\"\"\n        res = Results(data=self.iris[:0], store_data=True)\n        res.row_indices = np.array([], dtype=int)\n        res.actual = np.array([])\n        res.predicted = np.array([[]])\n        res.probabilities = np.zeros((1, 0, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.widget.select_correct()\n        self.widget.select_wrong()\n\n    def test_nan_results(self):\n        \"\"\"Test on results with nan values in actual/predicted\"\"\"\n        res = Results(data=self.iris, nmethods=2, store_data=True)\n        res.row_indices = np.array([0, 50, 100], dtype=int)\n        res.actual = np.array([0., np.nan, 2.])\n        res.predicted = np.array([[np.nan, 1, 2],\n                                  [np.nan, np.nan, np.nan]])\n        res.probabilities = np.zeros((1, 3, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.assertTrue(self.widget.Error.invalid_values.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.invalid_values.is_shown())\n\n    def test_not_append_extra_meta_columns(self):\n        \"\"\"\n        When a user does not want append extra meta column, the widget\n        should not crash.\n        GH-2386\n        \"\"\"\n        self.widget.append_predictions = False\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n\n    def test_unique_output_domain(self):\n        bayes = NaiveBayesLearner()\n        data = possible_duplicate_table('iris(Learner #1)')\n        input_data = CrossValidation(k=3, store_data=True)(data, [bayes])\n        self.send_signal(self.widget.Inputs.evaluation_results, input_data)\n        output = self.get_output(self.widget.Outputs.annotated_data)\n        self.assertEqual(output.domain.metas[0].name, 'iris(Learner #1) (1)')\n\n    def test_unique_var_names(self):\n        bayes = NaiveBayesLearner()\n        domain = self.iris.domain\n        results = CrossValidation(k=3, store_data=True)(self.iris, [bayes])\n        self.widget.append_probabilities = True\n        self.widget.append_predictions = True\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        out_data = self.get_output(self.widget.Outputs.annotated_data)\n\n        widget2 = self.create_widget(OWConfusionMatrix)\n        data2 = out_data.transform(\n            Domain(domain.attributes, domain.class_vars,\n                   [meta for meta in out_data.domain.metas if \"versicolor\" not in meta.name]))\n        results2 = CrossValidation(k=3, store_data=True)(data2, [bayes])\n        widget2.append_probabilities = True\n        widget2.append_predictions = True\n        self.send_signal(widget2.Inputs.evaluation_results, results2)\n        out_data2 = self.get_output(widget2.Outputs.annotated_data)\n        self.assertEqual({meta.name for meta in out_data2.domain.metas},\n                         {'Selected', 'Selected (1)',\n                          'iris(Learner #1)', 'iris(Learner #1) (1)',\n                          'p(Iris-setosa)', 'p(Iris-virginica)',\n                          'p(Iris-setosa) (1)', 'p(Iris-versicolor) (1)',\n                          'p(Iris-virginica) (1)'})\n\n    def test_sum_of_probabilities(self):\n        results: Results = self.results_1_iris\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        model = self.widget.tablemodel\n        n = model.rowCount() - 3\n        matrix = np.zeros((n, n))\n        probabilities = results.probabilities[0]\n        for label_index in np.unique(results.actual).astype(int):\n            mask = results.actual == label_index\n            prob_sum = np.sum(probabilities[mask], axis=0)\n            matrix[label_index] = prob_sum\n        colsum = matrix.sum(axis=0)\n        rowsum = matrix.sum(axis=1)\n\n        simulate.combobox_activate_index(\n            self.widget.controls.selected_quantity, 3)\n        # matrix\n        for i in range(n):\n            for j in range(n):\n                value = model.data(model.index(i + 2, j + 2))\n                self.assertAlmostEqual(float(value), matrix[i, j], 1)\n        # rowsum\n        for i in range(n):\n            value = model.data(model.index(i + 2, n + 2))\n            self.assertAlmostEqual(float(value), rowsum[i], 0)\n        # colsum\n        for i in range(n):\n            value = model.data(model.index(n + 2, i + 2))\n            self.assertAlmostEqual(float(value), colsum[i], 0)\n        # total\n        value = model.data(model.index(n + 2, n + 2))\n        self.assertAlmostEqual(float(value), colsum.sum(), 0)",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 15,
                                "end_lineno": 188,
                                "parent": null
                            }
                        }
                    ],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "7ed8c4f21f672008a8f0c0b9bafc00b368b36e31^",
    "new_commit_hash": "7ed8c4f21f672008a8f0c0b9bafc00b368b36e31",
    "commit_message": "Merge pull request #6101 from VesnaT/conf_matrix_prob\n\nConfusion Matrix: Add Sum of probabilities",
    "commit_date": "2022-09-16T22:05:55+02:00",
    "metadata": {}
}
{
    "repo_name": "orange3",
    "new_commit_hash": "7ed8c4f21f672008a8f0c0b9bafc00b368b36e31",
    "test_file_codes": [
        "# pylint: disable=missing-docstring, protected-access\nimport unittest\nimport numpy as np\n\nfrom Orange.data import Table, Domain\nfrom Orange.classification import NaiveBayesLearner, TreeLearner\nfrom Orange.regression import MeanLearner\nfrom Orange.evaluation.testing import CrossValidation, TestOnTrainingData, \\\n    ShuffleSplit, Results\nfrom Orange.widgets.evaluate.owconfusionmatrix import OWConfusionMatrix\nfrom Orange.widgets.tests.base import WidgetTest, WidgetOutputsTestMixin\nfrom Orange.widgets.tests.utils import possible_duplicate_table, simulate\n\n\nclass TestOWConfusionMatrix(WidgetTest, WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n\n        bayes = NaiveBayesLearner()\n        tree = TreeLearner()\n        # `data` is defined in WidgetOutputsTestMixin, pylint: disable=no-member\n        cls.iris = cls.data\n        titanic = Table(\"titanic\")\n        cv = CrossValidation(k=3, store_data=True)\n        cls.results_1_iris = cv(cls.iris, [bayes])\n        cls.results_2_iris = cv(cls.iris, [bayes, tree])\n        cls.results_2_titanic = cv(titanic, [bayes, tree])\n\n        cls.signal_name = \"Evaluation Results\"\n        cls.signal_data = cls.results_1_iris\n        cls.same_input_output_domain = False\n\n    def setUp(self):\n        self.widget = self.create_widget(OWConfusionMatrix,\n                                         stored_settings={\"auto_apply\": False})\n\n    def test_selected_learner(self):\n        \"\"\"Check learner and model for various values of all parameters\n        when pruning parameters are not checked\n        \"\"\"\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_iris)\n        self.assertEqual(self.widget.selected_learner, [0])\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_2_titanic)\n        self.widget.selected_learner[:] = [1]\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.widget.selected_learner[:] = [0]\n\n    def _select_data(self):\n        self.widget.select_correct()\n        indices = self.widget.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        selected = [i for i, t in enumerate(zip(\n            self.widget.results.actual, self.widget.results.predicted[0]))\n                    if t in indices]\n        return self.widget.results.row_indices[selected]\n\n    def test_show_error_on_regression(self):\n        \"\"\"On regression data, the widget must show error\"\"\"\n        housing = Table(\"housing\")\n        results = TestOnTrainingData(store_data=True)(housing, [MeanLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.assertTrue(self.widget.Error.no_regression.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n        self.assertFalse(self.widget.Error.no_regression.is_shown())\n\n    def test_row_indices(self):\n        \"\"\"Map data instances when using random shuffling\"\"\"\n        results = ShuffleSplit(store_data=True\n                               )(self.iris, [NaiveBayesLearner()])\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n        self.widget.select_correct()\n        selected = self.get_output(self.widget.Outputs.selected_data)\n        # pylint: disable=unsubscriptable-object\n        correct = np.equal(results.actual, results.predicted)[0]\n        correct_indices = results.row_indices[correct]\n        self.assertSetEqual(set(self.iris[correct_indices].ids),\n                            set(selected.ids))\n\n    def test_empty_results(self):\n        \"\"\"Test on empty results.\"\"\"\n        res = Results(data=self.iris[:0], store_data=True)\n        res.row_indices = np.array([], dtype=int)\n        res.actual = np.array([])\n        res.predicted = np.array([[]])\n        res.probabilities = np.zeros((1, 0, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.widget.select_correct()\n        self.widget.select_wrong()\n\n    def test_nan_results(self):\n        \"\"\"Test on results with nan values in actual/predicted\"\"\"\n        res = Results(data=self.iris, nmethods=2, store_data=True)\n        res.row_indices = np.array([0, 50, 100], dtype=int)\n        res.actual = np.array([0., np.nan, 2.])\n        res.predicted = np.array([[np.nan, 1, 2],\n                                  [np.nan, np.nan, np.nan]])\n        res.probabilities = np.zeros((1, 3, 3))\n        self.send_signal(self.widget.Inputs.evaluation_results, res)\n        self.assertTrue(self.widget.Error.invalid_values.is_shown())\n        self.send_signal(self.widget.Inputs.evaluation_results, None)\n        self.assertFalse(self.widget.Error.invalid_values.is_shown())\n\n    def test_not_append_extra_meta_columns(self):\n        \"\"\"\n        When a user does not want append extra meta column, the widget\n        should not crash.\n        GH-2386\n        \"\"\"\n        self.widget.append_predictions = False\n        self.send_signal(self.widget.Inputs.evaluation_results, self.results_1_iris)\n\n    def test_unique_output_domain(self):\n        bayes = NaiveBayesLearner()\n        data = possible_duplicate_table('iris(Learner #1)')\n        input_data = CrossValidation(k=3, store_data=True)(data, [bayes])\n        self.send_signal(self.widget.Inputs.evaluation_results, input_data)\n        output = self.get_output(self.widget.Outputs.annotated_data)\n        self.assertEqual(output.domain.metas[0].name, 'iris(Learner #1) (1)')\n\n    def test_unique_var_names(self):\n        bayes = NaiveBayesLearner()\n        domain = self.iris.domain\n        results = CrossValidation(k=3, store_data=True)(self.iris, [bayes])\n        self.widget.append_probabilities = True\n        self.widget.append_predictions = True\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        out_data = self.get_output(self.widget.Outputs.annotated_data)\n\n        widget2 = self.create_widget(OWConfusionMatrix)\n        data2 = out_data.transform(\n            Domain(domain.attributes, domain.class_vars,\n                   [meta for meta in out_data.domain.metas if \"versicolor\" not in meta.name]))\n        results2 = CrossValidation(k=3, store_data=True)(data2, [bayes])\n        widget2.append_probabilities = True\n        widget2.append_predictions = True\n        self.send_signal(widget2.Inputs.evaluation_results, results2)\n        out_data2 = self.get_output(widget2.Outputs.annotated_data)\n        self.assertEqual({meta.name for meta in out_data2.domain.metas},\n                         {'Selected', 'Selected (1)',\n                          'iris(Learner #1)', 'iris(Learner #1) (1)',\n                          'p(Iris-setosa)', 'p(Iris-virginica)',\n                          'p(Iris-setosa) (1)', 'p(Iris-versicolor) (1)',\n                          'p(Iris-virginica) (1)'})\n\n    def test_sum_of_probabilities(self):\n        results: Results = self.results_1_iris\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n\n        model = self.widget.tablemodel\n        n = model.rowCount() - 3\n        matrix = np.zeros((n, n))\n        probabilities = results.probabilities[0]\n        for label_index in np.unique(results.actual).astype(int):\n            mask = results.actual == label_index\n            prob_sum = np.sum(probabilities[mask], axis=0)\n            matrix[label_index] = prob_sum\n        colsum = matrix.sum(axis=0)\n        rowsum = matrix.sum(axis=1)\n\n        simulate.combobox_activate_index(\n            self.widget.controls.selected_quantity, 3)\n        # matrix\n        for i in range(n):\n            for j in range(n):\n                value = model.data(model.index(i + 2, j + 2))\n                self.assertAlmostEqual(float(value), matrix[i, j], 1)\n        # rowsum\n        for i in range(n):\n            value = model.data(model.index(i + 2, n + 2))\n            self.assertAlmostEqual(float(value), rowsum[i], 0)\n        # colsum\n        for i in range(n):\n            value = model.data(model.index(n + 2, i + 2))\n            self.assertAlmostEqual(float(value), colsum[i], 0)\n        # total\n        value = model.data(model.index(n + 2, n + 2))\n        self.assertAlmostEqual(float(value), colsum.sum(), 0)\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n"
    ],
    "test_file_names": [
        "test_1.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Starting Orange installation attempts...\nAttempting installation with Python 3.7...\nrunning build_ext\nCompiling Orange/classification/_tree_scorers.pyx because it changed.\nCompiling Orange/data/_contingency.pyx because it changed.\nCompiling Orange/data/_io.pyx because it changed.\nCompiling Orange/data/_valuecount.pyx because it changed.\nCompiling Orange/data/_variable.pyx because it changed.\nCompiling Orange/distance/_distance.pyx because it changed.\nCompiling Orange/preprocess/_discretize.pyx because it changed.\nCompiling Orange/preprocess/_relieff.pyx because it changed.\nCompiling Orange/projection/_som.pyx because it changed.\n[1/9] Cythonizing Orange/classification/_tree_scorers.pyx\n[2/9] Cythonizing Orange/data/_contingency.pyx\n[3/9] Cythonizing Orange/data/_io.pyx\n[4/9] Cythonizing Orange/data/_valuecount.pyx\n[5/9] Cythonizing Orange/data/_variable.pyx\n[6/9] Cythonizing Orange/distance/_distance.pyx\n[7/9] Cythonizing Orange/preprocess/_discretize.pyx\n[8/9] Cythonizing Orange/preprocess/_relieff.pyx\n[9/9] Cythonizing Orange/projection/_som.pyx\nbuilding 'Orange.classification._tree_scorers' extension\ncreating build\ncreating build/temp.linux-x86_64-3.7\ncreating build/temp.linux-x86_64-3.7/Orange\ncreating build/temp.linux-x86_64-3.7/Orange/classification\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/classification/_tree_scorers.c -o build/temp.linux-x86_64-3.7/Orange/classification/_tree_scorers.o\ncreating build/lib.linux-x86_64-3.7\ncreating build/lib.linux-x86_64-3.7/Orange\ncreating build/lib.linux-x86_64-3.7/Orange/classification\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_tree_scorers.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._contingency' extension\ncreating build/temp.linux-x86_64-3.7/Orange/data\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_contingency.c -o build/temp.linux-x86_64-3.7/Orange/data/_contingency.o\ncreating build/lib.linux-x86_64-3.7/Orange/data\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_contingency.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._io' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_io.c -o build/temp.linux-x86_64-3.7/Orange/data/_io.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_io.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._valuecount' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_valuecount.c -o build/temp.linux-x86_64-3.7/Orange/data/_valuecount.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_valuecount.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._variable' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_variable.c -o build/temp.linux-x86_64-3.7/Orange/data/_variable.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_variable.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.distance._distance' extension\ncreating build/temp.linux-x86_64-3.7/Orange/distance\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/distance/_distance.c -o build/temp.linux-x86_64-3.7/Orange/distance/_distance.o\ncreating build/lib.linux-x86_64-3.7/Orange/distance\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/distance/_distance.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._discretize' extension\ncreating build/temp.linux-x86_64-3.7/Orange/preprocess\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/preprocess/_discretize.c -o build/temp.linux-x86_64-3.7/Orange/preprocess/_discretize.o\ncreating build/lib.linux-x86_64-3.7/Orange/preprocess\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_discretize.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._relieff' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/preprocess/_relieff.cpp -o build/temp.linux-x86_64-3.7/Orange/preprocess/_relieff.o\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_relieff.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.projection._som' extension\ncreating build/temp.linux-x86_64-3.7/Orange/projection\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/projection/_som.c -o build/temp.linux-x86_64-3.7/Orange/projection/_som.o\ncreating build/lib.linux-x86_64-3.7/Orange/projection\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/projection/_som.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.classification._simple_tree' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/classification/_simple_tree.c -o build/temp.linux-x86_64-3.7/Orange/classification/_simple_tree.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_simple_tree.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.widgets.utils._grid_density' extension\ncreating build/temp.linux-x86_64-3.7/Orange/widgets\ncreating build/temp.linux-x86_64-3.7/Orange/widgets/utils\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/widgets/utils/_grid_density.cpp -o build/temp.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.o\ncreating build/lib.linux-x86_64-3.7/Orange/widgets\ncreating build/lib.linux-x86_64-3.7/Orange/widgets/utils\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so -> Orange/distance\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so -> Orange/projection\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so -> Orange/widgets/utils\nrunning develop\nrunning egg_info\ncreating Orange3.egg-info\nwriting Orange3.egg-info/PKG-INFO\nwriting dependency_links to Orange3.egg-info/dependency_links.txt\nwriting entry points to Orange3.egg-info/entry_points.txt\nwriting requirements to Orange3.egg-info/requires.txt\nwriting top-level names to Orange3.egg-info/top_level.txt\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest template 'MANIFEST.in'\nadding license file 'LICENSE'\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nrunning build_ext\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so -> Orange/distance\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so -> Orange/projection\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so -> Orange/widgets/utils\nCreating /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/Orange3.egg-link (link to .)\nAdding Orange3 3.33.0.dev0+7ed8c4f to easy-install.pth file\nInstalling orange-canvas script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nInstalled /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31\nProcessing dependencies for Orange3==3.33.0.dev0+7ed8c4f\nSearching for XlsxWriter==3.2.0\nBest match: XlsxWriter 3.2.0\nAdding XlsxWriter 3.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for xlrd==2.0.1\nBest match: xlrd 2.0.1\nAdding xlrd 2.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for setuptools==59.8.0\nBest match: setuptools 59.8.0\nAdding setuptools 59.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for serverfiles==0.3.1\nBest match: serverfiles 0.3.1\nAdding serverfiles 0.3.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for scipy==1.7.3\nBest match: scipy 1.7.3\nAdding scipy 1.7.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for scikit-learn==1.0.2\nBest match: scikit-learn 1.0.2\nAdding scikit-learn 1.0.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for requests==2.31.0\nBest match: requests 2.31.0\nAdding requests 2.31.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for qtconsole==5.4.4\nBest match: qtconsole 5.4.4\nAdding qtconsole 5.4.4 to easy-install.pth file\nInstalling jupyter-qtconsole script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for PyYAML==6.0.1\nBest match: PyYAML 6.0.1\nAdding PyYAML 6.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for python-louvain==0.16\nBest match: python-louvain 0.16\nAdding python-louvain 0.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pyqtgraph==0.12.3\nBest match: pyqtgraph 0.12.3\nAdding pyqtgraph 0.12.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pygments==2.17.2\nBest match: pygments 2.17.2\nAdding pygments 2.17.2 to easy-install.pth file\nInstalling pygmentize script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pip==24.0\nBest match: pip 24.0\nAdding pip 24.0 to easy-install.pth file\nInstalling pip script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling pip3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling pip3.10 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pandas==1.3.5\nBest match: pandas 1.3.5\nAdding pandas 1.3.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for orange-widget-base==4.22.0\nBest match: orange-widget-base 4.22.0\nAdding orange-widget-base 4.22.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for orange-canvas-core==0.1.35\nBest match: orange-canvas-core 0.1.35\nAdding orange-canvas-core 0.1.35 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for openpyxl==3.1.3\nBest match: openpyxl 3.1.3\nAdding openpyxl 3.1.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for openTSNE==1.0.1\nBest match: openTSNE 1.0.1\nAdding openTSNE 1.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for numpy==1.17.5\nBest match: numpy 1.17.5\nAdding numpy 1.17.5 to easy-install.pth file\nInstalling f2py script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling f2py3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling f2py3.7 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for networkx==2.6.3\nBest match: networkx 2.6.3\nAdding networkx 2.6.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for matplotlib==3.5.3\nBest match: matplotlib 3.5.3\nAdding matplotlib 3.5.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for keyrings.alt==4.2.0\nBest match: keyrings.alt 4.2.0\nAdding keyrings.alt 4.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for keyring==24.1.1\nBest match: keyring 24.1.1\nAdding keyring 24.1.1 to easy-install.pth file\nInstalling keyring script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for joblib==1.3.2\nBest match: joblib 1.3.2\nAdding joblib 1.3.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for httpx==0.24.1\nBest match: httpx 0.24.1\nAdding httpx 0.24.1 to easy-install.pth file\nInstalling httpx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for chardet==5.2.0\nBest match: chardet 5.2.0\nAdding chardet 5.2.0 to easy-install.pth file\nInstalling chardetect script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for Bottleneck==1.4.0\nBest match: Bottleneck 1.4.0\nAdding Bottleneck 1.4.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for baycomp==1.0.3\nBest match: baycomp 1.0.3\nAdding baycomp 1.0.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for PyQtWebEngine==5.15.6\nBest match: PyQtWebEngine 5.15.6\nAdding PyQtWebEngine 5.15.6 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for PyQt5==5.15.10\nBest match: PyQt5 5.15.10\nAdding PyQt5 5.15.10 to easy-install.pth file\nInstalling pylupdate5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling pyrcc5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling pyuic5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for AnyQt==0.2.0\nBest match: AnyQt 0.2.0\nAdding AnyQt 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for threadpoolctl==3.1.0\nBest match: threadpoolctl 3.1.0\nAdding threadpoolctl 3.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for urllib3==2.0.7\nBest match: urllib3 2.0.7\nAdding urllib3 2.0.7 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for charset-normalizer==3.4.1\nBest match: charset-normalizer 3.4.1\nAdding charset-normalizer 3.4.1 to easy-install.pth file\nInstalling normalizer script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for certifi==2024.12.14\nBest match: certifi 2024.12.14\nAdding certifi 2024.12.14 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for idna==3.10\nBest match: idna 3.10\nAdding idna 3.10 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for packaging==24.0\nBest match: packaging 24.0\nAdding packaging 24.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for jupyter-core==4.12.0\nBest match: jupyter-core 4.12.0\nAdding jupyter-core 4.12.0 to easy-install.pth file\nInstalling jupyter script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling jupyter-migrate script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling jupyter-troubleshoot script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for ipython-genutils==0.2.0\nBest match: ipython-genutils 0.2.0\nAdding ipython-genutils 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for traitlets==5.9.0\nBest match: traitlets 5.9.0\nAdding traitlets 5.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pyzmq==26.2.0\nBest match: pyzmq 26.2.0\nAdding pyzmq 26.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for ipykernel==6.16.2\nBest match: ipykernel 6.16.2\nAdding ipykernel 6.16.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for jupyter-client==7.4.9\nBest match: jupyter-client 7.4.9\nAdding jupyter-client 7.4.9 to easy-install.pth file\nInstalling jupyter-kernel script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling jupyter-kernelspec script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling jupyter-run script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for QtPy==2.4.2\nBest match: QtPy 2.4.2\nAdding QtPy 2.4.2 to easy-install.pth file\nInstalling qtpy script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pytz==2024.2\nBest match: pytz 2024.2\nAdding pytz 2024.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for python-dateutil==2.9.0.post0\nBest match: python-dateutil 2.9.0.post0\nAdding python-dateutil 2.9.0.post0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for typing-extensions==4.7.1\nBest match: typing-extensions 4.7.1\nAdding typing-extensions 4.7.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for qasync==0.25.0\nBest match: qasync 0.25.0\nAdding qasync 0.25.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for commonmark==0.9.1\nBest match: commonmark 0.9.1\nAdding commonmark 0.9.1 to easy-install.pth file\nInstalling cmark script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for requests-cache==1.1.1\nBest match: requests-cache 1.1.1\nAdding requests-cache 1.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for docutils==0.20.1\nBest match: docutils 0.20.1\nAdding docutils 0.20.1 to easy-install.pth file\nInstalling docutils script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for dictdiffer==0.9.0\nBest match: dictdiffer 0.9.0\nAdding dictdiffer 0.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for importlib-metadata==6.7.0\nBest match: importlib-metadata 6.7.0\nAdding importlib-metadata 6.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for et-xmlfile==1.1.0\nBest match: et-xmlfile 1.1.0\nAdding et-xmlfile 1.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for kiwisolver==1.4.5\nBest match: kiwisolver 1.4.5\nAdding kiwisolver 1.4.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pyparsing==3.1.4\nBest match: pyparsing 3.1.4\nAdding pyparsing 3.1.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for cycler==0.11.0\nBest match: cycler 0.11.0\nAdding cycler 0.11.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for fonttools==4.38.0\nBest match: fonttools 4.38.0\nAdding fonttools 4.38.0 to easy-install.pth file\nInstalling fonttools script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling pyftmerge script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling pyftsubset script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling ttx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for Pillow==9.5.0\nBest match: Pillow 9.5.0\nAdding Pillow 9.5.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for jaraco.classes==3.2.3\nBest match: jaraco.classes 3.2.3\nAdding jaraco.classes 3.2.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for SecretStorage==3.3.3\nBest match: SecretStorage 3.3.3\nAdding SecretStorage 3.3.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for jeepney==0.8.0\nBest match: jeepney 0.8.0\nAdding jeepney 0.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for importlib-resources==5.12.0\nBest match: importlib-resources 5.12.0\nAdding importlib-resources 5.12.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for sniffio==1.3.1\nBest match: sniffio 1.3.1\nAdding sniffio 1.3.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for httpcore==0.17.3\nBest match: httpcore 0.17.3\nAdding httpcore 0.17.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for PyQt5-sip==12.13.0\nBest match: PyQt5-sip 12.13.0\nAdding PyQt5-sip 12.13.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for PyQtWebEngine-Qt5==5.15.16\nBest match: PyQtWebEngine-Qt5 5.15.16\nAdding PyQtWebEngine-Qt5 5.15.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for PyQt5-Qt5==5.15.16\nBest match: PyQt5-Qt5 5.15.16\nAdding PyQt5-Qt5 5.15.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for debugpy==1.7.0\nBest match: debugpy 1.7.0\nAdding debugpy 1.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for tornado==6.2\nBest match: tornado 6.2\nAdding tornado 6.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for ipython==7.34.0\nBest match: ipython 7.34.0\nAdding ipython 7.34.0 to easy-install.pth file\nInstalling iptest script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling iptest3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling ipython script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\nInstalling ipython3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for nest-asyncio==1.6.0\nBest match: nest-asyncio 1.6.0\nAdding nest-asyncio 1.6.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for matplotlib-inline==0.1.6\nBest match: matplotlib-inline 0.1.6\nAdding matplotlib-inline 0.1.6 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for psutil==6.1.1\nBest match: psutil 6.1.1\nAdding psutil 6.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for entrypoints==0.4\nBest match: entrypoints 0.4\nAdding entrypoints 0.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for six==1.17.0\nBest match: six 1.17.0\nAdding six 1.17.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for cattrs==23.1.2\nBest match: cattrs 23.1.2\nAdding cattrs 23.1.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for platformdirs==4.0.0\nBest match: platformdirs 4.0.0\nAdding platformdirs 4.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for attrs==24.2.0\nBest match: attrs 24.2.0\nAdding attrs 24.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for url-normalize==1.4.3\nBest match: url-normalize 1.4.3\nAdding url-normalize 1.4.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for zipp==3.15.0\nBest match: zipp 3.15.0\nAdding zipp 3.15.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for more-itertools==9.1.0\nBest match: more-itertools 9.1.0\nAdding more-itertools 9.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for cryptography==44.0.0\nBest match: cryptography 44.0.0\nAdding cryptography 44.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for h11==0.14.0\nBest match: h11 0.14.0\nAdding h11 0.14.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for anyio==3.7.1\nBest match: anyio 3.7.1\nAdding anyio 3.7.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for jedi==0.19.2\nBest match: jedi 0.19.2\nAdding jedi 0.19.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pexpect==4.9.0\nBest match: pexpect 4.9.0\nAdding pexpect 4.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for prompt-toolkit==3.0.48\nBest match: prompt-toolkit 3.0.48\nAdding prompt-toolkit 3.0.48 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for backcall==0.2.0\nBest match: backcall 0.2.0\nAdding backcall 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pickleshare==0.7.5\nBest match: pickleshare 0.7.5\nAdding pickleshare 0.7.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for decorator==5.1.1\nBest match: decorator 5.1.1\nAdding decorator 5.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for exceptiongroup==1.2.2\nBest match: exceptiongroup 1.2.2\nAdding exceptiongroup 1.2.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for cffi==1.15.1\nBest match: cffi 1.15.1\nAdding cffi 1.15.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for parso==0.8.4\nBest match: parso 0.8.4\nAdding parso 0.8.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for ptyprocess==0.7.0\nBest match: ptyprocess 0.7.0\nAdding ptyprocess 0.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for wcwidth==0.2.13\nBest match: wcwidth 0.2.13\nAdding wcwidth 0.2.13 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nSearching for pycparser==2.21\nBest match: pycparser 2.21\nAdding pycparser 2.21 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages\nFinished processing dependencies for Orange3==3.33.0.dev0+7ed8c4f\nVerifying Orange installation...\n✅ Orange installation successful!\nSuccessfully installed orange using Python 3.7\n",
    "setup_res_stderr": "Using CPython 3.7.9\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 18 packages in 85ms\nPrepared 18 packages in 2ms\nInstalled 18 packages in 160ms\n + cython==0.29.37\n + exceptiongroup==1.2.2\n + importlib-metadata==6.7.0\n + iniconfig==2.0.0\n + numpy==1.17.5\n + packaging==24.0\n + pluggy==1.2.0\n + pyqt5==5.15.10\n + pyqt5-qt5==5.15.16\n + pyqt5-sip==12.13.0\n + pyqtwebengine==5.15.6\n + pyqtwebengine-qt5==5.15.16\n + pytest==7.4.4\n + setuptools==59.8.0\n + tomli==2.0.1\n + typing-extensions==4.7.1\n + wheel==0.42.0\n + zipp==3.15.0\nResolved 54 packages in 530ms\nInstalled 47 packages in 873ms\n + anyio==3.7.1\n + baycomp==1.0.3\n + bottleneck==1.4.0\n + certifi==2024.12.14\n + cffi==1.15.1\n + chardet==5.2.0\n + charset-normalizer==3.4.1\n + cryptography==44.0.0\n + cycler==0.11.0\n + et-xmlfile==1.1.0\n + fonttools==4.38.0\n + h11==0.14.0\n + httpcore==0.17.3\n + httpx==0.24.1\n + idna==3.10\n + importlib-resources==5.12.0\n + jaraco-classes==3.2.3\n + jeepney==0.8.0\n + joblib==1.3.2\n + keyring==24.1.1\n + keyrings-alt==4.2.0\n + kiwisolver==1.4.5\n + matplotlib==3.5.3\n + more-itertools==9.1.0\n + networkx==2.6.3\n + openpyxl==3.1.3\n + opentsne==1.0.1\n + pandas==1.3.5\n + pillow==9.5.0\n + pip==24.0\n + pycparser==2.21\n + pyparsing==3.1.4\n + python-dateutil==2.9.0.post0\n + python-louvain==0.16\n + pytz==2024.2\n + pyyaml==6.0.1\n + requests==2.31.0\n + scikit-learn==1.0.2\n + scipy==1.7.3\n + secretstorage==3.3.3\n + serverfiles==0.3.1\n + six==1.17.0\n + sniffio==1.3.1\n + threadpoolctl==3.1.0\n + urllib3==2.0.7\n + xlrd==2.0.1\n + xlsxwriter==3.2.0\nResolved 59 packages in 370ms\nInstalled 38 packages in 361ms\n + anyqt==0.2.0\n + attrs==24.2.0\n + backcall==0.2.0\n + cattrs==23.1.2\n + commonmark==0.9.1\n + debugpy==1.7.0\n + decorator==5.1.1\n + dictdiffer==0.9.0\n + docutils==0.20.1\n + entrypoints==0.4\n + ipykernel==6.16.2\n + ipython==7.34.0\n + ipython-genutils==0.2.0\n + jedi==0.19.2\n + jupyter-client==7.4.9\n + jupyter-core==4.12.0\n + matplotlib-inline==0.1.6\n + nest-asyncio==1.6.0\n + orange-canvas-core==0.1.35\n + orange-widget-base==4.22.0\n + parso==0.8.4\n + pexpect==4.9.0\n + pickleshare==0.7.5\n + platformdirs==4.0.0\n + prompt-toolkit==3.0.48\n + psutil==6.1.1\n + ptyprocess==0.7.0\n + pygments==2.17.2\n + pyqtgraph==0.12.3\n + pyzmq==26.2.0\n + qasync==0.25.0\n + qtconsole==5.4.4\n + qtpy==2.4.2\n + requests-cache==1.1.1\n + tornado==6.2\n + traitlets==5.9.0\n + url-normalize==1.4.3\n + wcwidth==0.2.13\nResolved 2 packages in 3ms\nInstalled 2 packages in 5ms\n + psycopg2==2.9.9\n + pymssql==2.3.2\nResolved 19 packages in 24ms\nInstalled 5 packages in 1.21s\n + catboost==1.2.7\n + graphviz==0.20.1\n + plotly==5.18.0\n + tenacity==8.2.3\n + xgboost==1.6.2\nAudited 2 packages in 1ms\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/classification/_tree_scorers.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_2find_threshold_entropy’:\nOrange/classification/_tree_scorers.c:3427:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 3427 |   __pyx_t_7 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_6find_threshold_MSE’:\nOrange/classification/_tree_scorers.c:4883:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 4883 |   __pyx_t_1 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_8find_binarization_MSE’:\nOrange/classification/_tree_scorers.c:5629:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5629 |           for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {\n      |                                           ^\nOrange/classification/_tree_scorers.c:5750:39: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5750 |           __pyx_t_20 = ((__pyx_v_left >= __pyx_v_min_leaf) != 0);\n      |                                       ^~\nOrange/classification/_tree_scorers.c:5756:53: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5756 |           __pyx_t_20 = (((__pyx_v_N - __pyx_v_left) >= __pyx_v_min_leaf) != 0);\n      |                                                     ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_14compute_predictions_csr’:\nOrange/classification/_tree_scorers.c:7217:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7217 |         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_16compute_predictions_csc’:\nOrange/classification/_tree_scorers.c:7874:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7874 |         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c:7934:150: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int32_t’ {aka ‘int’} and ‘unsigned int’ [-Wsign-compare]\n 7934 |               __pyx_t_16 = (((*((__pyx_t_5numpy_int32_t const  *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_15 * __pyx_v_indices.strides[0]) ))) != __pyx_v_i) != 0);\n      |                                                                                                                                                      ^~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_contingency.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/data/_io.c: In function ‘__pyx_pf_6Orange_4data_3_io_sparse_read_float.constprop’:\nOrange/data/_io.c:4120:43: warning: ‘__pyx_v_decs’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4120 |           __pyx_v_value = ((__pyx_v_value * __pyx_v_decs) + (__pyx_v_c & 0xf));\n      |                            ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/data/_io.c:4318:24: warning: ‘__pyx_v_value’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4318 |           __pyx_t_10 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 223, __pyx_L5_error)\n      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:683:40: warning: ‘__pyx_v_attr_index’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n  683 |   #define PyInt_FromLong               PyLong_FromLong\n      |                                        ^~~~~~~~~~~~~~~\nOrange/data/_io.c:1590:7: note: ‘__pyx_v_attr_index’ was declared here\n 1590 |   int __pyx_v_attr_index;\n      |       ^~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:3183:25: warning: ‘__pyx_v_atomp’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3183 |           __pyx_v_atomp = (__pyx_v_atomp + 1);\n      |           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_valuecount.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/distance/_distance.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_discretize.c:774:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_relieff.cpp:790:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/projection/_som.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_5update_hex’:\nOrange/projection/_som.c:3863:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3863 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:3862:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3862 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_8update_sparse.constprop’:\nOrange/projection/_som.c:4934:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4934 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4933:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4933 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_7get_winners_sparse’:\nOrange/projection/_som.c:4732:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4732 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4307:7: note: ‘__pyx_v_win_y’ was declared here\n 4307 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4721:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4721 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4306:7: note: ‘__pyx_v_win_x’ was declared here\n 4306 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_10update_sparse_hex.constprop’:\nOrange/projection/_som.c:5682:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5682 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:5681:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5681 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_1get_winners’:\nOrange/projection/_som.c:3184:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3184 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2887:7: note: ‘__pyx_v_win_y’ was declared here\n 2887 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:3173:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3173 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2886:7: note: ‘__pyx_v_win_x’ was declared here\n 2886 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_3update’:\nOrange/projection/_som.c:3357:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3357 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/classification/_simple_tree.c: In function ‘gain_ratio_c’:\nOrange/classification/_simple_tree.c:63:9: warning: implicit declaration of function ‘qsort_r’; did you mean ‘qsort’? [-Wimplicit-function-declaration]\n   63 |         qsort_r(base, nel, size, compar, thunk)\n      |         ^~~~~~~\nOrange/classification/_simple_tree.c:147:9: note: in expansion of macro ‘QSORT_R_FUNC’\n  147 |         QSORT_R_FUNC(examples, size, sizeof(struct Example), (void*) &compar_attr, compar_examples);\n      |         ^~~~~~~~~~~~\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/setuptools/command/easy_install.py:159: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.\n  EasyInstallDeprecationWarning,\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31/.venv/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.\n  setuptools.SetuptoolsDeprecationWarning,\nwarning: no files found matching 'README*' under directory 'Orange'\nwarning: no files found matching 'LICENSE' under directory 'Orange'\nwarning: no files found matching '*.basket' under directory 'Orange/datasets'\nwarning: no files found matching '*.svg' under directory 'Orange/canvas'\nwarning: no files found matching '*.js' under directory 'Orange/widgets'\nwarning: no files found matching '*.css' under directory 'Orange/widgets'\nwarning: no files found matching '*.html' under directory 'Orange/widgets'\nwarning: no files found matching '*.svg' under directory 'distribute'\nwarning: no files found matching 'COPYING'\n",
    "new_commit_res_code": 1,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31\nplugins: anyio-3.7.1\ncollected 16 items\n\nr2e_tests/test_1.py sss..F..........                                     [100%]\n\n=================================== FAILURES ===================================\n___________________ TestOWConfusionMatrix.test_minimum_size ____________________\n\nself = <r2e_tests.test_1.TestOWConfusionMatrix testMethod=test_minimum_size>\n\n    def test_minimum_size(self):\n        widget = getattr(self, \"widget\", None)\n        if widget is None:\n            self.skipTest(\"minimum size not tested as .widget was not set\")\n>       self.check_minimum_size(widget)\n\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:242: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:615: in check_minimum_size\n    self.assertLess(min_size.width(), 800)\nE   AssertionError: 1307 not less than 800\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_empty_results\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_image_export\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_msg_base_class\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_nan_results\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_not_append_extra_meta_columns\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_outputs\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_row_indices\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_selected_learner\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_show_error_on_regression\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_sum_of_probabilities\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_unique_output_domain\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_unique_var_names\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:244: image exporting not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:238: minimum size not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:250: msg base class not tested as .widget was not set\nFAILED r2e_tests/test_1.py::TestOWConfusionMatrix::test_minimum_size - Assert...\n=================== 1 failed, 12 passed, 3 skipped in 5.80s ====================\nWidgets left: 0    Max widgets: 1316 \n\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7ed8c4f21f672008a8f0c0b9bafc00b368b36e31\nplugins: anyio-3.7.1\ncollected 16 items\n\nr2e_tests/test_1.py sss..F.......F..                                     [100%]\n\n=================================== FAILURES ===================================\n___________________ TestOWConfusionMatrix.test_minimum_size ____________________\n\nself = <r2e_tests.test_1.TestOWConfusionMatrix testMethod=test_minimum_size>\n\n    def test_minimum_size(self):\n        widget = getattr(self, \"widget\", None)\n        if widget is None:\n            self.skipTest(\"minimum size not tested as .widget was not set\")\n>       self.check_minimum_size(widget)\n\n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:242: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n.venv/lib/python3.7/site-packages/orangewidget/tests/base.py:615: in check_minimum_size\n    self.assertLess(min_size.width(), 800)\nE   AssertionError: 1307 not less than 800\n_______________ TestOWConfusionMatrix.test_sum_of_probabilities ________________\n\nself = <r2e_tests.test_1.TestOWConfusionMatrix testMethod=test_sum_of_probabilities>\n\n    def test_sum_of_probabilities(self):\n        results: Results = self.results_1_iris\n        self.send_signal(self.widget.Inputs.evaluation_results, results)\n    \n        model = self.widget.tablemodel\n        n = model.rowCount() - 3\n        matrix = np.zeros((n, n))\n        probabilities = results.probabilities[0]\n        for label_index in np.unique(results.actual).astype(int):\n            mask = results.actual == label_index\n            prob_sum = np.sum(probabilities[mask], axis=0)\n            matrix[label_index] = prob_sum\n        colsum = matrix.sum(axis=0)\n        rowsum = matrix.sum(axis=1)\n    \n        simulate.combobox_activate_index(\n>           self.widget.controls.selected_quantity, 3)\n\nr2e_tests/test_1.py:172: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\ncbox = <orangewidget.utils.combobox.ComboBox object at 0x7c00ade73870>\nindex = 3, delay = -1\n\n    @staticmethod\n    def combobox_activate_index(cbox, index, delay=-1):\n        \"\"\"\n        Activate an item at `index` in a given combo box.\n    \n        The item at index **must** be enabled and selectable.\n    \n        Parameters\n        ----------\n        cbox : QComboBox\n        index : int\n        delay : int\n            Run the event loop after the signals are emitted for `delay`\n            milliseconds (-1, the default, means no delay).\n        \"\"\"\n>       assert 0 <= index < cbox.count()\nE       AssertionError\n\n.venv/lib/python3.7/site-packages/orangewidget/tests/utils.py:224: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_empty_results\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_image_export\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_msg_base_class\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_nan_results\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_not_append_extra_meta_columns\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_outputs\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_row_indices\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_selected_learner\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_show_error_on_regression\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_unique_output_domain\nPASSED r2e_tests/test_1.py::TestOWConfusionMatrix::test_unique_var_names\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:244: image exporting not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:238: minimum size not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:250: msg base class not tested as .widget was not set\nFAILED r2e_tests/test_1.py::TestOWConfusionMatrix::test_minimum_size - Assert...\nFAILED r2e_tests/test_1.py::TestOWConfusionMatrix::test_sum_of_probabilities\n=================== 2 failed, 11 passed, 3 skipped in 3.25s ====================\nWidgets left: 0    Max widgets: 1316 \n\n",
    "old_commit_res_stderr": ""
}
Orange/widgets/evaluate/owconfusionmatrix.py Orange/widgets/evaluate/tests/test_owconfusionmatrix.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** Confusion Matrix Widget Fails to Maintain Minimum Size When Displaying Sum of Probabilities

**Description:**
After adding the "Sum of probabilities" option to the Confusion Matrix widget, selecting this option causes the widget to not adhere to its expected minimum size. This results in layout issues where certain elements may be cut off or not displayed properly.

**Example Code:**
When the "Sum of probabilities" is selected, the widget attempts to display additional information without adjusting its minimum size accordingly.

```python
widget = OWConfusionMatrix()
widget.selected_quantity = "Sum of probabilities"
# The widget does not resize to accommodate the new display elements
```

**Expected Behavior:**
The Confusion Matrix widget should automatically adjust its minimum size to accommodate the additional "Sum of probabilities" information, ensuring all elements are fully visible and properly laid out.

**Actual Behavior:**
Selecting "Sum of probabilities" does not trigger an adjustment of the widget's minimum size, leading to incomplete or improperly displayed elements within the widget.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/widgets/evaluate/owconfusionmatrix.py
"""Confusion matrix widget"""

from math import isnan, isinf
from itertools import chain
import unicodedata

from AnyQt.QtWidgets import QTableView, QHeaderView, QStyledItemDelegate, \
    QSizePolicy
from AnyQt.QtGui import QFont, QBrush, QColor, QStandardItemModel, QStandardItem
from AnyQt.QtCore import Qt, QSize, QItemSelectionModel, QItemSelection
import numpy as np
import sklearn.metrics as skl_metrics

import Orange
from Orange.data.util import get_unique_names
import Orange.evaluation
from Orange.widgets import widget, gui
from Orange.widgets.settings import \
    Setting, ContextSetting, ClassValuesContextHandler
from Orange.widgets.utils.annotated_data import (create_annotated_table,
                                                 ANNOTATED_DATA_SIGNAL_NAME)
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.widget import Msg, Input, Output


def confusion_matrix(res, index):
    """
    Compute confusion matrix

    Args:
        res (Orange.evaluation.Results): evaluation results
        index (int): model index

    Returns: Confusion matrix
    """
    labels = np.arange(len(res.domain.class_var.values))
    if not res.actual.size:
        # scikit-learn will not return an zero matrix
        return np.zeros((len(labels), len(labels)))
    else:
        return skl_metrics.confusion_matrix(
            res.actual, res.predicted[index], labels=labels)


BorderRole = next(gui.OrangeUserRole)
BorderColorRole = next(gui.OrangeUserRole)


class BorderedItemDelegate(QStyledItemDelegate):
    """Item delegate that paints border at the specified sides

    Data for `BorderRole` is a string containing letters t, r, b and/or l,
    which defines the sides at which the border is drawn.

    Role `BorderColorRole` sets the color for the cell. If not color is given,
    `self.color` is used as default.

    Args:
        color (QColor): default color (default default is black)
    """
    def __init__(self, color=Qt.black):
        super().__init__()
        self.color = color

    def paint(self, painter, option, index):
        """Overloads `paint` to draw borders"""
        QStyledItemDelegate.paint(self, painter, option, index)
        borders = index.data(BorderRole)
        if borders:
            color = index.data(BorderColorRole) or self.color
            painter.save()
            painter.setPen(color)
            rect = option.rect
            for side, p1, p2 in (("t", rect.topLeft(), rect.topRight()),
                                 ("r", rect.topRight(), rect.bottomRight()),
                                 ("b", rect.bottomLeft(), rect.bottomRight()),
                                 ("l", rect.topLeft(), rect.bottomLeft())):
                if side in borders:
                    painter.drawLine(p1, p2)
            painter.restore()


class OWConfusionMatrix(widget.OWWidget):
    """Confusion matrix widget"""

    name = "Confusion Matrix"
    description = "Display a confusion matrix constructed from " \
                  "the results of classifier evaluations."
    icon = "icons/ConfusionMatrix.svg"
    priority = 1001
    keywords = []

    class Inputs:
        evaluation_results = Input("Evaluation Results", Orange.evaluation.Results)

    class Outputs:
        selected_data = Output("Selected Data", Orange.data.Table, default=True)
        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)

    quantities = ["Number of instances",
                  "Proportion of predicted",
                  "Proportion of actual"]

    settings_version = 1
    settingsHandler = ClassValuesContextHandler()

    selected_learner = Setting([0], schema_only=True)
    selection = ContextSetting(set())
    selected_quantity = Setting(0)
    append_predictions = Setting(True)
    append_probabilities = Setting(False)
    autocommit = Setting(True)

    UserAdviceMessages = [
        widget.Message(
            "Clicking on cells or in headers outputs the corresponding "
            "data instances",
            "click_cell")]

    class Error(widget.OWWidget.Error):
        no_regression = Msg("Confusion Matrix cannot show regression results.")
        invalid_values = Msg("Evaluation Results input contains invalid values")
        empty_input = widget.Msg("Empty result on input. Nothing to display.")

    def __init__(self):
        super().__init__()

        self.data = None
        self.results = None
        self.learners = []
        self.headers = []

        self.learners_box = gui.listBox(
            self.controlArea, self, "selected_learner", "learners", box='Learners',
            callback=self._learner_changed
        )

        self.outputbox = gui.vBox(self.buttonsArea)
        box = gui.vBox(self.outputbox, box="Output")
        gui.checkBox(box, self, "append_predictions",
                     "Predictions", callback=self._invalidate)
        gui.checkBox(box, self, "append_probabilities",
                     "Probabilities",
                     callback=self._invalidate)

        gui.auto_apply(self.outputbox, self, "autocommit", box=False)

        box = gui.vBox(self.mainArea, box=True)

        sbox = gui.hBox(box)
        gui.rubber(sbox)
        gui.comboBox(sbox, self, "selected_quantity",
                     items=self.quantities, label="Show: ",
                     orientation=Qt.Horizontal, callback=self._update)

        self.tablemodel = QStandardItemModel(self)
        view = self.tableview = QTableView(
            editTriggers=QTableView.NoEditTriggers)
        view.setModel(self.tablemodel)
        view.horizontalHeader().hide()
        view.verticalHeader().hide()
        view.horizontalHeader().setMinimumSectionSize(60)
        view.selectionModel().selectionChanged.connect(self._invalidate)
        view.setShowGrid(False)
        view.setItemDelegate(BorderedItemDelegate(Qt.white))
        view.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.MinimumExpanding)
        view.clicked.connect(self.cell_clicked)
        box.layout().addWidget(view)

        selbox = gui.hBox(box)
        gui.button(selbox, self, "Select Correct",
                   callback=self.select_correct, autoDefault=False)
        gui.button(selbox, self, "Select Misclassified",
                   callback=self.select_wrong, autoDefault=False)
        gui.button(selbox, self, "Clear Selection",
                   callback=self.select_none, autoDefault=False)

    @staticmethod
    def sizeHint():
        """Initial size"""
        return QSize(750, 340)

    def _item(self, i, j):
        return self.tablemodel.item(i, j) or QStandardItem()

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

    def _init_table(self, nclasses):
        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, nclasses)
        self.tableview.setSpan(2, 0, nclasses, 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.setSectionResizeMode(QHeaderView.ResizeToContents)
        else:
            hor_header.setDefaultSectionSize(60)
        self.tablemodel.setRowCount(nclasses + 3)
        self.tablemodel.setColumnCount(nclasses + 3)

    @Inputs.evaluation_results
    def set_results(self, results):
        """Set the input results."""
        # false positive, pylint: disable=no-member
        prev_sel_learner = self.selected_learner.copy()
        self.clear()
        self.warning()
        self.closeContext()

        data = None
        if results is not None and results.data is not None:
            data = results.data[results.row_indices]

        self.Error.no_regression.clear()
        self.Error.empty_input.clear()
        if data is not None and not data.domain.has_discrete_class:
            self.Error.no_regression()
            data = results = None
        elif results is not None and not results.actual.size:
            self.Error.empty_input()
            data = results = None

        nan_values = False
        if results is not None:
            assert isinstance(results, Orange.evaluation.Results)
            if np.any(np.isnan(results.actual)) or \
                    np.any(np.isnan(results.predicted)):
                # Error out here (could filter them out with a warning
                # instead).
                nan_values = True
                results = data = None

        self.Error.invalid_values(shown=nan_values)

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

        self.report_button.setDisabled(False)

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

        # NOTE: The 'learner_names' is set in 'Test Learners' widget.
        self.learners = getattr(
            results, "learner_names",
            [f"Learner #{i + 1}" for i in range(nmodels)])

        self._init_table(len(class_values))
        self.openContext(data.domain.class_var)
        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):
            if self.learners:
                self.selected_learner[:] = [0]
        else:
            self.selected_learner[:] = prev_sel_learner
        self._update()
        self._set_selection()
        self.commit.now()

    def clear(self):
        """Reset the widget, clear controls"""
        self.results = None
        self.data = None
        self.tablemodel.clear()
        self.headers = []
        # Clear learners last. This action will invoke `_learner_changed`
        self.learners = []

    def select_correct(self):
        """Select the diagonal elements of the matrix"""
        selection = QItemSelection()
        n = self.tablemodel.rowCount()
        for i in range(2, n):
            index = self.tablemodel.index(i, i)
            selection.select(index, index)
        self.tableview.selectionModel().select(
            selection, QItemSelectionModel.ClearAndSelect)

    def select_wrong(self):
        """Select the off-diagonal elements of the matrix"""
        selection = QItemSelection()
        n = self.tablemodel.rowCount()
        for i in range(2, n):
            for j in range(i + 1, n):
                index = self.tablemodel.index(i, j)
                selection.select(index, index)
                index = self.tablemodel.index(j, i)
                selection.select(index, index)
        self.tableview.selectionModel().select(
            selection, QItemSelectionModel.ClearAndSelect)

    def select_none(self):
        """Reset selection"""
        self.tableview.selectionModel().clear()

    def cell_clicked(self, model_index):
        """Handle cell click event"""
        i, j = model_index.row(), model_index.column()
        if not i or not j:
            return
        n = self.tablemodel.rowCount()
        index = self.tablemodel.index
        selection = None
        if i == j == 1 or i == j == n - 1:
            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))
        elif i in (1, n - 1):
            selection = QItemSelection(index(2, j), index(n - 1, j))
        elif j in (1, n - 1):
            selection = QItemSelection(index(i, 2), index(i, n - 1))

        if selection is not None:
            self.tableview.selectionModel().select(
                selection, QItemSelectionModel.ClearAndSelect)

    def _prepare_data(self):
        indices = self.tableview.selectedIndexes()
        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}
        actual = self.results.actual
        learner_name = self.learners[self.selected_learner[0]]
        predicted = self.results.predicted[self.selected_learner[0]]
        selected = [i for i, t in enumerate(zip(actual, predicted))
                    if t in indices]

        extra = []
        class_var = self.data.domain.class_var
        metas = self.data.domain.metas
        attrs = self.data.domain.attributes
        names = [var.name for var in chain(metas, [class_var], attrs)]

        if self.append_predictions:
            extra.append(predicted.reshape(-1, 1))
            proposed = "{}({})".format(class_var.name, learner_name)
            name = get_unique_names(names, proposed)
            var = Orange.data.DiscreteVariable(
                                               name,
                                               class_var.values)
            metas = metas + (var,)

        if self.append_probabilities and \
                        self.results.probabilities is not None:
            probs = self.results.probabilities[self.selected_learner[0]]
            extra.append(np.array(probs, dtype=object))
            names = [f"p({value})" for value in class_var.values]
            names = get_unique_names(self.data.domain, names)
            metas += tuple(map(Orange.data.ContinuousVariable, names))

        domain = Orange.data.Domain(self.data.domain.attributes,
                                    self.data.domain.class_vars,
                                    metas)
        data = self.data.transform(domain)
        if extra:
            with data.unlocked(data.metas):
                data.metas[:, len(self.data.domain.metas):] = \
                    np.hstack(tuple(extra))
        data.name = learner_name

        if selected:
            annotated_data = create_annotated_table(data, selected)
            data = data[selected]
        else:
            annotated_data = create_annotated_table(data, [])
            data = None

        return data, annotated_data

    @gui.deferred
    def commit(self):
        """Output data instances corresponding to selected cells"""
        if self.results is not None and self.data is not None \
                and self.selected_learner:
            data, annotated_data = self._prepare_data()
        else:
            data = None
            annotated_data = None

        self.Outputs.selected_data.send(data)
        self.Outputs.annotated_data.send(annotated_data)

    def _invalidate(self):
        indices = self.tableview.selectedIndexes()
        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}
        self.commit.deferred()

    def _set_selection(self):
        selection = QItemSelection()
        index = self.tableview.model().index
        for row, col in self.selection:
            sel = index(row + 2, col + 2)
            selection.select(sel, sel)
        self.tableview.selectionModel().select(
            selection, QItemSelectionModel.ClearAndSelect)

    def _learner_changed(self):
        self._update()
        self._set_selection()
        self.commit.deferred()

    def _update(self):
        def _isinvalid(x):
            return isnan(x) or isinf(x)

        # Update the displayed confusion matrix
        if self.results is not None and self.selected_learner:
            cmatrix = confusion_matrix(self.results, self.selected_learner[0])
            colsum = cmatrix.sum(axis=0)
            rowsum = cmatrix.sum(axis=1)
            n = len(cmatrix)
            diag = np.diag_indices(n)

            colors = cmatrix.astype(np.double)
            colors[diag] = 0
            if self.selected_quantity == 0:
                normalized = cmatrix.astype(int)
                formatstr = "{}"
                div = np.array([colors.max()])
            else:
                if self.selected_quantity == 1:
                    normalized = 100 * cmatrix / colsum
                    div = colors.max(axis=0)
                else:
                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]
                    div = colors.max(axis=1)[:, np.newaxis]
                formatstr = "{:2.1f} %"
            div[div == 0] = 1
            colors /= div
            maxval = normalized[diag].max()
            if maxval > 0:
                colors[diag] = normalized[diag] / maxval

            for i in range(n):
                for j in range(n):
                    val = normalized[i, j]
                    col_val = colors[i, j]
                    item = self._item(i + 2, j + 2)
                    item.setData(
                        "NA" if _isinvalid(val) else formatstr.format(val),
                        Qt.DisplayRole)
                    bkcolor = QColor.fromHsl(
                        [0, 240][i == j], 160,
                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))
                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)
                    # bkcolor is light-ish so use a black text
                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)
                    item.setData("trbl", BorderRole)
                    item.setToolTip("actual: {}\npredicted: {}".format(
                        self.headers[i], self.headers[j]))
                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
                    self._set_item(i + 2, j + 2, item)

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

            def _sum_item(value, border=""):
                item = QStandardItem()
                item.setData(value, Qt.DisplayRole)
                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
                item.setFlags(Qt.ItemIsEnabled)
                item.setFont(bold_font)
                item.setData(border, BorderRole)
                item.setData(QColor(192, 192, 192), BorderColorRole)
                return item

            for i in range(n):
                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), "t"))
                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), "l"))
            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))

    def send_report(self):
        """Send report"""
        if self.results is not None and self.selected_learner:
            self.report_table(
                "Confusion matrix for {} (showing {})".
                format(self.learners[self.selected_learner[0]],
                       self.quantities[self.selected_quantity].lower()),
                self.tableview)

    @classmethod
    def migrate_settings(cls, settings, version):
        if not version:
            # For some period of time the 'selected_learner' property was
            # changed from List[int] -> int
            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back
            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)
            if "selected_learner" in settings and \
                    isinstance(settings["selected_learner"], int):
                settings["selected_learner"] = [settings["selected_learner"]]


if __name__ == "__main__":  # pragma: no cover
    from Orange.widgets.evaluate.utils import results_for_preview
    WidgetPreview(OWConfusionMatrix).run(results_for_preview("iris"))

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
**Title:** Confusion Matrix Widget Fails to Maintain Minimum Size When Displaying Sum of Probabilities

**Description:**
After adding the "Sum of probabilities" option to the Confusion Matrix widget, selecting this option causes the widget to not adhere to its expected minimum size. This results in layout issues where certain elements may be cut off or not displayed properly.

**Example Code:**
When the "Sum of probabilities" is selected, the widget attempts to display additional information without adjusting its minimum size accordingly.

```python
widget = OWConfusionMatrix()
widget.selected_quantity = "Sum of probabilities"
# The widget does not resize to accommodate the new display elements
```

**Expected Behavior:**
The Confusion Matrix widget should automatically adjust its minimum size to accommodate the additional "Sum of probabilities" information, ensuring all elements are fully visible and properly laid out.

**Actual Behavior:**
Selecting "Sum of probabilities" does not trigger an adjustment of the widget's minimum size, leading to incomplete or improperly displayed elements within the widget.

[/ISSUE]
{
    "TestOWConfusionMatrix.test_empty_results": "PASSED",
    "TestOWConfusionMatrix.test_image_export": "PASSED",
    "TestOWConfusionMatrix.test_msg_base_class": "PASSED",
    "TestOWConfusionMatrix.test_nan_results": "PASSED",
    "TestOWConfusionMatrix.test_not_append_extra_meta_columns": "PASSED",
    "TestOWConfusionMatrix.test_outputs": "PASSED",
    "TestOWConfusionMatrix.test_row_indices": "PASSED",
    "TestOWConfusionMatrix.test_selected_learner": "PASSED",
    "TestOWConfusionMatrix.test_show_error_on_regression": "PASSED",
    "TestOWConfusionMatrix.test_sum_of_probabilities": "PASSED",
    "TestOWConfusionMatrix.test_unique_output_domain": "PASSED",
    "TestOWConfusionMatrix.test_unique_var_names": "PASSED",
    "TestOWConfusionMatrix.test_minimum_size": "FAILED"
}
diff --git a/Orange/widgets/evaluate/owconfusionmatrix.py b/Orange/widgets/evaluate/owconfusionmatrix.py
index 3f28eb3ea..8716ee812 100644
--- a/Orange/widgets/evaluate/owconfusionmatrix.py
+++ b/Orange/widgets/evaluate/owconfusionmatrix.py
@@ -99,7 +99,13 @@ class OWConfusionMatrix(widget.OWWidget):
 
     quantities = ["Number of instances",
                   "Proportion of predicted",
-                  "Proportion of actual"]
+                  "Proportion of actual",
+                  "Sum of probabilities"]
+    qu_tooltips = ["Number of correctly and incorrectly classified instances",
+                   "Proportion of predicted",
+                   "Proportion of actual",
+                   "Number of instances, distributed across columns "
+                   "according to predicted probabilities"]
 
     settings_version = 1
     settingsHandler = ClassValuesContextHandler()
@@ -149,8 +155,8 @@ class OWConfusionMatrix(widget.OWWidget):
 
         sbox = gui.hBox(box)
         gui.rubber(sbox)
-        gui.comboBox(sbox, self, "selected_quantity",
-                     items=self.quantities, label="Show: ",
+        gui.comboBox(sbox, self, "selected_quantity", label="Show: ",
+                     items=self.quantities, tooltips=self.qu_tooltips,
                      orientation=Qt.Horizontal, callback=self._update)
 
         self.tablemodel = QStandardItemModel(self)
@@ -445,9 +451,22 @@ class OWConfusionMatrix(widget.OWWidget):
 
         # Update the displayed confusion matrix
         if self.results is not None and self.selected_learner:
-            cmatrix = confusion_matrix(self.results, self.selected_learner[0])
-            colsum = cmatrix.sum(axis=0)
-            rowsum = cmatrix.sum(axis=1)
+            learner_index = self.selected_learner[0]
+            if self.selected_quantity != 3:
+                cmatrix = confusion_matrix(self.results, learner_index)
+                colsum = cmatrix.sum(axis=0)
+                rowsum = cmatrix.sum(axis=1)
+
+            else:
+                probabilities = self.results.probabilities[learner_index]
+                n = probabilities.shape[1]
+                cmatrix = np.zeros((n, n), dtype=float)
+                for index in np.unique(self.results.actual).astype(int):
+                    mask = self.results.actual == index
+                    cmatrix[index] = np.sum(probabilities[mask], axis=0)
+                colsum = cmatrix.sum(axis=0)
+                rowsum = cmatrix.sum(axis=1)
+
             n = len(cmatrix)
             diag = np.diag_indices(n)
 
@@ -457,14 +476,18 @@ class OWConfusionMatrix(widget.OWWidget):
                 normalized = cmatrix.astype(int)
                 formatstr = "{}"
                 div = np.array([colors.max()])
-            else:
-                if self.selected_quantity == 1:
-                    normalized = 100 * cmatrix / colsum
-                    div = colors.max(axis=0)
-                else:
-                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]
-                    div = colors.max(axis=1)[:, np.newaxis]
+            elif self.selected_quantity == 1:
+                normalized = 100 * cmatrix / colsum
+                div = colors.max(axis=0)
+                formatstr = "{:2.1f} %"
+            elif self.selected_quantity == 2:
+                normalized = 100 * cmatrix / rowsum[:, np.newaxis]
+                div = colors.max(axis=1)[:, np.newaxis]
                 formatstr = "{:2.1f} %"
+            elif self.selected_quantity == 3:
+                normalized = cmatrix
+                formatstr = "{:2.1f}"
+                div = np.array([colors.max()])
             div[div == 0] = 1
             colors /= div
             maxval = normalized[diag].max()
@@ -496,6 +519,7 @@ class OWConfusionMatrix(widget.OWWidget):
             bold_font.setBold(True)
 
             def _sum_item(value, border=""):
+                value = int(round(value))
                 item = QStandardItem()
                 item.setData(value, Qt.DisplayRole)
                 item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
@@ -506,9 +530,9 @@ class OWConfusionMatrix(widget.OWWidget):
                 return item
 
             for i in range(n):
-                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), "t"))
-                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), "l"))
-            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))
+                self._set_item(n + 2, i + 2, _sum_item(colsum[i], "t"))
+                self._set_item(i + 2, n + 2, _sum_item(rowsum[i], "l"))
+            self._set_item(n + 2, n + 2, _sum_item(rowsum.sum()))
 
     def send_report(self):
         """Send report"""

{"Orange/widgets/evaluate/owconfusionmatrix.py": "\"\"\"Confusion matrix widget\"\"\"\n\nfrom math import isnan, isinf\nfrom itertools import chain\nimport unicodedata\n\nfrom AnyQt.QtWidgets import QTableView, QHeaderView, QStyledItemDelegate, \\\n    QSizePolicy\nfrom AnyQt.QtGui import QFont, QBrush, QColor, QStandardItemModel, QStandardItem\nfrom AnyQt.QtCore import Qt, QSize, QItemSelectionModel, QItemSelection\nimport numpy as np\nimport sklearn.metrics as skl_metrics\n\nimport Orange\nfrom Orange.data.util import get_unique_names\nimport Orange.evaluation\nfrom Orange.widgets import widget, gui\nfrom Orange.widgets.settings import \\\n    Setting, ContextSetting, ClassValuesContextHandler\nfrom Orange.widgets.utils.annotated_data import (create_annotated_table,\n                                                 ANNOTATED_DATA_SIGNAL_NAME)\nfrom Orange.widgets.utils.widgetpreview import WidgetPreview\nfrom Orange.widgets.widget import Msg, Input, Output\n\n\ndef confusion_matrix(res, index):\n    \"\"\"\n    Compute confusion matrix\n\n    Args:\n        res (Orange.evaluation.Results): evaluation results\n        index (int): model index\n\n    Returns: Confusion matrix\n    \"\"\"\n    labels = np.arange(len(res.domain.class_var.values))\n    if not res.actual.size:\n        # scikit-learn will not return an zero matrix\n        return np.zeros((len(labels), len(labels)))\n    else:\n        return skl_metrics.confusion_matrix(\n            res.actual, res.predicted[index], labels=labels)\n\n\nBorderRole = next(gui.OrangeUserRole)\nBorderColorRole = next(gui.OrangeUserRole)\n\n\nclass BorderedItemDelegate(QStyledItemDelegate):\n    \"\"\"Item delegate that paints border at the specified sides\n\n    Data for `BorderRole` is a string containing letters t, r, b and/or l,\n    which defines the sides at which the border is drawn.\n\n    Role `BorderColorRole` sets the color for the cell. If not color is given,\n    `self.color` is used as default.\n\n    Args:\n        color (QColor): default color (default default is black)\n    \"\"\"\n    def __init__(self, color=Qt.black):\n        super().__init__()\n        self.color = color\n\n    def paint(self, painter, option, index):\n        \"\"\"Overloads `paint` to draw borders\"\"\"\n        QStyledItemDelegate.paint(self, painter, option, index)\n        borders = index.data(BorderRole)\n        if borders:\n            color = index.data(BorderColorRole) or self.color\n            painter.save()\n            painter.setPen(color)\n            rect = option.rect\n            for side, p1, p2 in ((\"t\", rect.topLeft(), rect.topRight()),\n                                 (\"r\", rect.topRight(), rect.bottomRight()),\n                                 (\"b\", rect.bottomLeft(), rect.bottomRight()),\n                                 (\"l\", rect.topLeft(), rect.bottomLeft())):\n                if side in borders:\n                    painter.drawLine(p1, p2)\n            painter.restore()\n\n\nclass OWConfusionMatrix(widget.OWWidget):\n    \"\"\"Confusion matrix widget\"\"\"\n\n    name = \"Confusion Matrix\"\n    description = \"Display a confusion matrix constructed from \" \\\n                  \"the results of classifier evaluations.\"\n    icon = \"icons/ConfusionMatrix.svg\"\n    priority = 1001\n    keywords = []\n\n    class Inputs:\n        evaluation_results = Input(\"Evaluation Results\", Orange.evaluation.Results)\n\n    class Outputs:\n        selected_data = Output(\"Selected Data\", Orange.data.Table, default=True)\n        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)\n\n    quantities = [\"Number of instances\",\n                  \"Proportion of predicted\",\n                  \"Proportion of actual\"]\n\n    settings_version = 1\n    settingsHandler = ClassValuesContextHandler()\n\n    selected_learner = Setting([0], schema_only=True)\n    selection = ContextSetting(set())\n    selected_quantity = Setting(0)\n    append_predictions = Setting(True)\n    append_probabilities = Setting(False)\n    autocommit = Setting(True)\n\n    UserAdviceMessages = [\n        widget.Message(\n            \"Clicking on cells or in headers outputs the corresponding \"\n            \"data instances\",\n            \"click_cell\")]\n\n    class Error(widget.OWWidget.Error):\n        no_regression = Msg(\"Confusion Matrix cannot show regression results.\")\n        invalid_values = Msg(\"Evaluation Results input contains invalid values\")\n        empty_input = widget.Msg(\"Empty result on input. Nothing to display.\")\n\n    def __init__(self):\n        super().__init__()\n\n        self.data = None\n        self.results = None\n        self.learners = []\n        self.headers = []\n\n        self.learners_box = gui.listBox(\n            self.controlArea, self, \"selected_learner\", \"learners\", box='Learners',\n            callback=self._learner_changed\n        )\n\n        self.outputbox = gui.vBox(self.buttonsArea)\n        box = gui.vBox(self.outputbox, box=\"Output\")\n        gui.checkBox(box, self, \"append_predictions\",\n                     \"Predictions\", callback=self._invalidate)\n        gui.checkBox(box, self, \"append_probabilities\",\n                     \"Probabilities\",\n                     callback=self._invalidate)\n\n        gui.auto_apply(self.outputbox, self, \"autocommit\", box=False)\n\n        box = gui.vBox(self.mainArea, box=True)\n\n        sbox = gui.hBox(box)\n        gui.rubber(sbox)\n        gui.comboBox(sbox, self, \"selected_quantity\",\n                     items=self.quantities, label=\"Show: \",\n                     orientation=Qt.Horizontal, callback=self._update)\n\n        self.tablemodel = QStandardItemModel(self)\n        view = self.tableview = QTableView(\n            editTriggers=QTableView.NoEditTriggers)\n        view.setModel(self.tablemodel)\n        view.horizontalHeader().hide()\n        view.verticalHeader().hide()\n        view.horizontalHeader().setMinimumSectionSize(60)\n        view.selectionModel().selectionChanged.connect(self._invalidate)\n        view.setShowGrid(False)\n        view.setItemDelegate(BorderedItemDelegate(Qt.white))\n        view.setSizePolicy(QSizePolicy.MinimumExpanding,\n                           QSizePolicy.MinimumExpanding)\n        view.clicked.connect(self.cell_clicked)\n        box.layout().addWidget(view)\n\n        selbox = gui.hBox(box)\n        gui.button(selbox, self, \"Select Correct\",\n                   callback=self.select_correct, autoDefault=False)\n        gui.button(selbox, self, \"Select Misclassified\",\n                   callback=self.select_wrong, autoDefault=False)\n        gui.button(selbox, self, \"Clear Selection\",\n                   callback=self.select_none, autoDefault=False)\n\n    @staticmethod\n    def sizeHint():\n        \"\"\"Initial size\"\"\"\n        return QSize(750, 340)\n\n    def _item(self, i, j):\n        return self.tablemodel.item(i, j) or QStandardItem()\n\n    def _set_item(self, i, j, item):\n        self.tablemodel.setItem(i, j, item)\n\n    def _init_table(self, nclasses):\n        item = self._item(0, 2)\n        item.setData(\"Predicted\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignCenter)\n        item.setFlags(Qt.NoItemFlags)\n\n        self._set_item(0, 2, item)\n        item = self._item(2, 0)\n        item.setData(\"Actual\", Qt.DisplayRole)\n        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignBottom)\n        item.setFlags(Qt.NoItemFlags)\n        self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())\n        self._set_item(2, 0, item)\n        self.tableview.setSpan(0, 2, 1, nclasses)\n        self.tableview.setSpan(2, 0, nclasses, 1)\n\n        font = self.tablemodel.invisibleRootItem().font()\n        bold_font = QFont(font)\n        bold_font.setBold(True)\n\n        for i in (0, 1):\n            for j in (0, 1):\n                item = self._item(i, j)\n                item.setFlags(Qt.NoItemFlags)\n                self._set_item(i, j, item)\n\n        for p, label in enumerate(self.headers):\n            for i, j in ((1, p + 2), (p + 2, 1)):\n                item = self._item(i, j)\n                item.setData(label, Qt.DisplayRole)\n                item.setFont(bold_font)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                if p < len(self.headers) - 1:\n                    item.setData(\"br\"[j == 1], BorderRole)\n                    item.setData(QColor(192, 192, 192), BorderColorRole)\n                self._set_item(i, j, item)\n\n        hor_header = self.tableview.horizontalHeader()\n        if len(' '.join(self.headers)) < 120:\n            hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)\n        else:\n            hor_header.setDefaultSectionSize(60)\n        self.tablemodel.setRowCount(nclasses + 3)\n        self.tablemodel.setColumnCount(nclasses + 3)\n\n    @Inputs.evaluation_results\n    def set_results(self, results):\n        \"\"\"Set the input results.\"\"\"\n        # false positive, pylint: disable=no-member\n        prev_sel_learner = self.selected_learner.copy()\n        self.clear()\n        self.warning()\n        self.closeContext()\n\n        data = None\n        if results is not None and results.data is not None:\n            data = results.data[results.row_indices]\n\n        self.Error.no_regression.clear()\n        self.Error.empty_input.clear()\n        if data is not None and not data.domain.has_discrete_class:\n            self.Error.no_regression()\n            data = results = None\n        elif results is not None and not results.actual.size:\n            self.Error.empty_input()\n            data = results = None\n\n        nan_values = False\n        if results is not None:\n            assert isinstance(results, Orange.evaluation.Results)\n            if np.any(np.isnan(results.actual)) or \\\n                    np.any(np.isnan(results.predicted)):\n                # Error out here (could filter them out with a warning\n                # instead).\n                nan_values = True\n                results = data = None\n\n        self.Error.invalid_values(shown=nan_values)\n\n        self.results = results\n        self.data = data\n\n        if data is not None:\n            class_values = data.domain.class_var.values\n        elif results is not None:\n            raise NotImplementedError\n\n        if results is None:\n            self.report_button.setDisabled(True)\n            return\n\n        self.report_button.setDisabled(False)\n\n        nmodels = results.predicted.shape[0]\n        self.headers = class_values + \\\n                       (unicodedata.lookup(\"N-ARY SUMMATION\"), )\n\n        # NOTE: The 'learner_names' is set in 'Test Learners' widget.\n        self.learners = getattr(\n            results, \"learner_names\",\n            [f\"Learner #{i + 1}\" for i in range(nmodels)])\n\n        self._init_table(len(class_values))\n        self.openContext(data.domain.class_var)\n        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):\n            if self.learners:\n                self.selected_learner[:] = [0]\n        else:\n            self.selected_learner[:] = prev_sel_learner\n        self._update()\n        self._set_selection()\n        self.commit.now()\n\n    def clear(self):\n        \"\"\"Reset the widget, clear controls\"\"\"\n        self.results = None\n        self.data = None\n        self.tablemodel.clear()\n        self.headers = []\n        # Clear learners last. This action will invoke `_learner_changed`\n        self.learners = []\n\n    def select_correct(self):\n        \"\"\"Select the diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            index = self.tablemodel.index(i, i)\n            selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_wrong(self):\n        \"\"\"Select the off-diagonal elements of the matrix\"\"\"\n        selection = QItemSelection()\n        n = self.tablemodel.rowCount()\n        for i in range(2, n):\n            for j in range(i + 1, n):\n                index = self.tablemodel.index(i, j)\n                selection.select(index, index)\n                index = self.tablemodel.index(j, i)\n                selection.select(index, index)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def select_none(self):\n        \"\"\"Reset selection\"\"\"\n        self.tableview.selectionModel().clear()\n\n    def cell_clicked(self, model_index):\n        \"\"\"Handle cell click event\"\"\"\n        i, j = model_index.row(), model_index.column()\n        if not i or not j:\n            return\n        n = self.tablemodel.rowCount()\n        index = self.tablemodel.index\n        selection = None\n        if i == j == 1 or i == j == n - 1:\n            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))\n        elif i in (1, n - 1):\n            selection = QItemSelection(index(2, j), index(n - 1, j))\n        elif j in (1, n - 1):\n            selection = QItemSelection(index(i, 2), index(i, n - 1))\n\n        if selection is not None:\n            self.tableview.selectionModel().select(\n                selection, QItemSelectionModel.ClearAndSelect)\n\n    def _prepare_data(self):\n        indices = self.tableview.selectedIndexes()\n        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        actual = self.results.actual\n        learner_name = self.learners[self.selected_learner[0]]\n        predicted = self.results.predicted[self.selected_learner[0]]\n        selected = [i for i, t in enumerate(zip(actual, predicted))\n                    if t in indices]\n\n        extra = []\n        class_var = self.data.domain.class_var\n        metas = self.data.domain.metas\n        attrs = self.data.domain.attributes\n        names = [var.name for var in chain(metas, [class_var], attrs)]\n\n        if self.append_predictions:\n            extra.append(predicted.reshape(-1, 1))\n            proposed = \"{}({})\".format(class_var.name, learner_name)\n            name = get_unique_names(names, proposed)\n            var = Orange.data.DiscreteVariable(\n                                               name,\n                                               class_var.values)\n            metas = metas + (var,)\n\n        if self.append_probabilities and \\\n                        self.results.probabilities is not None:\n            probs = self.results.probabilities[self.selected_learner[0]]\n            extra.append(np.array(probs, dtype=object))\n            names = [f\"p({value})\" for value in class_var.values]\n            names = get_unique_names(self.data.domain, names)\n            metas += tuple(map(Orange.data.ContinuousVariable, names))\n\n        domain = Orange.data.Domain(self.data.domain.attributes,\n                                    self.data.domain.class_vars,\n                                    metas)\n        data = self.data.transform(domain)\n        if extra:\n            with data.unlocked(data.metas):\n                data.metas[:, len(self.data.domain.metas):] = \\\n                    np.hstack(tuple(extra))\n        data.name = learner_name\n\n        if selected:\n            annotated_data = create_annotated_table(data, selected)\n            data = data[selected]\n        else:\n            annotated_data = create_annotated_table(data, [])\n            data = None\n\n        return data, annotated_data\n\n    @gui.deferred\n    def commit(self):\n        \"\"\"Output data instances corresponding to selected cells\"\"\"\n        if self.results is not None and self.data is not None \\\n                and self.selected_learner:\n            data, annotated_data = self._prepare_data()\n        else:\n            data = None\n            annotated_data = None\n\n        self.Outputs.selected_data.send(data)\n        self.Outputs.annotated_data.send(annotated_data)\n\n    def _invalidate(self):\n        indices = self.tableview.selectedIndexes()\n        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}\n        self.commit.deferred()\n\n    def _set_selection(self):\n        selection = QItemSelection()\n        index = self.tableview.model().index\n        for row, col in self.selection:\n            sel = index(row + 2, col + 2)\n            selection.select(sel, sel)\n        self.tableview.selectionModel().select(\n            selection, QItemSelectionModel.ClearAndSelect)\n\n    def _learner_changed(self):\n        self._update()\n        self._set_selection()\n        self.commit.deferred()\n\n    def _update(self):\n        def _isinvalid(x):\n            return isnan(x) or isinf(x)\n\n        # Update the displayed confusion matrix\n        if self.results is not None and self.selected_learner:\n            cmatrix = confusion_matrix(self.results, self.selected_learner[0])\n            colsum = cmatrix.sum(axis=0)\n            rowsum = cmatrix.sum(axis=1)\n            n = len(cmatrix)\n            diag = np.diag_indices(n)\n\n            colors = cmatrix.astype(np.double)\n            colors[diag] = 0\n            if self.selected_quantity == 0:\n                normalized = cmatrix.astype(int)\n                formatstr = \"{}\"\n                div = np.array([colors.max()])\n            else:\n                if self.selected_quantity == 1:\n                    normalized = 100 * cmatrix / colsum\n                    div = colors.max(axis=0)\n                else:\n                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]\n                    div = colors.max(axis=1)[:, np.newaxis]\n                formatstr = \"{:2.1f} %\"\n            div[div == 0] = 1\n            colors /= div\n            maxval = normalized[diag].max()\n            if maxval > 0:\n                colors[diag] = normalized[diag] / maxval\n\n            for i in range(n):\n                for j in range(n):\n                    val = normalized[i, j]\n                    col_val = colors[i, j]\n                    item = self._item(i + 2, j + 2)\n                    item.setData(\n                        \"NA\" if _isinvalid(val) else formatstr.format(val),\n                        Qt.DisplayRole)\n                    bkcolor = QColor.fromHsl(\n                        [0, 240][i == j], 160,\n                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))\n                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)\n                    # bkcolor is light-ish so use a black text\n                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)\n                    item.setData(\"trbl\", BorderRole)\n                    item.setToolTip(\"actual: {}\\npredicted: {}\".format(\n                        self.headers[i], self.headers[j]))\n                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)\n                    self._set_item(i + 2, j + 2, item)\n\n            bold_font = self.tablemodel.invisibleRootItem().font()\n            bold_font.setBold(True)\n\n            def _sum_item(value, border=\"\"):\n                item = QStandardItem()\n                item.setData(value, Qt.DisplayRole)\n                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)\n                item.setFlags(Qt.ItemIsEnabled)\n                item.setFont(bold_font)\n                item.setData(border, BorderRole)\n                item.setData(QColor(192, 192, 192), BorderColorRole)\n                return item\n\n            for i in range(n):\n                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), \"t\"))\n                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), \"l\"))\n            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))\n\n    def send_report(self):\n        \"\"\"Send report\"\"\"\n        if self.results is not None and self.selected_learner:\n            self.report_table(\n                \"Confusion matrix for {} (showing {})\".\n                format(self.learners[self.selected_learner[0]],\n                       self.quantities[self.selected_quantity].lower()),\n                self.tableview)\n\n    @classmethod\n    def migrate_settings(cls, settings, version):\n        if not version:\n            # For some period of time the 'selected_learner' property was\n            # changed from List[int] -> int\n            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back\n            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)\n            if \"selected_learner\" in settings and \\\n                    isinstance(settings[\"selected_learner\"], int):\n                settings[\"selected_learner\"] = [settings[\"selected_learner\"]]\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    from Orange.widgets.evaluate.utils import results_for_preview\n    WidgetPreview(OWConfusionMatrix).run(results_for_preview(\"iris\"))\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** Confusion Matrix Widget Fails to Maintain Minimum Size When Displaying Sum of Probabilities

**Description:**
After adding the "Sum of probabilities" option to the Confusion Matrix widget, selecting this option causes the widget to not adhere to its expected minimum size. This results in layout issues where certain elements may be cut off or not displayed properly.

**Example Code:**
When the "Sum of probabilities" is selected, the widget attempts to display additional information without adjusting its minimum size accordingly.

```python
widget = OWConfusionMatrix()
widget.selected_quantity = "Sum of probabilities"
# The widget does not resize to accommodate the new display elements
```

**Expected Behavior:**
The Confusion Matrix widget should automatically adjust its minimum size to accommodate the additional "Sum of probabilities" information, ensuring all elements are fully visible and properly laid out.

**Actual Behavior:**
Selecting "Sum of probabilities" does not trigger an adjustment of the widget's minimum size, leading to incomplete or improperly displayed elements within the widget.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/widgets/evaluate/owconfusionmatrix.py
"""Confusion matrix widget"""

from math import isnan, isinf
from itertools import chain
import unicodedata

from AnyQt.QtWidgets import QTableView, QHeaderView, QStyledItemDelegate, \
    QSizePolicy
from AnyQt.QtGui import QFont, QBrush, QColor, QStandardItemModel, QStandardItem
from AnyQt.QtCore import Qt, QSize, QItemSelectionModel, QItemSelection
import numpy as np
import sklearn.metrics as skl_metrics

import Orange
from Orange.data.util import get_unique_names
import Orange.evaluation
from Orange.widgets import widget, gui
from Orange.widgets.settings import \
    Setting, ContextSetting, ClassValuesContextHandler
from Orange.widgets.utils.annotated_data import (create_annotated_table,
                                                 ANNOTATED_DATA_SIGNAL_NAME)
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.widget import Msg, Input, Output


def confusion_matrix(res, index):
    """
    Compute confusion matrix

    Args:
        res (Orange.evaluation.Results): evaluation results
        index (int): model index

    Returns: Confusion matrix
    """
    labels = np.arange(len(res.domain.class_var.values))
    if not res.actual.size:
        # scikit-learn will not return an zero matrix
        return np.zeros((len(labels), len(labels)))
    else:
        return skl_metrics.confusion_matrix(
            res.actual, res.predicted[index], labels=labels)


BorderRole = next(gui.OrangeUserRole)
BorderColorRole = next(gui.OrangeUserRole)


class BorderedItemDelegate(QStyledItemDelegate):
    """Item delegate that paints border at the specified sides

    Data for `BorderRole` is a string containing letters t, r, b and/or l,
    which defines the sides at which the border is drawn.

    Role `BorderColorRole` sets the color for the cell. If not color is given,
    `self.color` is used as default.

    Args:
        color (QColor): default color (default default is black)
    """
    def __init__(self, color=Qt.black):
        super().__init__()
        self.color = color

    def paint(self, painter, option, index):
        """Overloads `paint` to draw borders"""
        QStyledItemDelegate.paint(self, painter, option, index)
        borders = index.data(BorderRole)
        if borders:
            color = index.data(BorderColorRole) or self.color
            painter.save()
            painter.setPen(color)
            rect = option.rect
            for side, p1, p2 in (("t", rect.topLeft(), rect.topRight()),
                                 ("r", rect.topRight(), rect.bottomRight()),
                                 ("b", rect.bottomLeft(), rect.bottomRight()),
                                 ("l", rect.topLeft(), rect.bottomLeft())):
                if side in borders:
                    painter.drawLine(p1, p2)
            painter.restore()


class OWConfusionMatrix(widget.OWWidget):
    """Confusion matrix widget"""

    name = "Confusion Matrix"
    description = "Display a confusion matrix constructed from " \
                  "the results of classifier evaluations."
    icon = "icons/ConfusionMatrix.svg"
    priority = 1001
    keywords = []

    class Inputs:
        evaluation_results = Input("Evaluation Results", Orange.evaluation.Results)

    class Outputs:
        selected_data = Output("Selected Data", Orange.data.Table, default=True)
        annotated_data = Output(ANNOTATED_DATA_SIGNAL_NAME, Orange.data.Table)

    quantities = ["Number of instances",
                  "Proportion of predicted",
                  "Proportion of actual"]

    settings_version = 1
    settingsHandler = ClassValuesContextHandler()

    selected_learner = Setting([0], schema_only=True)
    selection = ContextSetting(set())
    selected_quantity = Setting(0)
    append_predictions = Setting(True)
    append_probabilities = Setting(False)
    autocommit = Setting(True)

    UserAdviceMessages = [
        widget.Message(
            "Clicking on cells or in headers outputs the corresponding "
            "data instances",
            "click_cell")]

    class Error(widget.OWWidget.Error):
        no_regression = Msg("Confusion Matrix cannot show regression results.")
        invalid_values = Msg("Evaluation Results input contains invalid values")
        empty_input = widget.Msg("Empty result on input. Nothing to display.")

    def __init__(self):
        super().__init__()

        self.data = None
        self.results = None
        self.learners = []
        self.headers = []

        self.learners_box = gui.listBox(
            self.controlArea, self, "selected_learner", "learners", box='Learners',
            callback=self._learner_changed
        )

        self.outputbox = gui.vBox(self.buttonsArea)
        box = gui.vBox(self.outputbox, box="Output")
        gui.checkBox(box, self, "append_predictions",
                     "Predictions", callback=self._invalidate)
        gui.checkBox(box, self, "append_probabilities",
                     "Probabilities",
                     callback=self._invalidate)

        gui.auto_apply(self.outputbox, self, "autocommit", box=False)

        box = gui.vBox(self.mainArea, box=True)

        sbox = gui.hBox(box)
        gui.rubber(sbox)
        gui.comboBox(sbox, self, "selected_quantity",
                     items=self.quantities, label="Show: ",
                     orientation=Qt.Horizontal, callback=self._update)

        self.tablemodel = QStandardItemModel(self)
        view = self.tableview = QTableView(
            editTriggers=QTableView.NoEditTriggers)
        view.setModel(self.tablemodel)
        view.horizontalHeader().hide()
        view.verticalHeader().hide()
        view.horizontalHeader().setMinimumSectionSize(60)
        view.selectionModel().selectionChanged.connect(self._invalidate)
        view.setShowGrid(False)
        view.setItemDelegate(BorderedItemDelegate(Qt.white))
        view.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.MinimumExpanding)
        view.clicked.connect(self.cell_clicked)
        box.layout().addWidget(view)

        selbox = gui.hBox(box)
        gui.button(selbox, self, "Select Correct",
                   callback=self.select_correct, autoDefault=False)
        gui.button(selbox, self, "Select Misclassified",
                   callback=self.select_wrong, autoDefault=False)
        gui.button(selbox, self, "Clear Selection",
                   callback=self.select_none, autoDefault=False)

    @staticmethod
    def sizeHint():
        """Initial size"""
        return QSize(750, 340)

    def _item(self, i, j):
        return self.tablemodel.item(i, j) or QStandardItem()

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

    def _init_table(self, nclasses):
        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, nclasses)
        self.tableview.setSpan(2, 0, nclasses, 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.setSectionResizeMode(QHeaderView.ResizeToContents)
        else:
            hor_header.setDefaultSectionSize(60)
        self.tablemodel.setRowCount(nclasses + 3)
        self.tablemodel.setColumnCount(nclasses + 3)

    @Inputs.evaluation_results
    def set_results(self, results):
        """Set the input results."""
        # false positive, pylint: disable=no-member
        prev_sel_learner = self.selected_learner.copy()
        self.clear()
        self.warning()
        self.closeContext()

        data = None
        if results is not None and results.data is not None:
            data = results.data[results.row_indices]

        self.Error.no_regression.clear()
        self.Error.empty_input.clear()
        if data is not None and not data.domain.has_discrete_class:
            self.Error.no_regression()
            data = results = None
        elif results is not None and not results.actual.size:
            self.Error.empty_input()
            data = results = None

        nan_values = False
        if results is not None:
            assert isinstance(results, Orange.evaluation.Results)
            if np.any(np.isnan(results.actual)) or \
                    np.any(np.isnan(results.predicted)):
                # Error out here (could filter them out with a warning
                # instead).
                nan_values = True
                results = data = None

        self.Error.invalid_values(shown=nan_values)

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

        self.report_button.setDisabled(False)

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

        # NOTE: The 'learner_names' is set in 'Test Learners' widget.
        self.learners = getattr(
            results, "learner_names",
            [f"Learner #{i + 1}" for i in range(nmodels)])

        self._init_table(len(class_values))
        self.openContext(data.domain.class_var)
        if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):
            if self.learners:
                self.selected_learner[:] = [0]
        else:
            self.selected_learner[:] = prev_sel_learner
        self._update()
        self._set_selection()
        self.commit.now()

    def clear(self):
        """Reset the widget, clear controls"""
        self.results = None
        self.data = None
        self.tablemodel.clear()
        self.headers = []
        # Clear learners last. This action will invoke `_learner_changed`
        self.learners = []

    def select_correct(self):
        """Select the diagonal elements of the matrix"""
        selection = QItemSelection()
        n = self.tablemodel.rowCount()
        for i in range(2, n):
            index = self.tablemodel.index(i, i)
            selection.select(index, index)
        self.tableview.selectionModel().select(
            selection, QItemSelectionModel.ClearAndSelect)

    def select_wrong(self):
        """Select the off-diagonal elements of the matrix"""
        selection = QItemSelection()
        n = self.tablemodel.rowCount()
        for i in range(2, n):
            for j in range(i + 1, n):
                index = self.tablemodel.index(i, j)
                selection.select(index, index)
                index = self.tablemodel.index(j, i)
                selection.select(index, index)
        self.tableview.selectionModel().select(
            selection, QItemSelectionModel.ClearAndSelect)

    def select_none(self):
        """Reset selection"""
        self.tableview.selectionModel().clear()

    def cell_clicked(self, model_index):
        """Handle cell click event"""
        i, j = model_index.row(), model_index.column()
        if not i or not j:
            return
        n = self.tablemodel.rowCount()
        index = self.tablemodel.index
        selection = None
        if i == j == 1 or i == j == n - 1:
            selection = QItemSelection(index(2, 2), index(n - 1, n - 1))
        elif i in (1, n - 1):
            selection = QItemSelection(index(2, j), index(n - 1, j))
        elif j in (1, n - 1):
            selection = QItemSelection(index(i, 2), index(i, n - 1))

        if selection is not None:
            self.tableview.selectionModel().select(
                selection, QItemSelectionModel.ClearAndSelect)

    def _prepare_data(self):
        indices = self.tableview.selectedIndexes()
        indices = {(ind.row() - 2, ind.column() - 2) for ind in indices}
        actual = self.results.actual
        learner_name = self.learners[self.selected_learner[0]]
        predicted = self.results.predicted[self.selected_learner[0]]
        selected = [i for i, t in enumerate(zip(actual, predicted))
                    if t in indices]

        extra = []
        class_var = self.data.domain.class_var
        metas = self.data.domain.metas
        attrs = self.data.domain.attributes
        names = [var.name for var in chain(metas, [class_var], attrs)]

        if self.append_predictions:
            extra.append(predicted.reshape(-1, 1))
            proposed = "{}({})".format(class_var.name, learner_name)
            name = get_unique_names(names, proposed)
            var = Orange.data.DiscreteVariable(
                                               name,
                                               class_var.values)
            metas = metas + (var,)

        if self.append_probabilities and \
                        self.results.probabilities is not None:
            probs = self.results.probabilities[self.selected_learner[0]]
            extra.append(np.array(probs, dtype=object))
            names = [f"p({value})" for value in class_var.values]
            names = get_unique_names(self.data.domain, names)
            metas += tuple(map(Orange.data.ContinuousVariable, names))

        domain = Orange.data.Domain(self.data.domain.attributes,
                                    self.data.domain.class_vars,
                                    metas)
        data = self.data.transform(domain)
        if extra:
            with data.unlocked(data.metas):
                data.metas[:, len(self.data.domain.metas):] = \
                    np.hstack(tuple(extra))
        data.name = learner_name

        if selected:
            annotated_data = create_annotated_table(data, selected)
            data = data[selected]
        else:
            annotated_data = create_annotated_table(data, [])
            data = None

        return data, annotated_data

    @gui.deferred
    def commit(self):
        """Output data instances corresponding to selected cells"""
        if self.results is not None and self.data is not None \
                and self.selected_learner:
            data, annotated_data = self._prepare_data()
        else:
            data = None
            annotated_data = None

        self.Outputs.selected_data.send(data)
        self.Outputs.annotated_data.send(annotated_data)

    def _invalidate(self):
        indices = self.tableview.selectedIndexes()
        self.selection = {(ind.row() - 2, ind.column() - 2) for ind in indices}
        self.commit.deferred()

    def _set_selection(self):
        selection = QItemSelection()
        index = self.tableview.model().index
        for row, col in self.selection:
            sel = index(row + 2, col + 2)
            selection.select(sel, sel)
        self.tableview.selectionModel().select(
            selection, QItemSelectionModel.ClearAndSelect)

    def _learner_changed(self):
        self._update()
        self._set_selection()
        self.commit.deferred()

    def _update(self):
        def _isinvalid(x):
            return isnan(x) or isinf(x)

        # Update the displayed confusion matrix
        if self.results is not None and self.selected_learner:
            cmatrix = confusion_matrix(self.results, self.selected_learner[0])
            colsum = cmatrix.sum(axis=0)
            rowsum = cmatrix.sum(axis=1)
            n = len(cmatrix)
            diag = np.diag_indices(n)

            colors = cmatrix.astype(np.double)
            colors[diag] = 0
            if self.selected_quantity == 0:
                normalized = cmatrix.astype(int)
                formatstr = "{}"
                div = np.array([colors.max()])
            else:
                if self.selected_quantity == 1:
                    normalized = 100 * cmatrix / colsum
                    div = colors.max(axis=0)
                else:
                    normalized = 100 * cmatrix / rowsum[:, np.newaxis]
                    div = colors.max(axis=1)[:, np.newaxis]
                formatstr = "{:2.1f} %"
            div[div == 0] = 1
            colors /= div
            maxval = normalized[diag].max()
            if maxval > 0:
                colors[diag] = normalized[diag] / maxval

            for i in range(n):
                for j in range(n):
                    val = normalized[i, j]
                    col_val = colors[i, j]
                    item = self._item(i + 2, j + 2)
                    item.setData(
                        "NA" if _isinvalid(val) else formatstr.format(val),
                        Qt.DisplayRole)
                    bkcolor = QColor.fromHsl(
                        [0, 240][i == j], 160,
                        255 if _isinvalid(col_val) else int(255 - 30 * col_val))
                    item.setData(QBrush(bkcolor), Qt.BackgroundRole)
                    # bkcolor is light-ish so use a black text
                    item.setData(QBrush(Qt.black), Qt.ForegroundRole)
                    item.setData("trbl", BorderRole)
                    item.setToolTip("actual: {}\npredicted: {}".format(
                        self.headers[i], self.headers[j]))
                    item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
                    item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
                    self._set_item(i + 2, j + 2, item)

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

            def _sum_item(value, border=""):
                item = QStandardItem()
                item.setData(value, Qt.DisplayRole)
                item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
                item.setFlags(Qt.ItemIsEnabled)
                item.setFont(bold_font)
                item.setData(border, BorderRole)
                item.setData(QColor(192, 192, 192), BorderColorRole)
                return item

            for i in range(n):
                self._set_item(n + 2, i + 2, _sum_item(int(colsum[i]), "t"))
                self._set_item(i + 2, n + 2, _sum_item(int(rowsum[i]), "l"))
            self._set_item(n + 2, n + 2, _sum_item(int(rowsum.sum())))

    def send_report(self):
        """Send report"""
        if self.results is not None and self.selected_learner:
            self.report_table(
                "Confusion matrix for {} (showing {})".
                format(self.learners[self.selected_learner[0]],
                       self.quantities[self.selected_quantity].lower()),
                self.tableview)

    @classmethod
    def migrate_settings(cls, settings, version):
        if not version:
            # For some period of time the 'selected_learner' property was
            # changed from List[int] -> int
            # (commit 4e49bb3fd0e11262f3ebf4b1116a91a4b49cc982) and then back
            # again (commit 8a492d79a2e17154a0881e24a05843406c8892c0)
            if "selected_learner" in settings and \
                    isinstance(settings["selected_learner"], int):
                settings["selected_learner"] = [settings["selected_learner"]]


if __name__ == "__main__":  # pragma: no cover
    from Orange.widgets.evaluate.utils import results_for_preview
    WidgetPreview(OWConfusionMatrix).run(results_for_preview("iris"))

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user