Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Working API #41

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# Load our model into memory.
# Please update this path to reflect your own trained model.
static_model = load_model(
path_to_model='assets/trained-models/load_shortfall_simple_lm_regression.pkl')
path_to_model='./assets/trained-models/linear_model.pkl')

print ('-'*40)
print ('Model successfully loaded')
Expand Down Expand Up @@ -62,4 +62,4 @@ def model_prediction():
# This will allow Flask to automatically restart itself everytime you
# update your API code.
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=False)
app.run(host='0.0.0.0', port=5000, debug=True)
Binary file added assets/trained-models/linear_model.pkl
Binary file not shown.
Binary file not shown.
2,921 changes: 2,921 additions & 0 deletions df_test.csv

Large diffs are not rendered by default.

8,764 changes: 8,764 additions & 0 deletions df_train.csv

Large diffs are not rendered by default.

Empty file added linear_model.pkl
Empty file.
12 changes: 10 additions & 2 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
import pandas as pd
import pickle
import json
from matplotlib.pyplot import axis
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import *

def _preprocess_data(data):

"""Private helper function to preprocess data for model prediction.

NB: If you have utilised feature engineering/selection in order to create
Expand Down Expand Up @@ -58,10 +62,14 @@ def _preprocess_data(data):
# ---------------------------------------------------------------

# ----------- Replace this code with your own preprocessing steps --------
predict_vector = feature_vector_df[['Madrid_wind_speed','Bilbao_rain_1h','Valencia_wind_speed']]
# ------------------------------------------------------------------------




feature_vector_df.fillna(0, inplace = True)
predict_vector = feature_vector_df[['Madrid_temp', 'Barcelona_temp_min', 'Bilbao_pressure', 'Seville_temp', 'Valencia_wind_speed']]
return predict_vector
# ------------------------------------------------------------------------

def load_model(path_to_model:str):
"""Adapter function to load our pretrained model into memory.
Expand Down
Loading