def write_scores(scores,
output=sys.stdout,
do_normalize=True,
default_score=0):
"""
Writes the given segment scores to a submission file. If a expected segment is missing, it will be filled with
a default value.
:param scores: A list of score dictionaries. Each if the inner dictionaries should have two keys: 'clip' and
'preictal'. 'clip' is the name of the segment and 'preictal' is the class probability of that
segment being preictal.
:param output: The file-like object which the scores should be written to.
:param do_normalize: If True, scores will be normalized per subject.
:param default_score: The value to use for missing segments in the *scores* list.
:return: None. The scores are written to the output file-like object.
"""
submissions = scores_to_submission(scores, do_normalize=do_normalize, default_score=default_score)
csv_writer = csv.DictWriter(output, fieldnames=['clip', 'preictal'])
csv_writer.writeheader()
csv_writer.writerows(submissions)
评论列表
文章目录