Memuat
Memuat
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Class Deep Learning CNN-LSTM Pneumonia Detection #6: Clinical Evaluation (Sensitivity, Specificity, ROC-AUC) & Grad-CAM”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
Here is the final result, the Grad-CAM map showing which lung regions the CNN-LSTM model pays attention to when deciding between pneumonia or normal. Previously, we compared the hybrid model with another CNN-Base using sensitivity, specificity, and ROC curve, metrics used in medical research. Let's get started. Hello, welcome to the final episode of the hybrid CNN-LSTM model series for early detection of lung diseases. In the medical field, accuracy alone is not enough. We need to know how many sick patients are successfully detected, how many healthy individuals are wrongly diagnosed, and whether the model is looking at reasonable image regions. In this episode, we evaluate both models using linear metrics, then open up the model's black box with Grad-CAM. Create an evaluation .py file
We load both trained models, another CNN-Base and the best CNN-LSTM, then create a prediction function that returns pneumonia probability via Softmax. The report function calculates the confusion matrix and 4 metrics. Accuracy, sensitivity is the percentage of pneumonia patients detected, specificity is the percentage of healthy individuals correctly identified as normal, and AUC. Results on the test data, the other CNN-Base has an accuracy of about 90.7 percent, sensitivity 96.7, specificity 80.8, and AUC 0.966.
CNN-LSTM is slightly better, with an accuracy of 91 percent, sensitivity 98.5, and AUC 0.97. High sensitivity is very important for screening, because patients who pass through undetected are far more dangerous. As a trade-off, specificity slightly decreases. The threshold of 0.5 may not necessarily be the best.
We find the optimal threshold using the UDEN index, which is sensitivity plus specificity minus 1, on validation data, not test data, to be fair. The result is about 0.48, very close to 0.5, so the metrics are almost the same. Then we draw the confusion matrix for both models and their ROC curves. The CNN-LSTM curve is slightly closer to the top-left corner, consistent with its AUC value.
Now Grad-CAM. Create a gradecam.py file The idea is to look at the last convolutional layer, calculate the gradient score of the class against its activation, then average the gradient as the weight for each channel. Summing weighted activations gives a heat map of the image regions most influencing the decision. We attach forward hook and backward hook on the ReLU layer of the third block to capture the activation and gradient. We select 4 pneumonia images and 2 normal images that were correctly predicted, then display their heat maps above the X-ray.
In some cases of pneumonia, the model pays attention to the cloudy areas of the lungs. However, in some images, the model also looks at the middle part of the chest, the heart area, and the mediastinum. This is the purpose of Grad-CAM in research, proving that the model looks at relevant areas, as well as detecting shortcuts that need to be improved, for example, with lung segmentation or more data.
Done, and congratulations! We have completed the entire series, including the radiograph dataset, CLAHI preprocessing and augmentation, CNN Baseline, Hybrid CNN-LSTM architecture, training with class weights and early stopping, up to clinical evaluation and Grad-CAM. These results can directly become the framework for BAP methodology and results for a thesis or dissertation. To continue, try higher image resolution, transfer learning, or cross-validation. Thank you for learning with us. Are you currently working on a thesis, dissertation, or AI research in the field of medical imaging? Cerdas Inovasi Digital helps implement deep learning, from CNN, LSTM, hybrid models, up to Grad-CAM interpretation and result writing, as well as opening deep learning courses with Pythor. Want to master the entire series, from the radiograph dataset to evaluation and Grad-CAM? All 6 episodes, complete with step-by-step PDF guides and source code, are available for premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with the 12-month package, or pay once Rp999.000 for lifetime access. Want just one class? Buy a single class with lifetime access. Subscribe now at the premium page cerdasinovasidigital.com Contact our WhatsApp, or visit cerdasinovasidigital.com Thank you for watching, see you in the next episode. Thank you for watching, see you in the next episode.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →