This guide shows how to visualize the performance of your three breast cancer prediction models using the visualization pipeline.
The visualization system provides comprehensive performance analysis for:
- PyTorch Neural Network (NNModels.cpp)
- Scratch Neural Network (NNfromScratch.cpp)
- Custom Dataset Model (NNCustumDatasets.cpp)
- Shows the trade-off between true positive rate and false positive rate
- Includes AUC (Area Under Curve) scores for each model
- Higher AUC indicates better model performance
- Visual representation of model predictions vs actual values
- Shows true positives, true negatives, false positives, false negatives
- Includes accuracy scores for each model
- Side-by-side comparison of model accuracy
- Loss comparison across all models
- Easy identification of best performing model
- Simulated training accuracy over epochs
- Training loss progression
- Shows convergence behavior for each model
pip install -r requirements.txt# Build the project
mkdir build && cd build
cmake ..
make
# Run the export utility to generate model results
./BreastCancerPrediction -r=xml -ts=exportData# Run the visualization script
python visualize_models.pyAfter running the visualization script, you'll get these PNG files:
roc_curves.png- ROC curves with AUC scoresconfusion_matrices.png- Confusion matrices for all modelsperformance_comparison.png- Bar charts comparing metricstraining_curves.png- Training progress visualization
model_results.json- Exported model predictions and metrics- Generated automatically by running the export test case
# Install dependencies
pip install numpy pandas matplotlib seaborn scikit-learn
# Generate model data
./BreastCancerPrediction -r=xml -ts=exportData
# Create visualizations
python visualize_models.pyYou can modify visualize_models.py to:
- Change color schemes
- Add custom metrics
- Export to different formats
- Create interactive plots
- Top-left corner: Perfect classifier
- Diagonal line: Random classifier
- ** closer to top-left**: Better performance
- True Positive (TP): Correctly identified malignant
- True Negative (TN): Correctly identified benign
- False Positive (FP): Benign incorrectly classified as malignant
- False Negative (FN): Malignant incorrectly classified as benign
- Accuracy: Overall correct prediction percentage
- Loss: Training objective value (lower is better)
- AUC: Probability that model ranks random positive higher than random negative
-
Missing model_results.json
- Run
./BreastCancerPrediction -r=xml -ts=exportDatafirst to generate the data - Ensure the C++ models compile and run successfully
- Run
-
Python import errors
- Install all requirements:
pip install -r requirements.txt - Check Python version compatibility (3.7+ recommended)
- Install all requirements:
-
Display issues
- Ensure matplotlib backend is configured
- Try running in a Jupyter notebook for better interactivity
-
Build errors
- Check all dependencies are properly installed
- Verify CUDA paths in CMakeLists.txt are correct
- For large datasets, consider reducing the number of epochs
- Use GPU acceleration if available for faster model training
- Save intermediate results to avoid retraining
Modify the exportModelResults() function to include:
- Precision and recall
- F1-score
- Specificity and sensitivity
- Calibration curves
For real-time training visualization:
- Modify training loops to export intermediate results
- Update visualization script to read incremental data
- Use matplotlib animation features
Convert to a web-based dashboard using:
- Flask/FastAPI backend
- Plotly for interactive charts
- Bootstrap for responsive layout
Based on your README.md:
- PyTorch NN: 95.614% accuracy, 0.2664 loss
- Scratch NN: 92.105% accuracy, 0.218185 loss
- Custom Dataset: 94.7368% accuracy, 0.187598 loss
The visualizations will help you understand these metrics in detail and compare model behaviors across different evaluation criteria.