Example #1
0
    def __init__(self):
        super().__init__()

        # sets self.curvePoints, self.steps equidistant points from
        # 1/self.steps to 1
        self.updateCurvePoints()

# [start-snippet-2]
        self.scoring = [
            ("Classification Accuracy", Orange.evaluation.scoring.CA),
            ("AUC", Orange.evaluation.scoring.AUC),
            ("Precision", Orange.evaluation.scoring.Precision),
            ("Recall", Orange.evaluation.scoring.Recall)
        ]
# [end-snippet-2]
        #: input data on which to construct the learning curve
        self.data = None
        #: A {input_id: Learner} mapping of current learners from input channel
        self.learners = OrderedDict()
        #: A {input_id: List[Results]} mapping of input id to evaluation
        #: results list, one for each curve point
        self.results = OrderedDict()
        #: A {input_id: List[float]} mapping of input id to learning curve
        #: point scores
        self.curves = OrderedDict()

        # GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoa = gui.widgetLabel(box, 'No data on input.')
        self.infob = gui.widgetLabel(box, 'No learners.')

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Evaluation Scores")
        gui.comboBox(box, self, "scoringF",
                     items=[x[0] for x in self.scoring],
                     callback=self._invalidate_curves)

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Options")
        gui.spin(box, self, 'folds', 2, 100, step=1,
                 label='Cross validation folds:  ', keyboardTracking=False,
                 callback=lambda:
                    self._invalidate_results() if self.commitOnChange else None
        )
        gui.spin(box, self, 'steps', 2, 100, step=1,
                 label='Learning curve points:  ', keyboardTracking=False,
                 callback=[self.updateCurvePoints,
                           lambda: self._invalidate_results() if self.commitOnChange else None])
        gui.checkBox(box, self, 'commitOnChange', 'Apply setting on any change')
        self.commitBtn = gui.button(box, self, "Apply Setting",
                                    callback=self._invalidate_results,
                                    disabled=True)

        gui.rubber(self.controlArea)

        # table widget
        self.table = gui.table(self.mainArea,
                               selectionMode=QTableWidget.NoSelection)
Example #2
0
    def __init__(self):
        super().__init__()

        # sets self.curvePoints, self.steps equidistant points from
        # 1/self.steps to 1
        self.updateCurvePoints()

        self.scoring = [
            ("Classification Accuracy", Orange.evaluation.scoring.CA),
            ("AUC", Orange.evaluation.scoring.AUC),
            ("Precision", Orange.evaluation.scoring.Precision),
            ("Recall", Orange.evaluation.scoring.Recall)
        ]
        #: input data on which to construct the learning curve
        self.data = None
        #: optional test data
        self.testdata = None
        #: A {input_id: Learner} mapping of current learners from input channel
        self.learners = OrderedDict()
        #: A {input_id: List[Results]} mapping of input id to evaluation
        #: results list, one for each curve point
        self.results = OrderedDict()
        #: A {input_id: List[float]} mapping of input id to learning curve
        #: point scores
        self.curves = OrderedDict()

        # GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoa = gui.widgetLabel(box, 'No data on input.')
        self.infob = gui.widgetLabel(box, 'No learners.')

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Evaluation Scores")
        gui.comboBox(box, self, "scoringF",
                     items=[x[0] for x in self.scoring],
                     callback=self._invalidate_curves)

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Options")
        gui.spin(box, self, 'folds', 2, 100, step=1,
                 label='Cross validation folds:  ', keyboardTracking=False,
                 callback=lambda:
                    self._invalidate_results() if self.commitOnChange else None
        )
        gui.spin(box, self, 'steps', 2, 100, step=1,
                 label='Learning curve points:  ', keyboardTracking=False,
                 callback=[self.updateCurvePoints,
                           lambda: self._invalidate_results() if self.commitOnChange else None])
        gui.checkBox(box, self, 'commitOnChange', 'Apply setting on any change')
        self.commitBtn = gui.button(box, self, "Apply Setting",
                                    callback=self._invalidate_results,
                                    disabled=True)

        gui.rubber(self.controlArea)

        # table widget
        self.table = gui.table(self.mainArea,
                               selectionMode=QTableWidget.NoSelection)
Example #3
0
    def __init__(self,
                 parent: OWWidget = None,
                 title=None,
                 column_count=2,
                 column_headers=["x", "y"]):
        QtWidgets.QWidget.__init__(self, parent)
        OWComponent.__init__(self, parent)

        # GUI
        self.table = gui.table(self, 0, column_count)
        # selection multiline and row
        self.table.setSelectionMode(
            QtWidgets.QAbstractItemView.SelectionMode.MultiSelection)
        self.table.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
        # set headers labels
        self.table.setHorizontalHeaderLabels(column_headers)
        # columns shapes
        self.table.horizontalHeader().setResizeMode(
            QtWidgets.QHeaderView.Stretch)

        vbox = QtWidgets.QVBoxLayout()
        if title is not None:
            vbox.addWidget(gui.label(self, parent, title))
        vbox.addWidget(self.table)
        self.setLayout(vbox)
