WebashalarForML commited on
Commit
2aea707
·
verified ·
1 Parent(s): 7ae0a21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -8
app.py CHANGED
@@ -82,10 +82,10 @@ os.makedirs(app.config['MODEL_FOLDER'], exist_ok=True)
82
  # Prediction analysis models loaded from Hugging Face.
83
  src_path = hf_hub_download(
84
  repo_id="WebashalarForML/Diamond_model_",
85
- filename="models_list/mkble/StackingRegressor_best_pipeline_mkble_0_to_1.01.pkl",
86
  cache_dir=MODEL_FOLDER
87
  )
88
- dst_path = os.path.join(MODEL_FOLDER, "StackingRegressor_best_pipeline_mkble_0_to_1.01.pkl")
89
  shutil.copy(src_path, dst_path)
90
  makable_model = load(dst_path)
91
 
@@ -119,11 +119,25 @@ shutil.copy(src_path, dst_path)
119
  gia_model = load(dst_path)
120
 
121
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  print("makable_model type:", type(makable_model))
124
  print("grade_model type:", type(grade_model))
125
  print("bygrade_model type:", type(bygrade_model))
126
  print("gia_model type:", type(gia_model))
 
 
127
 
128
  #gia_model = load("models/StackingRegressor_best_pipeline_mkble_0_to_1.01.pkl")
129
  #grade_model = load("models/StackingRegressor_best_pipeline_grd_0_to_1.01.pkl")
@@ -278,13 +292,19 @@ def process_dataframe(df):
278
  # -------------------------
279
  try:
280
  x = df_pred.copy()
281
- df_pred['GIA_Predicted'] = pd.DataFrame(np.expm1(gia_model.predict(x)), columns=["Predicted"])
282
- df_pred['Grade_Predicted'] = pd.DataFrame(np.expm1(grade_model.predict(x)), columns=["Predicted"])
283
- df_pred['ByGrade_Predicted'] = pd.DataFrame(np.expm1(bygrade_model.predict(x)), columns=["Predicted"])
 
 
 
 
 
284
  df_pred['Makable_Predicted'] = pd.DataFrame(np.expm1(makable_model.predict(x)), columns=["Predicted"])
285
- df_pred['GIA_Diff'] = df_pred['EngAmt'] - df_pred['GIA_Predicted']
286
- df_pred['Grade_Diff'] = df_pred['EngAmt'] - df_pred['Grade_Predicted']
287
- df_pred['ByGrade_Diff'] = df_pred['EngAmt'] - df_pred['ByGrade_Predicted']
 
288
  df_pred['Makable_Diff'] = df_pred['EngAmt'] - df_pred['Makable_Predicted']
289
 
290
  for col in ['Tag', 'EngShp', 'EngQua', 'EngCol', 'EngCut', 'EngPol', 'EngSym', 'EngFlo', 'EngNts', 'EngMikly','EngBlk', 'EngWht', 'EngOpen', 'EngPav']:
 
82
  # Prediction analysis models loaded from Hugging Face.
83
  src_path = hf_hub_download(
84
  repo_id="WebashalarForML/Diamond_model_",
85
+ filename="models_list/mkble/DecisionTree_best_pipeline_mkble_with_assitance.pkl",
86
  cache_dir=MODEL_FOLDER
87
  )
88
+ dst_path = os.path.join(MODEL_FOLDER, "DecisionTree_best_pipeline_mkble_with_assitance.pkl")
89
  shutil.copy(src_path, dst_path)
90
  makable_model = load(dst_path)
91
 
 
119
  gia_model = load(dst_path)
120
 
121
 
122
+ #classsification model on the task
123
+ src_path = hf_hub_download(
124
+ repo_id="WebashalarForML/Diamond_model_",
125
+ filename="models_list/classification/3_pipeline.pkl",
126
+ cache_dir=MODEL_FOLDER
127
+ )
128
+ dst_path = os.path.join(MODEL_FOLDER, "3_pipeline.pkl")
129
+ shutil.copy(src_path, dst_path)
130
+ mkble_amt_class_model = load(dst_path)
131
+
132
+
133
+
134
 
135
  print("makable_model type:", type(makable_model))
136
  print("grade_model type:", type(grade_model))
137
  print("bygrade_model type:", type(bygrade_model))
138
  print("gia_model type:", type(gia_model))
139
+ print("================================")
140
+ print("mkble_amt_class_model type:", type(mkble_amt_class_model))
141
 
142
  #gia_model = load("models/StackingRegressor_best_pipeline_mkble_0_to_1.01.pkl")
143
  #grade_model = load("models/StackingRegressor_best_pipeline_grd_0_to_1.01.pkl")
 
292
  # -------------------------
293
  try:
294
  x = df_pred.copy()
295
+ #df_pred['GIA_Predicted'] = pd.DataFrame(np.expm1(gia_model.predict(x)), columns=["Predicted"])
296
+ #df_pred['Grade_Predicted'] = pd.DataFrame(np.expm1(grade_model.predict(x)), columns=["Predicted"])
297
+ #df_pred['ByGrade_Predicted'] = pd.DataFrame(np.expm1(bygrade_model.predict(x)), columns=["Predicted"])
298
+ df_pred['change_in_amt_mkble'] = pd.DataFrame(mkble_amt_class_model.predict(x), columns=["pred_change_in_eng_to_mkble"])
299
+ print("df_pred")
300
+ df_pred = df_pred[['Tag', 'EngCts', 'EngShp', 'EngQua', 'EngCol', 'EngCut', 'EngPol',
301
+ 'EngSym', 'EngFlo', 'EngNts', 'EngMikly', 'EngBlk', 'EngWht', 'EngOpen',
302
+ 'EngPav', 'EngAmt', 'change_in_amt_mkble']]
303
  df_pred['Makable_Predicted'] = pd.DataFrame(np.expm1(makable_model.predict(x)), columns=["Predicted"])
304
+
305
+ #df_pred['GIA_Diff'] = df_pred['EngAmt'] - df_pred['GIA_Predicted']
306
+ #df_pred['Grade_Diff'] = df_pred['EngAmt'] - df_pred['Grade_Predicted']
307
+ #df_pred['ByGrade_Diff'] = df_pred['EngAmt'] - df_pred['ByGrade_Predicted']
308
  df_pred['Makable_Diff'] = df_pred['EngAmt'] - df_pred['Makable_Predicted']
309
 
310
  for col in ['Tag', 'EngShp', 'EngQua', 'EngCol', 'EngCut', 'EngPol', 'EngSym', 'EngFlo', 'EngNts', 'EngMikly','EngBlk', 'EngWht', 'EngOpen', 'EngPav']: