本文整理汇总了Python中csv.DictReader.__next__方法的典型用法代码示例。如果您正苦于以下问题:Python DictReader.__next__方法的具体用法?Python DictReader.__next__怎么用?Python DictReader.__next__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类csv.DictReader
的用法示例。
在下文中一共展示了DictReader.__next__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: locations
# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __next__ [as 别名]
def locations(rack_locations_path=RACKS_LOCATION_CSV):
with open(rack_locations_path, 'r') as file:
csv_file = DictReader(file,
["latitude", "longitude", "icon", "desc", "racks_count", "parking_places"])
acc = []
csv_file.__next__() # Skip the header
for attributes in csv_file:
acc.append(RacksLocation(attributes))
return acc
示例2: __next__
# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __next__ [as 别名]
def __next__(self): # For Python 3
row = DictReader.__next__(self)
for (att, func) in self._casts.items():
row[att] = func(row[att])
return row
示例3: DictReader
# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __next__ [as 别名]
threshold = 0.5
label_path = path + 'validation.csv'
predict_path = path + 'submission.csv'
label_reader = DictReader(open(label_path))
predict_reader = DictReader(open(predict_path))
count = 0
y_true = []
y_pred = []
y_scores = []
for t, row in enumerate(label_reader):
predict = predict_reader.__next__()
actual = float(row['label'])
predicted = float(predict['prob'])
y_true.append(actual)
y_scores.append(predicted)
# 大于阈值的即视为点击
if predicted >= threshold:
y_pred.append(1)
else:
y_pred.append(0)
count += 1
# 计算性能指标
auc = roc_auc_score(y_true, y_scores)
logloss = log_loss(y_true, y_scores)