|
|
| import pandas as pd |
| import joblib |
| import os |
| from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score |
|
|
| |
| MODEL_PATH = 'tourism_project/best_random_forest_model.joblib' |
| X_TEST_PATH = 'tourism_project/data/X_test.csv' |
| Y_TEST_PATH = 'tourism_project/data/y_test.csv' |
|
|
| def evaluate_model(): |
| print("Loading model and test data...") |
| model = joblib.load(MODEL_PATH) |
| X_test = pd.read_csv(X_TEST_PATH) |
| y_test = pd.read_csv(Y_TEST_PATH) |
|
|
| |
| print("Making predictions on test data...") |
| y_pred = model.predict(X_test) |
|
|
| |
| accuracy = accuracy_score(y_test, y_pred) |
| precision = precision_score(y_test, y_pred) |
| recall = recall_score(y_test, y_pred) |
| f1 = f1_score(y_test, y_pred) |
| roc_auc = roc_auc_score(y_test, y_pred) |
|
|
| print(f" |
| Model Evaluation Results:") |
| print(f"Accuracy: {accuracy:.4f}") |
| print(f"Precision: {precision:.4f}") |
| print(f"Recall: {recall:.4f}") |
| print(f"F1-Score: {f1:.4f}") |
| print(f"ROC AUC Score: {roc_auc:.4f}") |
|
|
| if __name__ == '__main__': |
| evaluate_model() |
|
|