本文整理汇总了Python中bigml.fields.Fields.items方法的典型用法代码示例。如果您正苦于以下问题:Python Fields.items方法的具体用法?Python Fields.items怎么用?Python Fields.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bigml.fields.Fields
的用法示例。
在下文中一共展示了Fields.items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_input_fields
# 需要导入模块: from bigml.fields import Fields [as 别名]
# 或者: from bigml.fields.Fields import items [as 别名]
def get_input_fields(resource, referrer=None):
"""New list of input fields
"""
if referrer is None:
referrer = {}
input_fields_ids = resource.get('input_fields', [])
if referrer:
referrer_input_fields = [[]]
# compare fields by name
resource_fields = Fields(
{'resource': resource['resource'], 'object': resource})
referrer_fields = Fields(
{'resource': referrer['resource'], 'object': referrer})
input_fields = [resource_fields.field_name(field_id) for field_id in
input_fields_ids]
input_fields = sorted(input_fields)
referrer_type = get_resource_type(referrer)
if referrer_type == 'dataset':
referrer_fields = referrer_fields.preferred_fields()
referrer_fields = sorted([field['name']
for _, field in referrer_fields.items()])
else:
referrer_fields = sorted(referrer_fields.fields_by_name.keys())
# check referrer input fields to see if they are equal
referrer_input_fields.append(referrer_fields)
# check whether the resource has an objective field not included in
# the input fields list
resource_type = get_resource_type(resource)
if resource_type == 'model':
objective_id = resource.get('objective_field')
try:
objective_id = objective_id.get('id')
except AttributeError:
pass
referrer_objective = resource_fields.field_name(
objective_id)
referrer_input_fields.append([name for name in referrer_fields
if name != referrer_objective])
if input_fields in referrer_input_fields:
return []
return input_fields_ids