本文整理汇总了Python中bigml.fields.Fields.pair方法的典型用法代码示例。如果您正苦于以下问题:Python Fields.pair方法的具体用法?Python Fields.pair怎么用?Python Fields.pair使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bigml.fields.Fields
的用法示例。
在下文中一共展示了Fields.pair方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ensemble
# 需要导入模块: from bigml.fields import Fields [as 别名]
# 或者: from bigml.fields.Fields import pair [as 别名]
def test_ensemble(self,test_file):
assert self.authenticated, 'Not authenticated!'
# download a local copy of the ensemble
self.logger.info('Creating local ensemble')
local_ensemble = Ensemble(self.ensemble_res,api=self.api)
# make the Fields object
source = self.api.get_source(self.source_res)
fields = Fields(source['object']['fields'])
self.logger.info('Reading test data and generating predictions')
true_labels = []
predict_labels = []
pr = Profile()
pr.enable()
with open(test_file) as fid:
test_reader = csv.reader(fid)
# skip the header line
test_reader.next()
for row in test_reader:
row_list = [val for val in row]
true_labels.append(row_list.pop())
instance = fields.pair(row_list)
predict_labels.append(local_ensemble.predict(instance,
by_name=False,
method=1))
pr.disable()
ps = Stats(pr)
self.predict_time = ps.total_tt
# eval_args = {'combiner':1}
# evaluation = self.api.create_evaluation(self.ensemble_res,test_data,eval_args)
# check_resource(evaluation['resource'],self.api.get_evaluation)
# evaluation = self.api.get_evaluation(evaluation['resource'])
# matrix = evaluation['object']['result']['model']['confusion_matrix']
# self.predict_time = evaluation['object']['status']['elapsed']/1000
if self.regression:
self.results = (predict_labels,true_labels)
else:
self.results = make_confusion_matrix(true_labels,predict_labels)