本文整理汇总了Python中Orange.data.table.Table.from_domain方法的典型用法代码示例。如果您正苦于以下问题:Python Table.from_domain方法的具体用法?Python Table.from_domain怎么用?Python Table.from_domain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.data.table.Table
的用法示例。
在下文中一共展示了Table.from_domain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: received_table_load_votable
# 需要导入模块: from Orange.data.table import Table [as 别名]
# 或者: from Orange.data.table.Table import from_domain [as 别名]
def received_table_load_votable(self, private_key, sender_id, msg_id, mtype, parameters, extra):
"""
Read the received VOTable and broadcast.
"""
print("Call:", private_key, sender_id, msg_id, mtype, parameters, extra)
# Retrieve and read the VOTable.
url_table = parameters['url']
# sys.stdout is redirected by canvas.__main__ via redirect_stdout()
# in canvas.util.redirect to an
# Orange.canvas.application.outputview.TextStream object. This
# has a @queued_blocking flush(), which can result in an "Result not
# yet ready" RuntimeError from the QueuedCallEvent class.
# This exception is raised because astropy.io.votable.table uses
# astropy.utils.xml.iterparser, which uses astropy.utils.data,
# which uses the Spinner class from astropy.utils.console, which
# finally uses stdout to output a progress indicator.
# Orange has its own mechanisms for indicating progress, so it would
# perhaps be better to try to use that.
# For now, the Orange redirect of stdout is temporarily disabled
# while the votable is being parsed.
stdout_orange = sys.stdout
sys.stdout = sys.__stdout__
votable_tree = votable.parse(url_table)
sys.stdout = stdout_orange
print("VOTable Tree created")
votable_table = votable_tree.get_first_table()
#type(votable)
#<class 'astropy.io.votable.tree.Table'>
table = votable_table.to_table()
#type(table)
#<class 'astropy.table.table.Table'>
print("AstroPy table made")
# This does not allow classes.
if False:
# Convert the VOTable to a Domain.
# TODO: Y en metas
attributes = [
ContinuousVariable(name=column)
for column in table.columns
]
domain = Domain(attributes = attributes)
print("Domain made")
# Convert the VOTable to a Table
# Append the Table to LazyTable self.data.
# (Re)send self.data).
# TODO: Use from_domain() implicitly from __init__().
# TODO: Include support to stop_pulling immediately.
otable = Table.from_domain(
#otable = LazyTable.from_domain(
#otable = LazyTable(
domain = domain,
n_rows = len(table),
# stop_pulling = True,
)
otable.stop_pulling = True
# TODO: set widget_origin?
print("Orange Table initialized")
for i, variable in enumerate(otable.domain.variables):
otable.X[:,i] = table.columns[variable.name].data
attributes = [
ContinuousVariable(name=column)
for column in table.columns if not 'CLASS' in column
]
class_vars = [
DiscreteVariable(name=column, values=['alpha', 'beta'])
for column in table.columns if 'CLASS' in column
]
domain = Domain(
attributes=attributes,
class_vars=class_vars,
)
otable = Table.from_domain(
domain = domain,
n_rows = len(table),
)
otable.stop_pulling = True
print("Orange Table initialized")
for i, variable in enumerate(otable.domain.attributes):
otable.X[:,i] = table.columns[variable.name].data
for i, variable in enumerate(otable.domain.class_vars):
#otable.Y[:,i] = table.columns[variable.name].data
#otable.Y[:] = table.columns[variable.name].data
otable.Y[:] = table.columns[variable.name].data.round()
print("Orange Table filled")
if self.data is None:
self.data = otable
else:
self.data.extend(otable)
# TODO: Why doesn't this work?:
#.........这里部分代码省略.........