Example #4
0
    def add_tables(self, networks):
        from PyQt4.QtCore import SIGNAL
        self.networks = networks
        self.tables = []

        if networks is None:
            return

        networks.sort(key=lambda net: net.repository)
        for k, g in itertools.groupby(networks,
                                      key=lambda net: net.repository):
            network_group = list(g)

            if len(network_group) > 0:
                self.network_list.layout().addWidget(
                    QLabel("<h3>" + network_group[0].repository + "</h3>"))
                table = gui.table(self.network_list,
                                  rows=len(network_group),
                                  columns=5,
                                  selectionMode=-1,
                                  addToLayout=1)
                table.setHorizontalHeaderLabels(
                    ['Name', 'Type', 'Nodes', 'Edges', 'Description'])
                f = table.font()
                f.setPointSize(9)
                table.setFont(f)
                table.verticalHeader().hide()
                table.setSelectionMode(QAbstractItemView.SingleSelection)
                table.setSelectionBehavior(QAbstractItemView.SelectRows)
                self.connect(table,
                             SIGNAL('itemSelectionChanged()'),
                             lambda table=table: self.select_network(table))

                for i, net in enumerate(network_group):
                    lbl = QLabel("<a href='" + net.link + "'>" + net.name +
                                 "</a>")
                    lbl.setOpenExternalLinks(True)
                    table.setCellWidget(i, 0, lbl)
                    gui.tableItem(table, i, 1, net.type)
                    gui.tableItem(table, i, 2, net.nodes)
                    gui.tableItem(table, i, 3, net.edges)
                    gui.tableItem(table, i, 4, net.description)

                table.setFixedSize(712, 100)
                table.setColumnWidth(0, 120)
                table.setColumnWidth(1, 80)
                table.setColumnWidth(2, 80)
                table.setColumnWidth(3, 80)
                table.setColumnWidth(4, 350)
                table.resizeRowsToContents()
                table.setFixedSize(
                    712,
                    sum(table.rowHeight(i) for i in range(len(networks))) + 27)
                self.tables.append(table)

                gui.separator(self.network_list, 10, 10)
Example #5
0
    def __init__(self):
        super().__init__()
        self.controlArea.setMinimumWidth(250)
        self.v_info_box = gui.vBox(self.controlArea, 'Info')
        self.v_info = gui.label(self.v_info_box, self, '')
        self.v_info.setAlignment(QtCore.Qt.AlignTop)

        self.mainArea.setMinimumWidth(600)
        self.mainArea.setMinimumHeight(600)

        self.v_table = gui.table(self.mainArea, 0, 0)
Example #6
0
    def add_tables(self, networks):
        self.networks = networks
        self.tables = []

        if networks is None:
            return

        networks.sort(key=lambda net: net.repository)
        for k,g in itertools.groupby(networks, key=lambda net: net.repository):
            network_group = list(g)

            if len(network_group) > 0:
                self.network_list.layout().addWidget(QLabel("<h3>" + network_group[0].repository + "</h3>"))
                table = gui.table(self.network_list, rows=len(network_group), columns=5, selectionMode = -1, addToLayout = 1)
                table.setHorizontalHeaderLabels(['Name', 'Type', 'Nodes', 'Edges', 'Description'])
                f = table.font()
                f.setPointSize(9)
                table.setFont(f)
                table.verticalHeader().hide()
                table.setSelectionMode(QAbstractItemView.SingleSelection)
                table.setSelectionBehavior(QAbstractItemView.SelectRows)
                table.itemSelectionChanged.connect(
                    lambda table=table: self.select_network(table))

                for i, net in enumerate(network_group):
                    lbl = QLabel("<a href='"+ net.link +"'>" + net.name + "</a>")
                    lbl.setOpenExternalLinks(True)
                    table.setCellWidget(i, 0, lbl)
                    gui.tableItem(table, i, 1, net.type)
                    gui.tableItem(table, i, 2, net.nodes)
                    gui.tableItem(table, i, 3, net.edges)
                    gui.tableItem(table, i, 4, net.description)

                table.setFixedSize(712, 100)
                table.setColumnWidth(0, 120)
                table.setColumnWidth(1, 80)
                table.setColumnWidth(2, 80)
                table.setColumnWidth(3, 80)
                table.setColumnWidth(4, 350)
                table.resizeRowsToContents()
                table.setFixedSize(712, sum(table.rowHeight(i) for i in range(len(networks))) + 27)
                self.tables.append(table)

                gui.separator(self.network_list, 10, 10)
Example #7
0
    def __init__(self):
        super().__init__()

        #: A {input_id: table} mapping of current tables from input channel
        self.tables = OrderedDict()

        # GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoa = gui.widgetLabel(box, "No data on input.")
        self.infob = gui.widgetLabel(box, "Please connect to other widgets.")

        gui.separator(self.controlArea)

        self.tablesbox = gui.widgetBox(self.controlArea, "Table List")
        gui.button(self.tablesbox, self, "Run Glueviz", callback=self.commit)
        self.tablesbox.setDisabled(True)

        gui.separator(self.controlArea)

        # table widget for statistic data of input tables
        self.tablelist = gui.table(self.controlArea,
                                   selectionMode=QTableWidget.NoSelection)
