Arafath10 commited on
Commit
abb2214
1 Parent(s): cbf646f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +10 -6
main.py CHANGED
@@ -37,6 +37,12 @@ def train_the_model(data,page):
37
  selected_columns = ['customer_name', 'customer_address', 'customer_phone_no',
38
  'weight', 'cod', 'pickup_address', 'client_number', 'destination_city',
39
  'status_name']
 
 
 
 
 
 
40
  new_data_filled = new_data[selected_columns].fillna('Missing')
41
 
42
  # Encoding categorical data
@@ -64,17 +70,15 @@ def train_the_model(data,page):
64
  }
65
 
66
  # Initializing GridSearchCV
67
- grid_search = GridSearchCV(xgb_model, param_grid, cv=10, n_jobs=-1, scoring='accuracy')
68
 
69
  # Fitting GridSearchCV
70
  grid_search.fit(X_train, y_train)
71
 
72
- # Updating the model with the best estimator
73
- best_model = grid_search.best_estimator_
74
- dump(best_model, 'transexpress_xgb_model.joblib')
75
 
76
  # Making predictions and evaluating the model
77
- y_pred = best_model.predict(X_test)
78
  accuracy = accuracy_score(y_test, y_pred)
79
  classification_rep = classification_report(y_test, y_pred)
80
 
@@ -117,7 +121,7 @@ def train_the_model(data,page):
117
  xgb = XGBClassifier(use_label_encoder=False, eval_metric='logloss')
118
 
119
  # Setup GridSearchCV
120
- grid_search = GridSearchCV(xgb, param_grid, cv=10, n_jobs=-1, scoring='accuracy')
121
 
122
  # Fit the grid search to the data
123
  grid_search.fit(X_train, y_train)
 
37
  selected_columns = ['customer_name', 'customer_address', 'customer_phone_no',
38
  'weight', 'cod', 'pickup_address', 'client_number', 'destination_city',
39
  'status_name']
40
+
41
+
42
+
43
+
44
+
45
+
46
  new_data_filled = new_data[selected_columns].fillna('Missing')
47
 
48
  # Encoding categorical data
 
70
  }
71
 
72
  # Initializing GridSearchCV
73
+ grid_search = GridSearchCV(xgb_model, param_grid, cv=2, n_jobs=-1, scoring='accuracy')
74
 
75
  # Fitting GridSearchCV
76
  grid_search.fit(X_train, y_train)
77
 
78
+ dump(grid_search, 'transexpress_xgb_model.joblib')
 
 
79
 
80
  # Making predictions and evaluating the model
81
+ y_pred = grid_search.predict(X_test)
82
  accuracy = accuracy_score(y_test, y_pred)
83
  classification_rep = classification_report(y_test, y_pred)
84
 
 
121
  xgb = XGBClassifier(use_label_encoder=False, eval_metric='logloss')
122
 
123
  # Setup GridSearchCV
124
+ grid_search = GridSearchCV(xgb, param_grid, cv=2, n_jobs=-1, scoring='accuracy')
125
 
126
  # Fit the grid search to the data
127
  grid_search.fit(X_train, y_train)