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

changes #30

Open
wants to merge 11 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
Binary file added Advanced-Regression-Starter-Data/.DS_Store
Binary file not shown.

Large diffs are not rendered by default.

4,855 changes: 4,855 additions & 0 deletions Advanced-Regression-Starter-Data/Team_CCB2.ipynb

Large diffs are not rendered by default.

2,921 changes: 2,921 additions & 0 deletions Advanced-Regression-Starter-Data/df_test.csv

Large diffs are not rendered by default.

8,764 changes: 8,764 additions & 0 deletions Advanced-Regression-Starter-Data/df_train.csv

Large diffs are not rendered by default.

2,921 changes: 2,921 additions & 0 deletions Advanced-Regression-Starter-Data/submissionA.csv

Large diffs are not rendered by default.

2,921 changes: 2,921 additions & 0 deletions Advanced-Regression-Starter-Data/submissionB.csv

Large diffs are not rendered by default.

2,921 changes: 2,921 additions & 0 deletions Advanced-Regression-Starter-Data/submissionF.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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/CBB2.pkl')

print ('-'*40)
print ('Model successfully loaded')
Expand Down
Binary file added assets/trained-models/CBB2.pkl
Binary file not shown.
Binary file modified assets/trained-models/load_shortfall_simple_lm_regression.pkl
Binary file not shown.
6 changes: 4 additions & 2 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def _preprocess_data(data):
feature_vector_dict = json.loads(data)
# Load the dictionary as a Pandas DataFrame.
feature_vector_df = pd.DataFrame.from_dict([feature_vector_dict])
new_f = ['Madrid_wind_speed', 'Bilbao_wind_deg', 'Bilbao_pressure',
'Valencia_temp_min']

# ---------------------------------------------------------------
# NOTE: You will need to swap the lines below for your own data
Expand All @@ -58,7 +60,7 @@ 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']]
predict_vector = feature_vector_df[new_f]
# ------------------------------------------------------------------------

return predict_vector
Expand Down Expand Up @@ -107,4 +109,4 @@ def make_prediction(data, model):
# Perform prediction with model and preprocessed data.
prediction = model.predict(prep_data)
# Format as list for output standardisation.
return prediction[0].tolist()
return prediction[0].tolist()
5 changes: 3 additions & 2 deletions utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
# NOTE: When testing your instance of the API on a remote machine
# replace the URL below with its public IP:

# url = 'http://{public-ip-address-of-remote-machine}:5000/api_v0.1'
url = 'http://127.0.0.1:5000/api_v0.1'
url = 'http://54.91.80.97:5000/api_v0.1'
#url = 'http://127.0.0.1:5000/api_v0.1'

# Perform the POST request.
print(f"Sending POST request to web server API at: {url}")
Expand All @@ -53,3 +53,4 @@
print(f"API prediction result: {api_response.json()[0]}")
print(f"The response took: {api_response.elapsed.total_seconds()} seconds")
print("*"*50)

7 changes: 4 additions & 3 deletions utils/train_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
train = pd.read_csv('./data/df_train.csv')

y_train = train[['load_shortfall_3h']]
X_train = train[['Madrid_wind_speed','Bilbao_rain_1h','Valencia_wind_speed']]
X_train = train[['Madrid_wind_speed', 'Bilbao_wind_deg', 'Bilbao_pressure',
'Valencia_temp_min']]

# Fit model
lm_regression = LinearRegression(normalize=True)
print ("Training Model...")
lm_regression.fit(X_train, y_train)

# Pickle model for use within our API
save_path = '../assets/trained-models/load_shortfall_simple_lm_regression.pkl'
save_path = '../assets/trained-models/CBB2.pkl'
print (f"Training completed. Saving model to: {save_path}")
pickle.dump(lm_regression, open(save_path,'wb'))
pickle.dump(lm_regression, open(save_path,'wb'))