Example #8
0
    def __init__(self):
        super().__init__()

        # sets self.curvePoints, self.steps equidistant points from
        # 1/self.steps to 1
        self.updateCurvePoints()

        self.scoring = [
            ("Classification Accuracy", Orange.evaluation.scoring.CA),
            ("AUC", Orange.evaluation.scoring.AUC),
            ("Precision", Orange.evaluation.scoring.Precision),
            ("Recall", Orange.evaluation.scoring.Recall),
        ]
        #: input data on which to construct the learning curve
        self.data = None
        #: optional test data
        self.testdata = None
        #: A {input_id: Learner} mapping of current learners from input channel
        self.learners = OrderedDict()
        #: A {input_id: List[Results]} mapping of input id to evaluation
        #: results list, one for each curve point
        self.results = OrderedDict()
        #: A {input_id: List[float]} mapping of input id to learning curve
        #: point scores
        self.curves = OrderedDict()

        # [start-snippet-3]
        #: The current evaluating task (if any)
        self._task = None  # type: Optional[Task]
        #: An executor we use to submit learner evaluations into a thread pool
        self._executor = ThreadExecutor()
        # [end-snippet-3]

        # GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoa = gui.widgetLabel(box, "No data on input.")
        self.infob = gui.widgetLabel(box, "No learners.")

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Evaluation Scores")
        gui.comboBox(
            box,
            self,
            "scoringF",
            items=[x[0] for x in self.scoring],
            callback=self._invalidate_curves,
        )

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Options")
        gui.spin(
            box,
            self,
            "folds",
            2,
            100,
            step=1,
            label="Cross validation folds:  ",
            keyboardTracking=False,
            callback=lambda: self._invalidate_results()
            if self.commitOnChange else None,
        )
        gui.spin(
            box,
            self,
            "steps",
            2,
            100,
            step=1,
            label="Learning curve points:  ",
            keyboardTracking=False,
            callback=[
                self.updateCurvePoints,
                lambda: self._invalidate_results()
                if self.commitOnChange else None,
            ],
        )
        gui.checkBox(box, self, "commitOnChange",
                     "Apply setting on any change")
        self.commitBtn = gui.button(box,
                                    self,
                                    "Apply Setting",
                                    callback=self._invalidate_results,
                                    disabled=True)

        gui.rubber(self.controlArea)

        # table widget
        self.table = gui.table(self.mainArea,
                               selectionMode=QTableWidget.NoSelection)
Example #9
0
    def __init__(self):
        super().__init__()

        # sets self.curvePoints, self.steps equidistant points from
        # 1/self.steps to 1
        self.updateCurvePoints()

        # [start-snippet-2]
        self.scoring = [("Classification Accuracy",
                         Orange.evaluation.scoring.CA),
                        ("AUC", Orange.evaluation.scoring.AUC),
                        ("Precision", Orange.evaluation.scoring.Precision),
                        ("Recall", Orange.evaluation.scoring.Recall)]
        # [end-snippet-2]
        #: input data on which to construct the learning curve
        self.data = None
        #: A {input_id: Learner} mapping of current learners from input channel
        self.learners = OrderedDict()  #OrderedDict()字典 排序
        #: A {input_id: List[Results]} mapping of input id to evaluation
        #: results list, one for each curve point
        self.results = OrderedDict(
        )  #Return an instance of a dict subclass, supporting the usual dict methods. An OrderedDict is a dict that remembers the order that keys were first inserted. If a new entry overwrites an existing entry, the original insertion position is left unchanged. Deleting an entry and reinserting it will move it to the end.
        #: A {input_id: List[float]} mapping of input id to learning curve
        #: point scores
        self.curves = OrderedDict()

        # GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoa = gui.widgetLabel(box, 'No data on input.')
        self.infob = gui.widgetLabel(box, 'No learners.')

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Evaluation Scores")
        gui.comboBox(box,
                     self,
                     "scoringF",
                     items=[x[0] for x in self.scoring],
                     callback=self._invalidate_curves)

        gui.separator(self.controlArea)

        box = gui.widgetBox(self.controlArea, "Options")
        gui.spin(box,
                 self,
                 'folds',
                 2,
                 100,
                 step=1,
                 label='Cross validation folds:  ',
                 keyboardTracking=False,
                 callback=lambda: self._invalidate_results()
                 if self.commitOnChange else None)
        gui.spin(box,
                 self,
                 'steps',
                 2,
                 100,
                 step=1,
                 label='Learning curve points:  ',
                 keyboardTracking=False,
                 callback=[
                     self.updateCurvePoints,
                     lambda: self._invalidate_results()
                     if self.commitOnChange else None
                 ])
        gui.checkBox(box, self, 'commitOnChange',
                     'Apply setting on any change')
        self.commitBtn = gui.button(box,
                                    self,
                                    "Apply Setting",
                                    callback=self._invalidate_results,
                                    disabled=True)

        gui.rubber(self.controlArea)

        # table widget
        self.table = gui.table(self.mainArea,
                               selectionMode=QTableWidget.NoSelection)