def __init__(self): super().__init__() self.data = None self.extra_data = None self.extra_data = None self.model = itemmodels.VariableListModel() self.model_unique_with_id = itemmodels.VariableListModel() self.extra_model_unique = itemmodels.VariableListModel() self.extra_model_unique_with_id = itemmodels.VariableListModel() box = gui.hBox(self.controlArea, box=None) self.infoBoxData = gui.label( box, self, self.dataInfoText(None), box="Data") self.infoBoxExtraData = gui.label( box, self, self.dataInfoText(None), box="Extra Data") grp = gui.radioButtonsInBox( self.controlArea, self, "merging", box="Merging", callback=self.change_merging) self.attr_boxes = [] radio_width = \ QApplication.style().pixelMetric(QStyle.PM_ExclusiveIndicatorWidth) def add_option(label, pre_label, between_label, merge_type, model, extra_model): gui.appendRadioButton(grp, label) vbox = gui.vBox(grp) box = gui.hBox(vbox) box.layout().addSpacing(radio_width) self.attr_boxes.append(box) gui.widgetLabel(box, pre_label) model[:] = [getattr(self, 'attr_{}_data'.format(merge_type))] extra_model[:] = [getattr(self, 'attr_{}_extra'.format(merge_type))] cb = gui.comboBox(box, self, 'attr_{}_data'.format(merge_type), callback=self._invalidate, model=model) cb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) cb.setFixedWidth(190) gui.widgetLabel(box, between_label) cb = gui.comboBox(box, self, 'attr_{}_extra'.format(merge_type), callback=self._invalidate, model=extra_model) cb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) cb.setFixedWidth(190) vbox.layout().addSpacing(6) add_option("Append columns from Extra Data", "by matching", "with", "augment", self.model, self.extra_model_unique) add_option("Find matching rows", "where", "equals", "merge", self.model_unique_with_id, self.extra_model_unique_with_id) add_option("Concatenate tables, merge rows", "where", "equals", "combine", self.model_unique_with_id, self.extra_model_unique_with_id) self.set_merging()
def add_main_layout(self): # var models self.x_var_model = itemmodels.VariableListModel() self.y_var_model = itemmodels.VariableListModel() # options box self.options_box = gui.widgetBox(self.controlArea, "Options") opts = dict( widget=self.options_box, master=self, orientation=Qt.Horizontal) opts_combo = dict(opts, **dict(sendSelectedValue=True, maximumContentsLength=15)) self.cbx = gui.comboBox( value='attr_x', label='X: ', callback=self.apply, **opts_combo) self.cby = gui.comboBox( value='attr_y', label='Y: ', callback=self.apply, **opts_combo) self.target_class_combobox = gui.comboBox( value='target_class', label='Target: ', callback=self.apply, **opts_combo) self.degree_spin = gui.spin( value='degree', label='Polynomial expansion:', minv=1, maxv=5, step=1, callback=self.init_learner, alignment=Qt.AlignRight, controlWidth=70, **opts) self.cbx.setModel(self.x_var_model) self.cby.setModel(self.y_var_model) # plot properties box self.plot_properties_box = gui.widgetBox( self.controlArea, "Plot Properties") self.legend_enabled_checkbox = gui.checkBox( self.plot_properties_box, self, 'legend_enabled', label="Show legend", callback=self.replot) self.contours_enabled_checkbox = gui.checkBox( self.plot_properties_box, self, 'contours_enabled', label="Show contours", callback=self.plot_contour) self.contour_step_slider = gui.spin( self.plot_properties_box, self, 'contour_step', minv=0.10, maxv=0.50, step=0.05, callback=self.plot_contour, label='Contour step:', decimals=2, spinType=float, alignment=Qt.AlignRight, controlWidth=70) gui.rubber(self.controlArea) # chart self.scatter = Scatterplot( xAxis_gridLineWidth=0, yAxis_gridLineWidth=0, xAxis_startOnTick=False, xAxis_endOnTick=False, yAxis_startOnTick=False, yAxis_endOnTick=False, xAxis_lineWidth=0, yAxis_lineWidth=0, yAxis_tickWidth=1, title_text='', tooltip_shared=False) # Just render an empty chart so it shows a nice 'No data to display' self.scatter.chart() self.mainArea.layout().addWidget(self.scatter) self.init_learner()
def add_main_layout(self): self.scatterplot_item = None self.plot_item = None self.x_label = 'x' self.y_label = 'y' box = gui.vBox(self.controlArea, "Variables") self.x_var_model = itemmodels.VariableListModel() self.comboBoxAttributesX = gui.comboBox( box, self, value='x_var_index', label="Input ", orientation=Qt.Horizontal, callback=self.apply, contentsLength=12) self.comboBoxAttributesX.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) self.comboBoxAttributesX.setModel(self.x_var_model) gui.doubleSpin( gui.indentedBox(box), self, "polynomialexpansion", 0, 10, label="Polynomial expansion:", callback=self.apply) gui.separator(box, height=8) self.y_var_model = itemmodels.VariableListModel() self.comboBoxAttributesY = gui.comboBox( box, self, value='y_var_index', label='Target', orientation=Qt.Horizontal, callback=self.apply, contentsLength=12) self.comboBoxAttributesY.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) self.comboBoxAttributesY.setModel(self.y_var_model) gui.rubber(self.controlArea) # main area GUI self.plotview = pg.PlotWidget(background="w") self.plot = self.plotview.getPlotItem() axis_color = self.palette().color(QPalette.Text) axis_pen = QPen(axis_color) tickfont = QFont(self.font()) tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11)) axis = self.plot.getAxis("bottom") axis.setLabel(self.x_label) axis.setPen(axis_pen) axis.setTickFont(tickfont) axis = self.plot.getAxis("left") axis.setLabel(self.y_label) axis.setPen(axis_pen) axis.setTickFont(tickfont) self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0), disableAutoRange=True) self.mainArea.layout().addWidget(self.plotview)
def __init__(self): super().__init__() # data self.dataA = None self.dataB = None # GUI box = gui.hBox(self.controlArea, "Match instances by") # attribute A selection self.attrViewA = gui.comboBox(box, self, 'attr_a', label="Data A", orientation=Qt.Vertical, sendSelectedValue=True, callback=self._invalidate) self.attrModelA = itemmodels.VariableListModel() self.attrViewA.setModel(self.attrModelA) # attribute B selection self.attrViewB = gui.comboBox(box, self, 'attr_b', label="Data B", orientation=Qt.Vertical, sendSelectedValue=True, callback=self._invalidate) self.attrModelB = itemmodels.VariableListModel() self.attrViewB.setModel(self.attrModelB) # info A box = gui.hBox(self.controlArea, box=None) self.infoBoxDataA = gui.label(box, self, self.dataInfoText(None), box="Data A Info") # info B self.infoBoxDataB = gui.label(box, self, self.dataInfoText(None), box="Data B Info") gui.separator(self.controlArea) box = gui.vBox(self.controlArea, box=True) gui.checkBox(box, self, "inner", "Exclude instances without a match", callback=self._invalidate)
def __init__(self): super().__init__() # data self.dataA = None self.dataB = None # GUI w = QWidget(self) self.controlArea.layout().addWidget(w) grid = QGridLayout() grid.setContentsMargins(0, 0, 0, 0) w.setLayout(grid) # attribute A selection boxAttrA = gui.vBox(self, self.tr("Attribute A"), addToLayout=False) grid.addWidget(boxAttrA, 0, 0) self.attrViewA = gui.comboBox(boxAttrA, self, 'attr_a', orientation=Qt.Horizontal, sendSelectedValue=True, callback=self._invalidate) self.attrModelA = itemmodels.VariableListModel() self.attrViewA.setModel(self.attrModelA) # attribute B selection boxAttrB = gui.vBox(self, self.tr("Attribute B"), addToLayout=False) grid.addWidget(boxAttrB, 0, 1) self.attrViewB = gui.comboBox(boxAttrB, self, 'attr_b', orientation=Qt.Horizontal, sendSelectedValue=True, callback=self._invalidate) self.attrModelB = itemmodels.VariableListModel() self.attrViewB.setModel(self.attrModelB) # info A boxDataA = gui.vBox(self, self.tr("Data A Input"), addToLayout=False) grid.addWidget(boxDataA, 1, 0) self.infoBoxDataA = gui.widgetLabel(boxDataA, self.dataInfoText(None)) # info B boxDataB = gui.vBox(self, self.tr("Data B Input"), addToLayout=False) grid.addWidget(boxDataB, 1, 1) self.infoBoxDataB = gui.widgetLabel(boxDataB, self.dataInfoText(None)) gui.rubber(self)
def __init__(self): super().__init__() self.data = None self.component_x = 0 self.component_y = 1 box = gui.vBox(self.controlArea, "Variables") self.varlist = itemmodels.VariableListModel() self.varview = view = QListView(selectionMode=QListView.MultiSelection) view.setModel(self.varlist) view.selectionModel().selectionChanged.connect(self._var_changed) box.layout().addWidget(view) axes_box = gui.vBox(self.controlArea, "Axes") box = gui.vBox(axes_box, "Axis X", margin=0) box.setFlat(True) self.axis_x_cb = gui.comboBox( box, self, "component_x", callback=self._component_changed) box = gui.vBox(axes_box, "Axis Y", margin=0) box.setFlat(True) self.axis_y_cb = gui.comboBox( box, self, "component_y", callback=self._component_changed) self.infotext = gui.widgetLabel( gui.vBox(self.controlArea, "Contribution to Inertia"), "\n" ) gui.rubber(self.controlArea) self.plot = pg.PlotWidget(background="w") self.plot.setMenuEnabled(False) self.mainArea.layout().addWidget(self.plot)
def __init__(self): super().__init__() # Diagram update is in progress self._updating = False # Input update is in progress self._inputUpdate = False # Input datasets in the order they were 'connected'. self.data = {} # Extracted input item sets in the order they were 'connected' self.itemsets = {} # A list with 2 ** len(self.data) elements that store item sets # belonging to each area self.disjoint = [] # A list with 2 ** len(self.data) elements that store keys of tables # intersected in each area self.area_keys = [] # Main area view self.scene = QGraphicsScene() self.view = QGraphicsView(self.scene) self.view.setRenderHint(QPainter.Antialiasing) self.view.setBackgroundRole(QPalette.Window) self.view.setFrameStyle(QGraphicsView.StyledPanel) self.mainArea.layout().addWidget(self.view) self.vennwidget = VennDiagram() self._resize() self.vennwidget.itemTextEdited.connect(self._on_itemTextEdited) self.scene.selectionChanged.connect(self._on_selectionChanged) self.scene.addItem(self.vennwidget) controls = gui.hBox(self.mainArea) box = gui.radioButtonsInBox(controls, self, 'rowwise', [ "Columns (features)", "Rows (instances), matched by", ], box="Elements", callback=self._on_matching_changed) gui.comboBox(gui.indentedBox(box), self, "selected_feature", model=itemmodels.VariableListModel( placeholder="Instance identity"), callback=self._on_inputAttrActivated) box.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) self.outputs_box = box = gui.vBox(controls, "Output") self.output_duplicates_cb = gui.checkBox( box, self, "output_duplicates", "Output duplicates", callback=lambda: self.commit()) # pylint: disable=unnecessary-lambda gui.auto_send(box, self, "autocommit", box=False) self.output_duplicates_cb.setEnabled(bool(self.rowwise)) self._queue = []
def __init__(self): super().__init__() self.data = None self._effective_data = None self._matrix = None self._silhouette = None self._labels = None self._silplot = None box = gui.widgetBox(self.controlArea, "Settings",) gui.comboBox(box, self, "distance_idx", label="Distance", items=[name for name, _ in OWSilhouettePlot.Distances], callback=self._invalidate_distances) self.cluster_var_cb = gui.comboBox( box, self, "cluster_var_idx", label="Cluster", callback=self._invalidate_scores) self.cluster_var_model = itemmodels.VariableListModel(parent=self) self.cluster_var_cb.setModel(self.cluster_var_model) gui.spin(box, self, "bar_size", minv=1, maxv=10, label="Bar Size", callback=self._update_bar_size) gui.checkBox(box, self, "group_by_cluster", "Group by cluster", callback=self._replot) self.annotation_cb = gui.comboBox( box, self, "annotation_var_idx", label="Annotations", callback=self._update_annotations) self.annotation_var_model = itemmodels.VariableListModel(parent=self) self.annotation_var_model[:] = ["None"] self.annotation_cb.setModel(self.annotation_var_model) gui.rubber(self.controlArea) box = gui.widgetBox(self.controlArea, "Output") gui.checkBox(box, self, "add_scores", "Add silhouette scores",) gui.auto_commit(box, self, "auto_commit", "Commit", box=False) self.scene = QtGui.QGraphicsScene() self.view = QtGui.QGraphicsView(self.scene) self.view.setRenderHint(QtGui.QPainter.Antialiasing, True) self.view.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.mainArea.layout().addWidget(self.view)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.data: Optional[Table] = None self._output_desc: Optional[Dict[str, str]] = None box = gui.widgetBox(self.controlArea, "Unique Row Identifier") self.idvar_model = itemmodels.VariableListModel( [None], placeholder="Row number") self.var_cb = gui.comboBox( box, self, "idvar", model=self.idvar_model, callback=self._invalidate, minimumContentsLength=16, tooltip="A column with identifier, like customer's id") box = gui.widgetBox(self.controlArea, "Filter") gui.checkBox(box, self, "only_numeric", "Ignore non-numeric features", callback=self._invalidate) gui.checkBox( box, self, "exclude_zeros", "Exclude zero values", callback=self._invalidate, tooltip="Besides missing values, also omit items with zero values") form = QFormLayout() gui.widgetBox(self.controlArea, "Names for generated features", orientation=form) form.addRow( "Item:", gui.lineEdit(None, self, "item_var_name", callback=self._invalidate, placeholderText=DEFAULT_ITEM_NAME, styleSheet="padding-left: 3px")) form.addRow( "Value:", gui.lineEdit(None, self, "value_var_name", callback=self._invalidate, placeholderText=DEFAULT_VALUE_NAME, styleSheet="padding-left: 3px")) gui.auto_apply(self.controlArea, self)
def __init__(self): super().__init__() self.data = None self.component_x = 0 self.component_y = 1 self._set_input_summary(None) self._set_output_summary(None) box = gui.vBox(self.controlArea, "Variables") self.varlist = itemmodels.VariableListModel() self.varview = view = ListViewSearch( selectionMode=QListView.MultiSelection, uniformItemSizes=True ) view.setModel(self.varlist) view.selectionModel().selectionChanged.connect(self._var_changed) box.layout().addWidget(view) axes_box = gui.vBox(self.controlArea, "Axes") self.axis_x_cb = gui.comboBox( axes_box, self, "component_x", label="X:", callback=self._component_changed, orientation=Qt.Horizontal, sizePolicy=(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred) ) self.axis_y_cb = gui.comboBox( axes_box, self, "component_y", label="Y:", callback=self._component_changed, orientation=Qt.Horizontal, sizePolicy=(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred) ) self.infotext = gui.widgetLabel( gui.vBox(self.controlArea, "Contribution to Inertia"), "\n" ) gui.auto_send(self.buttonsArea, self, "auto_commit") self.plot = pg.PlotWidget(background="w") self.plot.setMenuEnabled(False) self.mainArea.layout().addWidget(self.plot)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.data = None # type: Orange.data.Table self.idvar_model = itemmodels.VariableListModel(parent=self) self.item_var_name = "Item" self.value_var_name = "Rating" box = gui.widgetBox(self.controlArea, "Info") self.info_text = gui.widgetLabel(box, "No data") box = gui.widgetBox(self.controlArea, "Id var") self.var_cb = gui.comboBox(box, self, "idvar", callback=self._invalidate) self.var_cb.setMinimumContentsLength(16) self.var_cb.setModel(self.idvar_model) gui.lineEdit(self.controlArea, self, "item_var_name", box="Item name", callback=self._invalidate) gui.lineEdit(self.controlArea, self, "value_var_name", box="Value name", callback=self._invalidate)