def _load_saved_predictions(self, existing_predictions, matrix_store):
index = matrix_store.matrix.index
score_lookup = {}
for prediction in existing_predictions:
score_lookup[(
prediction.entity_id,
prediction.as_of_date.date().isoformat()
)] = prediction.score
if 'as_of_date' in index.names:
score_iterator = (
score_lookup[(
entity_id,
datetime.strptime(dt, self.expected_matrix_ts_format).date().isoformat()
)]
for (entity_id, dt) in index
)
else:
as_of_date = matrix_store.metadata['end_time'].date().isoformat()
score_iterator = (score_lookup[(row, as_of_date)] for row in index)
return numpy.fromiter(score_iterator, float)
评论列表
文章目录