-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev
- Loading branch information
Showing
13 changed files
with
230 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
external_models/naive_python_model_with_mlproject_file/MLproject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: naive_python | ||
|
||
docker_env: | ||
image: python:3.10 | ||
|
||
#python_env: python_env.yaml | ||
|
||
entry_points: | ||
train: | ||
parameters: | ||
train_data: path | ||
model_output_file: path | ||
command: "python train.py {train_data} {model_output_file}" | ||
predict: | ||
parameters: | ||
future_data: path | ||
model: path | ||
out_file: path | ||
command: "python predict.py {future_data} {model} {out_file}" |
6 changes: 6 additions & 0 deletions
6
external_models/naive_python_model_with_mlproject_file/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
|
||
name: naive_python_model | ||
train_command: "python mock_predictor_script.py train {train_data} {model}" | ||
predict_command: "python mock_predictor_script.py predict {future_data} {model} {out_file}" | ||
data_type: HealthData |
11 changes: 11 additions & 0 deletions
11
external_models/naive_python_model_with_mlproject_file/future_data.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
,time_period,rainfall,mean_temperature,max_temperature,location,disease_cases | ||
0,2012-08,20,1,1,oslo, | ||
1,2012-09,20,1,1,oslo, | ||
2,2012-10,20,1,1,oslo, | ||
3,2012-11,20,1,1,oslo, | ||
4,2012-12,20,1,1,oslo, | ||
0,2012-08,1,100,1,bergen, | ||
1,2012-09,1,100,1,bergen, | ||
2,2012-10,1,100,1,bergen, | ||
3,2012-11,1,100,1,bergen, | ||
4,2012-12,1,100,1,bergen, |
47 changes: 47 additions & 0 deletions
47
external_models/naive_python_model_with_mlproject_file/mock_predictor_script.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pickle | ||
|
||
import climate_health | ||
from climate_health.datatypes import ClimateData, ClimateHealthTimeSeries | ||
from climate_health.predictor.naive_predictor import NaivePredictor, MultiRegionNaivePredictor | ||
import typer | ||
|
||
from climate_health.spatio_temporal_data.temporal_dataclass import DataSet | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def train(train_data_set: str, model_output_file: str): | ||
predictor = MultiRegionNaivePredictor() | ||
train_data = DataSet.from_csv(train_data_set, ClimateHealthTimeSeries) | ||
predictor.train(train_data) | ||
|
||
# pickle predictor | ||
with open(model_output_file, 'wb') as f: | ||
pickle.dump(predictor, f) | ||
|
||
|
||
@app.command() | ||
def predict(future_climate_data_set: str, model_file: str, output_file: str): | ||
with open(model_file, 'rb') as f: | ||
predictor = pickle.load(f) | ||
|
||
future_climate_data = DataSet.from_csv(future_climate_data_set, ClimateData) | ||
predictions = predictor.predict(future_climate_data) | ||
print(predictions) | ||
predictions.to_csv(output_file) | ||
|
||
|
||
@app.command() | ||
def predict_values(train_data_set: str, future_climate_data_set: str, output_file: str): | ||
predictor = MultiRegionNaivePredictor() | ||
train_data = DataSet.from_csv(train_data_set, ClimateHealthTimeSeries) | ||
future_climate_data = DataSet.from_csv(future_climate_data_set, ClimateData) | ||
predictor.train(train_data) | ||
predictions = predictor.predict(future_climate_data) | ||
print(predictions) | ||
predictions.to_csv(output_file) | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
Binary file added
BIN
+271 Bytes
external_models/naive_python_model_with_mlproject_file/naive_python_model.model
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
external_models/naive_python_model_with_mlproject_file/predictions.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
,time_period,disease_cases,location | ||
0,2012-08,1.0,bergen | ||
0,2012-08,20.0,oslo |
15 changes: 15 additions & 0 deletions
15
external_models/naive_python_model_with_mlproject_file/training_data.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
,time_period,rainfall,mean_temperature,disease_cases,location | ||
0,2012-01,1,1,20,oslo | ||
1,2012-02,1,1,20,oslo | ||
2,2012-03,1,1,20,oslo | ||
3,2012-04,1,1,20,oslo | ||
4,2012-05,1,1,20,oslo | ||
5,2012-06,1,1,20,oslo | ||
6,2012-07,1,1,20,oslo | ||
0,2012-01,100,1,1,bergen | ||
1,2012-02,100,1,1,bergen | ||
2,2012-03,100,1,1,bergen | ||
3,2012-04,100,1,1,bergen | ||
4,2012-05,100,1,1,bergen | ||
5,2012-06,100,1,1,bergen | ||
6,2012-07,100,1,1,bergen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.