Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Practical Guide to Applied Conformal Prediction in Python

You're reading from  Practical Guide to Applied Conformal Prediction in Python

Product type Book
Published in Dec 2023
Publisher Packt
ISBN-13 9781805122760
Pages 240 pages
Edition 1st Edition
Languages
Author (1):
Valery Manokhin Valery Manokhin
Profile icon Valery Manokhin

Table of Contents (19) Chapters

Preface 1. Part 1: Introduction
2. Chapter 1: Introducing Conformal Prediction 3. Chapter 2: Overview of Conformal Prediction 4. Part 2: Conformal Prediction Framework
5. Chapter 3: Fundamentals of Conformal Prediction 6. Chapter 4: Validity and Efficiency of Conformal Prediction 7. Chapter 5: Types of Conformal Predictors 8. Part 3: Applications of Conformal Prediction
9. Chapter 6: Conformal Prediction for Classification 10. Chapter 7: Conformal Prediction for Regression 11. Chapter 8: Conformal Prediction for Time Series and Forecasting 12. Chapter 9: Conformal Prediction for Computer Vision 13. Chapter 10: Conformal Prediction for Natural Language Processing 14. Part 4: Advanced Topics
15. Chapter 11: Handling Imbalanced Data 16. Chapter 12: Multi-Class Conformal Prediction 17. Index 18. Other Books You May Enjoy

Building computer vision classifiers using conformal prediction

Let’s illustrate the application of conformal prediction to computer vision in practice. We will use a notebook from the book repository available at https://github.com/PacktPublishing/Practical-Guide-to-Applied-Conformal-Prediction/blob/main/Chapter_09.ipynb. This notebook extensively uses notebooks from Anastasios Angelopolous’ Conformal Prediction repo at https://github.com/aangelopoulos/conformal-prediction.

After loading the data, set up the problem and define the desired coverage and the number of points in the calibration set:

n_cal = 1000
alpha = 0.1

The softmax scores were split into the calibration and test datasets, obtaining calibration and test labels:

idx = np.array([1] * n_cal + [0] * (smx.shape[0]-n_cal)) > 0
np.random.seed(42)
np.random.shuffle(idx)
cal_smx, test_smx = smx[idx,:], smx[~idx,:]
cal_labels, test_labels = labels[idx], labels[~idx]

The test dataset contains 49...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}