Skip to content

Commit 9673744

Browse files
authored
Merge branch 'master' into prescriptor-assignment
2 parents 1f167eb + 16f502c commit 9673744

File tree

9 files changed

+25
-52
lines changed

9 files changed

+25
-52
lines changed

Predictor_submission_template.ipynb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
" :param end_date: day on which to stop making predictions, as a string, format YYYY-MM-DDD\n",
298298
" :param path_to_ips_file: path to a csv file containing the intervention plans between inception date (Jan 1 2020)\n",
299299
" and end_date, for the countries and regions for which a prediction is needed\n",
300-
" :param output_file_path: path to file to which to save the the predictions\n",
300+
" :param output_file_path: path to file to save the predictions to\n",
301301
" :return: Nothing. Saves the generated predictions to an output_file_path CSV file\n",
302302
" with columns \"CountryName,RegionName,Date,PredictedDailyNewCases\"\n",
303303
" \"\"\"\n",
@@ -321,7 +321,8 @@
321321
"cell_type": "markdown",
322322
"metadata": {},
323323
"source": [
324-
"## Display predictions"
324+
"## Display predictions\n",
325+
"If prediction worked ok, it generated the `output_file` file, that we can read like that:"
325326
]
326327
},
327328
{
@@ -330,9 +331,6 @@
330331
"metadata": {},
331332
"outputs": [],
332333
"source": [
333-
"# If prediction worked ok, it generated the following file:\n",
334-
"\n",
335-
"# That we can read like this:\n",
336334
"prediction_output_df = pd.read_csv(output_file,\n",
337335
" parse_dates=['Date'],\n",
338336
" encoding=\"ISO-8859-1\")\n",

codefresh.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Copyright 2020 (c) Cognizant Digital Business, Evolutionary AI. All rights reserved. Issued under the Apache 2.0 License.
22
version: '1.0'
33
steps:
4+
start_clean:
5+
title: Clean up CodeFresh volume
6+
# Images come from hierarchy at: https://github.com/docker-library/python
7+
image: python:3.6-slim
8+
commands:
9+
- rm -rf '${{CF_REPO_NAME}}'
10+
411
clone_main_repo:
512
type: git-clone
613
title: "Clone repo"
@@ -23,3 +30,9 @@ steps:
2330
working_directory: ${{CF_REPO_NAME}}
2431
commands:
2532
- nosetests -v
33+
34+
end_clean:
35+
title: Clean up CodeFresh volume
36+
image: python:3.6-slim
37+
commands:
38+
- rm -rf '${{CF_REPO_NAME}}'

examples/predictors/linear/predict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def predict(start_date: str,
4444
:param end_date: day on which to stop making predictions, as a string, format YYYY-MM-DDD
4545
:param path_to_ips_file: path to a csv file containing the intervention plans between inception date (Jan 1 2020)
4646
and end_date, for the countries and regions for which a prediction is needed
47-
:param output_file_path: path to file to which to save the the predictions
47+
:param output_file_path: path to file to save the predictions to
4848
:return: Nothing. Saves the generated predictions to an output_file_path CSV file
4949
with columns "CountryName,RegionName,Date,PredictedDailyNewCases"
5050
"""

examples/predictors/lstm/predict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def predict(start_date: str,
3030
:param end_date: day on which to stop making predictions, as a string, format YYYY-MM-DDD
3131
:param path_to_ips_file: path to a csv file containing the intervention plans between inception date (Jan 1 2020)
3232
and end_date, for the countries and regions for which a prediction is needed
33-
:param output_file_path: path to file to which to save the the predictions
33+
:param output_file_path: path to file to save the predictions to
3434
:return: Nothing. Saves the generated predictions to an output_file_path CSV file
3535
with columns "CountryName,RegionName,Date,PredictedDailyNewCases"
3636
"""

examples/predictors/lstm/tests/test_xprize_predictor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
END_DATE = "2020-08-04"
2121

2222

23-
class TestMultiplicativeEvaluator(unittest.TestCase):
23+
class TestXPrizePredictor(unittest.TestCase):
2424

2525
@classmethod
2626
def setUpClass(cls):
2727
# Download and cache the raw data
28-
latest = True
29-
if not os.path.exists(DATA_FILE) or latest:
30-
urllib.request.urlretrieve(DATA_URL, DATA_FILE)
28+
urllib.request.urlretrieve(DATA_URL, DATA_FILE)
3129

3230
def test_predict(self):
3331
predictor = XPrizePredictor(PREDICTOR_WEIGHTS, DATA_FILE, CUTOFF_DATE)

examples/predictors/lstm/xprize_predictor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import os
44
import urllib.request
55

6+
# Suppress noisy Tensorflow debug logging
7+
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
8+
69
# noinspection PyPep8Naming
710
import keras.backend as K
811
import numpy as np

predict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def predict(start_date: str,
1414
:param end_date: day on which to stop making predictions, as a string, format YYYY-MM-DDD
1515
:param path_to_ips_file: path to a csv file containing the intervention plans between inception date (Jan 1 2020)
1616
and end_date, for the countries and regions for which a prediction is needed
17-
:param output_file_path: path to file to which to save the the predictions
17+
:param output_file_path: path to file to save the predictions to
1818
:return: Nothing. Saves the generated predictions to an output_file_path CSV file
1919
with columns "CountryName,RegionName,Date,PredictedDailyNewCases"
2020
"""

robojudge.ipynb

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -163,45 +163,6 @@
163163
"# actual_npis_df.to_csv(npis_file_name, index=False)"
164164
]
165165
},
166-
{
167-
"cell_type": "code",
168-
"execution_count": null,
169-
"metadata": {},
170-
"outputs": [],
171-
"source": [
172-
"hist_end_date_str = \"2020-09-30\"\n",
173-
"hist_end_date = pd.to_datetime(hist_end_date_str, format='%Y-%m-%d')"
174-
]
175-
},
176-
{
177-
"cell_type": "code",
178-
"execution_count": null,
179-
"metadata": {},
180-
"outputs": [],
181-
"source": [
182-
"historical_npis_df = npis_df[npis_df.Date <= hist_end_date]\n",
183-
"historical_npis_df.sample(3)"
184-
]
185-
},
186-
{
187-
"cell_type": "code",
188-
"execution_count": null,
189-
"metadata": {},
190-
"outputs": [],
191-
"source": [
192-
"# hist_file_name = \"validation/data/\" + hist_end_date.strftime('%Y-%m-%d') + \"_historical_ip.csv\"\n",
193-
"# # hist_file_name"
194-
]
195-
},
196-
{
197-
"cell_type": "code",
198-
"execution_count": null,
199-
"metadata": {},
200-
"outputs": [],
201-
"source": [
202-
"# historical_npis_df.to_csv(hist_file_name, index=False)"
203-
]
204-
},
205166
{
206167
"cell_type": "markdown",
207168
"metadata": {},

validation/scenario_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def generate_scenario(start_date_str, end_date_str, raw_df, countries=None, scen
8484
if start_date < INCEPTION_DATE:
8585
raise ValueError(f"start_date {start_date} must be on or after inception date {INCEPTION_DATE}")
8686

87-
ips_df = raw_df[ID_COLS + NPI_COLUMNS]
87+
ips_df = raw_df[ID_COLS + NPI_COLUMNS].copy()
8888

8989
# Filter on countries
9090
if countries:

0 commit comments

Comments
 (0)