jaifar530 commited on
Commit
c724997
·
unverified ·
1 Parent(s): c69ae73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -25
app.py CHANGED
@@ -10,10 +10,8 @@ from sklearn.preprocessing import LabelEncoder
10
  import pickle
11
  import numpy as np
12
  from PIL import Image
13
- import joblib
14
  from joblib import load
15
 
16
- st.write(f"joblib version: {joblib.__version__}")
17
 
18
  # Custom headers for the HTTP request
19
  headers = {
@@ -276,32 +274,20 @@ if press_me_button:
276
  file_prefix = 'not_trancated_full_paragraph.xlsx'
277
 
278
  # Load the models and vectorizer
279
- #ridge_model = load_model(f"{file_prefix}_ridge_model.pkl")
280
-
281
- try:
282
- ridge_model = load(f"{file_prefix}_ridge_model.pkl")
283
- except Exception as e:
284
- st.write(f"Error loading the ridge model: {e}")
285
- exit(1)
286
 
287
- # extra_trees_model = load_model(f"{file_prefix}_extra_trees_model.pkl")
288
- try:
289
- extra_trees_model = load(f"{file_prefix}_extra_trees.pkl")
290
- except Exception as e:
291
- st.write(f"Error loading the extra_trees: {e}")
292
- exit(1)
293
-
294
- # vectorizer = load_model(f"{file_prefix}_vectorizer.pkl")
295
 
296
- try:
297
- with open(f"{file_prefix}_vectorizer.pkl", 'rb') as f:
298
- vectorizer = pickle.load(f)
299
- except Exception as e:
300
- st.write(f"Error loading the vectorizer: {e}")
301
- exit(1)
302
 
303
- # Transform the input
304
- user_input_transformed = vectorizer.transform([new_text])
305
 
306
  # Make predictions
307
  ridge_prediction = ridge_model.predict(user_input_transformed)
 
10
  import pickle
11
  import numpy as np
12
  from PIL import Image
 
13
  from joblib import load
14
 
 
15
 
16
  # Custom headers for the HTTP request
17
  headers = {
 
274
  file_prefix = 'not_trancated_full_paragraph.xlsx'
275
 
276
  # Load the models and vectorizer
277
+ ridge_model = load_model(f"{file_prefix}_ridge_model.pkl")
278
+ extra_trees_model = load_model(f"{file_prefix}_extra_trees_model.pkl")
279
+ vectorizer = load_model(f"{file_prefix}_vectorizer.pkl")
280
+ # Transform the input
281
+ user_input_transformed = vectorizer.transform(new_text)
 
 
282
 
283
+ # Load the saved models and vectorizer
 
 
 
 
 
 
 
284
 
285
+ # loaded_ridge_classifier = joblib.load(f'{excel_file_to_use}_ridge_model.pkl')
286
+ # loaded_extra_trees_classifier = joblib.load(f'{excel_file_to_use}_extra_trees_model.pkl')
287
+ # loaded_vectorizer = joblib.load(f'{excel_file_to_use}_vectorizer.pkl')
288
+
289
+ # user_input_vectorized = loaded_vectorizer.transform(user_input)
 
290
 
 
 
291
 
292
  # Make predictions
293
  ridge_prediction = ridge_model.predict(user_input_transformed)