From b2b0862c7da4fb6b6cc76cf3519628bf15440a91 Mon Sep 17 00:00:00 2001 From: Iddo-Smith Date: Tue, 25 May 2021 09:35:30 +0200 Subject: [PATCH 1/7] Update api.py --- api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.py b/api.py index a206495..89bf4c6 100644 --- a/api.py +++ b/api.py @@ -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/apples_simple_lm_regression.pkl') + path_to_model='assets/trained-models/mlr_model.pkl') print ('-'*40) print ('Model succesfully loaded') From 640dab23bd1e1bb8131a341e72decb81128045db Mon Sep 17 00:00:00 2001 From: Iddo-Smith Date: Tue, 25 May 2021 09:35:35 +0200 Subject: [PATCH 2/7] Update model.py --- model.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/model.py b/model.py index d72c14b..391f98b 100644 --- a/model.py +++ b/model.py @@ -48,7 +48,7 @@ def _preprocess_data(data): # Convert the json string to a python dictionary object feature_vector_dict = json.loads(data) # Load the dictionary as a Pandas DataFrame. - feature_vector_df = pd.DataFrame.from_dict([feature_vector_dict]) + df_train = pd.DataFrame.from_dict([feature_vector_dict]) # --------------------------------------------------------------- # NOTE: You will need to swap the lines below for your own data @@ -60,13 +60,25 @@ def _preprocess_data(data): # ----------- Replace this code with your own preprocessing steps -------- - - feature_vector_df = feature_vector_df[(feature_vector_df['Commodities'] == 'APPLE GOLDEN DELICIOUS')] - predict_vector = feature_vector_df[['Total_Qty_Sold','Stock_On_Hand']] + #Filtering Commodities for APPLE GOLDEN DELICIOUS + df_train = df_train[df_train['Commodities']=='APPLE GOLDEN DELICIOUS'] + + #Removing negative values + df_train = df_train._get_numeric_data() + df_train[df_train < 0] = 0 + + #Removing all infinity and 'not a number' values + df_train = df_train.replace([np.inf, -np.inf, 0], np.nan).dropna(axis=0) + + #Creating data sets + train = df_train[['Weight_Kg','Low_Price', 'High_Price', 'Sales_Total', 'Total_Qty_Sold','Total_Kg_Sold']] + + #feature_vector_df = feature_vector_df[(feature_vector_df['Commodities'] == 'APPLE GOLDEN DELICIOUS')] + #predict_vector = feature_vector_df[['Total_Qty_Sold','Stock_On_Hand']] # ------------------------------------------------------------------------ - return predict_vector + return train def load_model(path_to_model:str): """Adapter function to load our pretrained model into memory. From b2cdca1d9f0b5b2613c99f62711e5e24139a2f06 Mon Sep 17 00:00:00 2001 From: Iddo-Smith Date: Tue, 25 May 2021 15:45:10 +0200 Subject: [PATCH 3/7] Create mlr_model.pkl --- assets/trained-models/mlr_model.pkl | Bin 0 -> 532 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/trained-models/mlr_model.pkl diff --git a/assets/trained-models/mlr_model.pkl b/assets/trained-models/mlr_model.pkl new file mode 100644 index 0000000000000000000000000000000000000000..49209e68c172aacc33d03c51d7d369a69ed9cd3b GIT binary patch literal 532 zcmYk3&1(}u7{-%m)^4;lEr=Maka}qkF8zSwp^y!+7gtsrJoGl~$0R#;GZSWJixI@C z)Fx#_F>leMdMP3ZN)^1Ai-K4G0uP>g@;^`~+akV)8F=S;-uE{=8%KA{TqZ455^FK` zIJIIz^^ICA#Ic2ZPhe2Rt7)^2n;Z*47==E}+=DwXtwtL}B0?qR0d7m^Dw8ta@?vru zLr)n2Yj@D9ZW|QcWWE4bjZxIVo=o&8ZA9Q0DjzW1K%h?1q}A?N0pr+eC9xzP=UxZY z3B+;0sE|Afq~5LasSwmL8Xidc;AA$Tmi1u^>M-qO9b*%sF_jNxr;Ue}T;me-x(BaE zRCWnm*S+#bS9&-Z34X6OTiEzCV!nJnSg}$0)#n?Pw{B@~>P%FbdOEk$+&x>#;rq)M z$LV1ET|Xo<)d6UmGButcVS)uj$CV)hFZQ_J8I@`ylP^B5j=z6n!$Zxb^4z0q>6cAG zXfx3|1kq?z9MVS<|Ff4g&B@sOar)b0_4?PkTH5+$pZ_Vl``5nPU!JU-+rIF@zO}r+ zhsv+*%e&P&D?GMSn!>*{^yu=C;n9QN&(`lw9x@csVbo|H^E6Cl%v$pc);uJ>^%t-n B)9nBN literal 0 HcmV?d00001 From 0e21974598b2f730bc4e1e13d2733d8e437a2356 Mon Sep 17 00:00:00 2001 From: Iddo-Smith Date: Tue, 25 May 2021 16:21:39 +0200 Subject: [PATCH 4/7] Update request.py --- utils/request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/request.py b/utils/request.py index 79cfe84..94336b6 100644 --- a/utils/request.py +++ b/utils/request.py @@ -36,7 +36,7 @@ # 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://34.253.184.113/api_v0.1' # Perform the POST request. print(f"Sending POST request to web server API at: {url}") From 4196c8e7ef7faa2a2eb7f28fbd3c3fb4bf303f76 Mon Sep 17 00:00:00 2001 From: Iddo-Smith Date: Tue, 25 May 2021 16:31:41 +0200 Subject: [PATCH 5/7] Update request.py --- utils/request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/request.py b/utils/request.py index 94336b6..98d691c 100644 --- a/utils/request.py +++ b/utils/request.py @@ -36,7 +36,7 @@ # replace the URL below with its public IP: # url = 'http://{public-ip-address-of-remote-machine}:5000/api_v0.1' -url = 'http://34.253.184.113/api_v0.1' +url = 'http://34.253.184.113:5000/api_v0.1' # Perform the POST request. print(f"Sending POST request to web server API at: {url}") From 985eedfd9e925de39ca9672792447c56cd4ac4da Mon Sep 17 00:00:00 2001 From: Iddo-Smith Date: Tue, 25 May 2021 21:13:06 +0200 Subject: [PATCH 6/7] Update request.py --- utils/request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/request.py b/utils/request.py index 98d691c..eea2a0f 100644 --- a/utils/request.py +++ b/utils/request.py @@ -36,7 +36,7 @@ # replace the URL below with its public IP: # url = 'http://{public-ip-address-of-remote-machine}:5000/api_v0.1' -url = 'http://34.253.184.113:5000/api_v0.1' +url = 'http://34.244.117.108:5000/api_v0.1' # Perform the POST request. print(f"Sending POST request to web server API at: {url}") From 6b70520f25616e95d93f78b3958b0ea46ff7af56 Mon Sep 17 00:00:00 2001 From: Iddo-Smith Date: Wed, 26 May 2021 08:50:50 +0200 Subject: [PATCH 7/7] Update request.py --- utils/request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/request.py b/utils/request.py index eea2a0f..0d9773f 100644 --- a/utils/request.py +++ b/utils/request.py @@ -36,7 +36,7 @@ # replace the URL below with its public IP: # url = 'http://{public-ip-address-of-remote-machine}:5000/api_v0.1' -url = 'http://34.244.117.108:5000/api_v0.1' +url = 'http://34.245.158.7:5000/api_v0.1' # Perform the POST request. print(f"Sending POST request to web server API at: {url}")