Logistic Regression for Image Classification Using OpenCV
machinelearningmastery.com
machinelearningmastery.com
For more typical image classification problems, you can get >90% of the way for image classification on any arbitrary image dataset and with much less code by using CLIPVision image embeddings as a model input to your classification algorithm of choice.
In the final code sample, OpenCV is a) loading the image, which could be done with PIL and b) training the model, when the demo imports sklearn which has its own battle-tested logistic regression implementation.
There's a lot of useful things that can be done with machine learning and computer vision, but this article is a bad demo of it that won't work on any other real-world dataset and is out-of-date with more modern CV approaches. Their previous article is a good explanation of the math behind logistic regression, though: https://machinelearningmastery.com/logistic-regression-in-op...
It only takes a few minutes to train with default parameters and will have >99% accuracy on the MNIST test set.
Traditional classification algorithms but not deep learning such as Support Vector Machines and Random Forests perform a lot better on MNIST, up to 97% test set accuracy compared to the 88% from logistic regression in this post. Check the Original MNIST benchmarks here: http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/#
Here are some resources I've found which don't suck if you actually want to learn this stuff:
https://ai.stanford.edu/courses/ <- Stanford's AI course materials.
https://karpathy.ai/zero-to-hero.html <- Karpathy's "neural networks - zero to hero". The other ones (eg the transformers ones on youtube also seem excellent to me after an initial skim although I haven't got to actually working through them yet).
https://ocw.mit.edu/search/?q=artificial%20intelligence and https://ocw.mit.edu/search/?q=machine%20learning (MIT's relevant opencourseware)
https://probml.github.io/pml-book/book2.html (Draft book "Probabilistic machine learning: Advanced topics" by Kevin Murphy) <- looks seriously excellent although I've really only taken a cursory dip into it so far. He's also got 2 other books at https://probml.github.io/pml-book/ which are more introductory in nature which I expect are probably great too.