本文整理汇总了Python中Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph.can_draw_regresssion_line方法的典型用法代码示例。如果您正苦于以下问题:Python OWScatterPlotGraph.can_draw_regresssion_line方法的具体用法?Python OWScatterPlotGraph.can_draw_regresssion_line怎么用?Python OWScatterPlotGraph.can_draw_regresssion_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph
的用法示例。
在下文中一共展示了OWScatterPlotGraph.can_draw_regresssion_line方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWScatterPlot
# 需要导入模块: from Orange.widgets.visualize.owscatterplotgraph import OWScatterPlotGraph [as 别名]
# 或者: from Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph import can_draw_regresssion_line [as 别名]
#.........这里部分代码省略.........
data = Table(data_sample)
self.data = Table.concatenate((self.data, data), axis=0)
self.handleNewSignals()
def switch_sampling(self):
self.__timer.stop()
if self.auto_sample and self.sql_data:
self.add_data()
self.__timer.start()
@Inputs.data_subset
def set_subset_data(self, subset_data):
self.warning()
if isinstance(subset_data, SqlTable):
if subset_data.approx_len() < AUTO_DL_LIMIT:
subset_data = Table(subset_data)
else:
self.warning("Data subset does not support large Sql tables")
subset_data = None
self.subset_data = subset_data
self.controls.graph.alpha_value.setEnabled(subset_data is None)
# called when all signals are received, so the graph is updated only once
def handleNewSignals(self):
self.graph.new_data(self.data, self.subset_data)
if self.attribute_selection_list and self.graph.domain and \
all(attr in self.graph.domain
for attr in self.attribute_selection_list):
self.attr_x = self.attribute_selection_list[0]
self.attr_y = self.attribute_selection_list[1]
self.attribute_selection_list = None
self.update_graph()
self.cb_class_density.setEnabled(self.graph.can_draw_density())
self.cb_reg_line.setEnabled(self.graph.can_draw_regresssion_line())
if self.data is not None and self.__pending_selection_restore is not None:
self.apply_selection(self.__pending_selection_restore)
self.__pending_selection_restore = None
self.unconditional_commit()
def apply_selection(self, selection):
"""Apply `selection` to the current plot."""
if self.data is not None:
self.graph.selection = np.zeros(len(self.data), dtype=np.uint8)
self.selection_group = [x for x in selection if x[0] < len(self.data)]
selection_array = np.array(self.selection_group).T
self.graph.selection[selection_array[0]] = selection_array[1]
self.graph.update_colors(keep_colors=True)
@Inputs.features
def set_shown_attributes(self, attributes):
if attributes and len(attributes) >= 2:
self.attribute_selection_list = attributes[:2]
else:
self.attribute_selection_list = None
def init_attr_values(self):
domain = self.data and self.data.domain
for model in self.models:
model.set_domain(domain)
self.attr_x = self.xy_model[0] if self.xy_model else None
self.attr_y = self.xy_model[1] if len(self.xy_model) >= 2 \
else self.attr_x
self.graph.attr_color = self.data.domain.class_var if domain else None
self.graph.attr_shape = None
self.graph.attr_size = None
self.graph.attr_label = None
示例2: OWScatterPlot
# 需要导入模块: from Orange.widgets.visualize.owscatterplotgraph import OWScatterPlotGraph [as 别名]
# 或者: from Orange.widgets.visualize.owscatterplotgraph.OWScatterPlotGraph import can_draw_regresssion_line [as 别名]
#.........这里部分代码省略.........
def move_primitive_metas_to_X(self, data):
if data is not None:
new_attrs = [a for a in data.domain.attributes + data.domain.metas
if a.is_primitive()]
new_metas = [m for m in data.domain.metas if not m.is_primitive()]
new_domain = Domain(new_attrs, data.domain.class_vars, new_metas)
data = data.transform(new_domain)
return data
@Inputs.data_subset
def set_subset_data(self, subset_data):
self.warning()
if isinstance(subset_data, SqlTable):
if subset_data.approx_len() < AUTO_DL_LIMIT:
subset_data = Table(subset_data)
else:
self.warning("Data subset does not support large Sql tables")
subset_data = None
self.subset_data = self.move_primitive_metas_to_X(subset_data)
self.controls.graph.alpha_value.setEnabled(subset_data is None)
# called when all signals are received, so the graph is updated only once
def handleNewSignals(self):
self.graph.new_data(self.sparse_to_dense(self.data_metas_X),
self.sparse_to_dense(self.subset_data))
if self.attribute_selection_list and self.graph.domain and \
all(attr in self.graph.domain
for attr in self.attribute_selection_list):
self.attr_x = self.attribute_selection_list[0]
self.attr_y = self.attribute_selection_list[1]
self.attribute_selection_list = None
self.update_graph()
self.cb_class_density.setEnabled(self.graph.can_draw_density())
self.cb_reg_line.setEnabled(self.graph.can_draw_regresssion_line())
self.apply_selection()
self.unconditional_commit()
def prepare_data(self):
"""
Only when dealing with sparse matrices.
GH-2152
"""
self.graph.new_data(self.sparse_to_dense(self.data_metas_X),
self.sparse_to_dense(self.subset_data),
new=False)
def sparse_to_dense(self, input_data=None):
if input_data is None or not input_data.is_sparse():
return input_data
keys = []
attrs = {self.attr_x,
self.attr_y,
self.graph.attr_color,
self.graph.attr_shape,
self.graph.attr_size,
self.graph.attr_label}
for i, attr in enumerate(input_data.domain):
if attr in attrs:
keys.append(i)
new_domain = input_data.domain.select_columns(keys)
dmx = input_data.transform(new_domain)
dmx.X = dmx.X.toarray()
# TODO: remove once we make sure Y is always dense.
if sp.issparse(dmx.Y):
dmx.Y = dmx.Y.toarray()
return dmx