Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save time series to file #270

Merged
merged 9 commits into from
Jun 4, 2019
14 changes: 14 additions & 0 deletions scripts/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bz2
import pickle
import csv
from os import makedirs, path

from pandas import read_pickle
Expand Down Expand Up @@ -278,6 +279,19 @@ def run(self, predictors_to_run, emergence, normalized=False, train_test=False):
predicted_emergence = map_prediction_to_emergence_label(results, training_values, test_values,
predictors_to_run, test_terms=terms)

# save training_values to csv file
#
# training_values: csv file:
# {'term1': [0,2,4,6], 'term2': [2,4,1,3]} 'term1', 0, 2, 4, 6
# 'term2', 2, 4, 1, 3
#
filename = path.join('outputs', 'emergence', emergence + '_time_series.csv')
with open(filename, 'w') as f:
w = csv.writer(f)
for key, values in training_values.items():
my_list = ["'" + str(key) + "'"] + values
w.writerow(my_list)

html_results += report_predicted_emergence_labels_html(predicted_emergence)

html_results += report_prediction_as_graphs_html(results, predictors_to_run, self.__weekly_iso_dates,
Expand Down