Complete implementation of assignment_2 model pipeline and metrics #79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
I am adding performance metric calculations, including negative log loss, ROC AUC, accuracy, and balanced accuracy for test data. Additionally, I’m restructuring the code to display fold-level results in a more readable, sorted format.
What did you learn from the changes you have made?
From these changes, I learned how to use cross_validation to extract and evaluate fold-level metrics across different folds, and I gained a better understanding of calculating metrics for model performance on test data.
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
Yes, I considered using a separate function to handle the metric calculations and display results for both training and testing, to make the code more modular and reusable. This approach could improve readability, especially as the complexity of metrics increases.
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
Yes, I faced some challenges with the cross_validate function, especially in sorting results and calculating fold-level metrics directly. There were also issues with handling prediction probability arrays in metrics like roc_auc and log_loss. I addressed these by adjusting the data passed to predict_proba and breaking down the metric calculations step-by-step.
How were these changes tested?
These changes were tested by running the pipeline on a sample of test data and checking that each metric calculation matched the expected output. I also verified each step's output to ensure that the metrics align with known values for model performance.
A reference to a related issue in your repository (if applicable)
Refer to sections 3a, 3b, and 4 in the lab materials within the repository.
Checklist
I can confirm that my changes are working as intended
Code is free of syntax errors and runs without issues
Metrics display correctly for each fold and are sorted by neg_log_loss for clarity
Code is modular and well-documented for easy future adjustments
Output is formatted to improve readability and analysis