本文整理汇总了Python中Library.create_vector方法的典型用法代码示例。如果您正苦于以下问题:Python Library.create_vector方法的具体用法?Python Library.create_vector怎么用?Python Library.create_vector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library
的用法示例。
在下文中一共展示了Library.create_vector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: import Library [as 别名]
# 或者: from Library import create_vector [as 别名]
team_prob = probabilities['team_prob']
priors = probabilities['priors']
f.close()
correct = [0, 0]
# Init. confusion matrix
confusion_matrix = {x:{y:0 for y in result_lst} for x in result_lst}
for data in test_data:
answer = data.pop('result')
max_res = None
max_p = 1
teams, vector = lib.create_vector(data)
for res in result_lst:
p = priors[res]
try:
# Loop through the "team given result" probabilities
for x in range(len(teams)):
# Add probability of team given result
p += math.log(team_prob[res][team_lst[x]][teams[x]])
# Loop through the "feature given team given res" probabilities
for x in range(len(teams)):
for y in range(len(vector)):
# Add probability of feature given team given res
p += math.log(feature_prob[res][teams[x]][team_lst[x]][feature_lst[y]][vector[y]])
except KeyError as e: