本文整理汇总了Python中Orange.data.Table.name方法的典型用法代码示例。如果您正苦于以下问题:Python Table.name方法的具体用法?Python Table.name怎么用?Python Table.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.data.Table
的用法示例。
在下文中一共展示了Table.name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: commit
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def commit(self):
transformed = components = pp = None
if self._pca is not None:
if self._transformed is None:
# Compute the full transform (MAX_COMPONENTS components) only once.
self._transformed = self._pca(self.data)
transformed = self._transformed
domain = Domain(
transformed.domain.attributes[:self.ncomponents],
self.data.domain.class_vars,
self.data.domain.metas
)
transformed = transformed.from_table(domain, transformed)
# prevent caching new features by defining compute_value
dom = Domain([ContinuousVariable(a.name, compute_value=lambda _: None)
for a in self._pca.orig_domain.attributes],
metas=[StringVariable(name='component')])
metas = numpy.array([['PC{}'.format(i + 1)
for i in range(self.ncomponents)]],
dtype=object).T
components = Table(dom, self._pca.components_[:self.ncomponents],
metas=metas)
components.name = 'components'
pp = ApplyDomain(domain, "PCA")
self._pca_projector.component = self.ncomponents
self.Outputs.transformed_data.send(transformed)
self.Outputs.components.send(components)
self.Outputs.pca.send(self._pca_projector)
self.Outputs.preprocessor.send(pp)
示例2: send_features
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def send_features(self):
features = None
if self.attr_x or self.attr_y:
dom = Domain([], metas=(StringVariable(name="feature"),))
features = Table(dom, [[self.attr_x], [self.attr_y]])
features.name = "Features"
self.Outputs.features.send(features)
示例3: commit
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def commit(self):
transformed = components = None
if self._pca is not None:
if self._transformed is None:
# Compute the full transform (all components) only once.
self._transformed = self._pca(self.data)
transformed = self._transformed
domain = Domain(
transformed.domain.attributes[:self.ncomponents],
self.data.domain.class_vars,
self.data.domain.metas
)
transformed = transformed.from_table(domain, transformed)
dom = Domain(self._pca.orig_domain.attributes,
metas=[StringVariable(name='component')])
metas = numpy.array([['PC{}'.format(i + 1)
for i in range(self.ncomponents)]],
dtype=object).T
components = Table(dom, self._pca.components_[:self.ncomponents],
metas=metas)
components.name = 'components'
self._pca_projector.component = self.ncomponents
self.send("Transformed data", transformed)
self.send("Components", components)
self.send("PCA", self._pca_projector)
示例4: commit
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def commit(self):
if self.data is None or self.cont_data is None:
self.Outputs.data.send(self.data)
self.Outputs.features.send(None)
self.Outputs.correlations.send(None)
return
attrs = [ContinuousVariable("Correlation"), ContinuousVariable("FDR")]
metas = [StringVariable("Feature 1"), StringVariable("Feature 2")]
domain = Domain(attrs, metas=metas)
model = self.vizrank.rank_model
x = np.array([[float(model.data(model.index(row, 0), role))
for role in (Qt.DisplayRole, CorrelationRank.PValRole)]
for row in range(model.rowCount())])
x[:, 1] = FDR(list(x[:, 1]))
# pylint: disable=protected-access
m = np.array([[a.name for a in model.data(model.index(row, 0),
CorrelationRank._AttrRole)]
for row in range(model.rowCount())], dtype=object)
corr_table = Table(domain, x, metas=m)
corr_table.name = "Correlations"
self.Outputs.data.send(self.data)
# data has been imputed; send original attributes
self.Outputs.features.send(AttributeList(
[self.data.domain[name] for name, _ in self.selection]))
self.Outputs.correlations.send(corr_table)
示例5: open_ds
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def open_ds(ds, filter=True):
table = Table(ds)
continuous_features = [a for a in table.domain.attributes if a.is_continuous]
if not filter or len(continuous_features) > 5:
print(ds)
new_table = Table(Domain(continuous_features, [table.domain.class_var]), table)
impute(new_table)
new_table.name = ds
return new_table
示例6: send_components
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def send_components(self):
components = None
if self.data is not None and self.projection is not None:
meta_attrs = [StringVariable(name='component')]
domain = Domain(self.effective_variables, metas=meta_attrs)
components = Table(domain, self._send_components_x(),
metas=self._send_components_metas())
components.name = "components"
self.Outputs.components.send(components)
示例7: temporal_datasets
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def temporal_datasets():
datasets_dir = '/Users/anze/dev/orange-astaric/orangecontrib/astaric/temporal'
for ds in [file for file in os.listdir(datasets_dir) if file.endswith('tab')]:
table = Table(os.path.join(datasets_dir, ds))
continuous_features = [a for a in table.domain.attributes if isinstance(a, ContinuousVariable)]
if len(continuous_features) > 5:
new_table = Table(Domain(continuous_features), table)
impute(new_table)
new_table.name = ds
yield new_table
示例8: apply
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def apply(self):
transformed = components = None
if self.data is not None:
self.data = Continuize(Impute(self.data))
lda = LinearDiscriminantAnalysis(solver='eigen', n_components=2)
X = lda.fit_transform(self.data.X, self.data.Y)
dom = Domain([ContinuousVariable('Component_1'),
ContinuousVariable('Component_2')],
self.data.domain.class_vars, self.data.domain.metas)
transformed = Table(dom, X, self.data.Y, self.data.metas)
transformed.name = self.data.name + ' (LDA)'
dom = Domain(self.data.domain.attributes,
metas=[StringVariable(name='component')])
metas = np.array([['Component_{}'.format(i + 1)
for i in range(lda.scalings_.shape[1])]],
dtype=object).T
components = Table(dom, lda.scalings_.T, metas=metas)
components.name = 'components'
self.send("Transformed data", transformed)
self.send("Components", components)
示例9: update_model
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def update_model(self):
super().update_model()
coef_table = None
if self.model is not None:
domain = Domain(
[ContinuousVariable("coef")], metas=[StringVariable("name")])
coefs = [self.model.intercept] + list(self.model.coefficients)
names = ["intercept"] + \
[attr.name for attr in self.model.domain.attributes]
coef_table = Table(domain, list(zip(coefs, names)))
coef_table.name = "coefficients"
self.Outputs.coefficients.send(coef_table)
示例10: update_model
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def update_model(self):
super().update_model()
coeffs = None
if self.model is not None:
if self.model.domain.class_var.is_discrete:
coeffs = create_coef_table(self.model)
else:
attrs = [ContinuousVariable("coef", number_of_decimals=7)]
domain = Domain(attrs, metas=[StringVariable("name")])
cfs = list(self.model.intercept) + list(self.model.coefficients)
names = ["intercept"] + \
[attr.name for attr in self.model.domain.attributes]
coeffs = Table(domain, list(zip(cfs, names)))
coeffs.name = "coefficients"
self.Outputs.coefficients.send(coeffs)
示例11: commit
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def commit(self):
alpha = self.alphas[self.alpha_index]
preprocessors = self.preprocessors
if self.data is not None and np.isnan(self.data.Y).any():
self.warning(0, "Missing values of target variable(s)")
if not self.preprocessors:
if self.reg_type == OWLinearRegression.OLS:
preprocessors = LinearRegressionLearner.preprocessors
elif self.reg_type == OWLinearRegression.Ridge:
preprocessors = RidgeRegressionLearner.preprocessors
else:
preprocessors = LassoRegressionLearner.preprocessors
else:
preprocessors = list(self.preprocessors)
preprocessors.append(RemoveNaNClasses())
args = {"preprocessors": preprocessors}
if self.reg_type == OWLinearRegression.OLS:
learner = LinearRegressionLearner(**args)
elif self.reg_type == OWLinearRegression.Ridge:
learner = RidgeRegressionLearner(alpha=alpha, **args)
elif self.reg_type == OWLinearRegression.Lasso:
learner = LassoRegressionLearner(alpha=alpha, **args)
learner.name = self.learner_name
predictor = None
coef_table = None
self.error(0)
if self.data is not None:
if not learner.check_learner_adequacy(self.data.domain):
self.error(0, learner.learner_adequacy_err_msg)
else:
predictor = learner(self.data)
predictor.name = self.learner_name
domain = Domain(
[ContinuousVariable("coef", number_of_decimals=7)],
metas=[StringVariable("name")])
coefs = [predictor.intercept] + list(predictor.coefficients)
names = ["intercept"] + \
[attr.name for attr in predictor.domain.attributes]
coef_table = Table(domain, list(zip(coefs, names)))
coef_table.name = "coefficients"
self.send("Linear Regression", learner)
self.send("Model", predictor)
self.send("Coefficients", coef_table)
示例12: prepare_components
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def prepare_components():
if self.placement in [self.Placement.Circular, self.Placement.LDA]:
attrs = [a for a in self.model_selected[:]]
axes = self.plotdata.axes
elif self.placement == self.Placement.PCA:
axes = self._pca.components_.T
attrs = [a for a in self._pca.orig_domain.attributes]
if self.placement != self.Placement.Projection:
domain = Domain([ContinuousVariable(a.name, compute_value=lambda _: None)
for a in attrs],
metas=[StringVariable(name='component')])
metas = np.array([["{}{}".format(self.Component_name[self.placement], i + 1)
for i in range(axes.shape[1])]],
dtype=object).T
components = Table(domain, axes.T, metas=metas)
components.name = 'components'
else:
components = self.projection
return components
示例13: create_scores_table
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def create_scores_table(self, labels):
model_list = self.ranksModel.tolist()
if not model_list or len(model_list[0]) == 1: # Empty or just n_values column
return None
domain = Domain([ContinuousVariable(label) for label in labels],
metas=[StringVariable("Feature")])
# Prevent np.inf scores
finfo = np.finfo(np.float64)
scores = np.clip(np.array(model_list)[:, 1:], finfo.min, finfo.max)
feature_names = np.array([a.name for a in self.data.domain.attributes])
# Reshape to 2d array as Table does not like 1d arrays
feature_names = feature_names[:, None]
new_table = Table(domain, scores, metas=feature_names)
new_table.name = "Feature Scores"
return new_table
示例14: commit
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def commit(self):
if not len(self.selected_rows):
self.Outputs.reduced_data.send(None)
self.Outputs.statistics.send(None)
return
# Send a table with only selected columns to output
variables = self.model.variables[self.selected_rows]
self.Outputs.reduced_data.send(self.data[:, variables])
# Send the statistics of the selected variables to ouput
labels, data = self.model.get_statistics_matrix(variables, return_labels=True)
var_names = np.atleast_2d([var.name for var in variables]).T
domain = Domain(
attributes=[ContinuousVariable(name) for name in labels],
metas=[StringVariable('Feature')]
)
statistics = Table(domain, data, metas=var_names)
statistics.name = '%s (Feature Statistics)' % self.data.name
self.Outputs.statistics.send(statistics)
示例15: create_scores_table
# 需要导入模块: from Orange.data import Table [as 别名]
# 或者: from Orange.data.Table import name [as 别名]
def create_scores_table(self, labels):
indices = [i for i, m in enumerate(self.measures)
if self.selectedMeasures.get(m.name, False)]
measures = [s.name for s in self.measures if
self.selectedMeasures.get(s.name, False)]
measures += [label for label in labels]
if not measures:
return None
features = [ContinuousVariable(s) for s in measures]
metas = [StringVariable("Feature name")]
domain = Domain(features, metas=metas)
scores = np.array([row for i, row in enumerate(self.measure_scores)
if i in indices or i >= len(self.measures)]).T
feature_names = np.array([a.name for a in self.data.domain.attributes])
# Reshape to 2d array as Table does not like 1d arrays
feature_names = feature_names[:, None]
new_table = Table(domain, scores, metas=feature_names)
new_table.name = "Feature Scores"
return new_table