本文整理汇总了Python中Orange.widgets.utils.itemmodels.VariableListModel.extend方法的典型用法代码示例。如果您正苦于以下问题:Python VariableListModel.extend方法的具体用法?Python VariableListModel.extend怎么用?Python VariableListModel.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.widgets.utils.itemmodels.VariableListModel
的用法示例。
在下文中一共展示了VariableListModel.extend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWCorpus
# 需要导入模块: from Orange.widgets.utils.itemmodels import VariableListModel [as 别名]
# 或者: from Orange.widgets.utils.itemmodels.VariableListModel import extend [as 别名]
#.........这里部分代码省略.........
# Enable/Disable command when data from input
self.file_widget.setEnabled(not have_data)
self.browse_documentation.setEnabled(not have_data)
if have_data:
self.open_file(data=data)
else:
self.file_widget.reload()
def open_file(self, path=None, data=None):
self.closeContext()
self.Error.clear()
self.unused_attrs_model[:] = []
self.used_attrs_model[:] = []
if data:
self.corpus = Corpus.from_table(data.domain, data)
elif path:
try:
self.corpus = Corpus.from_file(path)
self.corpus.name = os.path.splitext(os.path.basename(path))[0]
except BaseException as err:
self.Error.read_file(path, str(err))
else:
return
self.update_info()
self.used_attrs = list(self.corpus.text_features)
if not self.corpus.text_features:
self.Error.corpus_without_text_features()
self.Outputs.corpus.send(None)
return
self.openContext(self.corpus)
self.used_attrs_model.extend(self.used_attrs)
self.unused_attrs_model.extend(
[f for f in self.corpus.domain.metas
if f.is_string and f not in self.used_attrs_model])
def update_info(self):
def describe(corpus):
dom = corpus.domain
text_feats = sum(m.is_string for m in dom.metas)
other_feats = len(dom.attributes) + len(dom.metas) - text_feats
text = \
"{} document(s), {} text features(s), {} other feature(s).". \
format(len(corpus), text_feats, other_feats)
if dom.has_continuous_class:
text += "<br/>Regression; numerical class."
elif dom.has_discrete_class:
text += "<br/>Classification; discrete class with {} values.". \
format(len(dom.class_var.values))
elif corpus.domain.class_vars:
text += "<br/>Multi-target; {} target variables.".format(
len(corpus.domain.class_vars))
else:
text += "<br/>Data has no target variable."
text += "</p>"
return text
if self.corpus is None:
self.info_label.setText("No corpus loaded.")
else:
self.info_label.setText(describe(self.corpus))
def update_feature_selection(self):
self.Error.no_text_features_used.clear()