Arafath10 commited on
Commit
06aeeae
·
verified ·
1 Parent(s): d7263a4

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -10
main.py CHANGED
@@ -28,13 +28,6 @@ app.add_middleware(
28
 
29
  def train_the_model(data,page):
30
  if page==2:
31
- # Function to evaluate the model
32
- def evaluate_model(model, X_test, y_test):
33
- y_pred = model.predict(X_test)
34
- accuracy = accuracy_score(y_test, y_pred)
35
- print("Accuracy:", accuracy)
36
- print("Classification Report:\n", classification_report(y_test, y_pred))
37
- return accuracy
38
 
39
  new_data = data
40
  encoders = load('encoders.joblib')
@@ -54,11 +47,17 @@ def train_the_model(data,page):
54
  new_data_filled[col] = encoder.transform(new_data_filled[col])
55
  X_new = new_data_filled.drop('status.name', axis=1)
56
  y_new = new_data_filled['status.name']
 
 
 
57
  xgb_model.fit(X_new, y_new)
58
- dump(xgb_model, 'xgb_model.joblib')
 
59
  print("Model updated with new data.")
60
- updated_model_accuracy = evaluate_model(xgb_model, X_test, y_test)
61
- print("Updated model accuracy:", updated_model_accuracy)
 
 
62
 
63
  else:
64
  data = data
 
28
 
29
  def train_the_model(data,page):
30
  if page==2:
 
 
 
 
 
 
 
31
 
32
  new_data = data
33
  encoders = load('encoders.joblib')
 
47
  new_data_filled[col] = encoder.transform(new_data_filled[col])
48
  X_new = new_data_filled.drop('status.name', axis=1)
49
  y_new = new_data_filled['status.name']
50
+
51
+ X_train, X_test, y_train, y_test = train_test_split(X_new,y_new, test_size=0.2, random_state=42)
52
+
53
  xgb_model.fit(X_new, y_new)
54
+ dump(xgb_model,'xgb_model.joblib')
55
+
56
  print("Model updated with new data.")
57
+ y_pred = xgb_model.predict(X_test)
58
+ accuracy = accuracy_score(y_test, y_pred)
59
+ print("Accuracy:", accuracy)
60
+ print("Classification Report:\n", classification_report(y_test, y_pred))
61
 
62
  else:
63
  data = data