DEV Community

petercour
petercour

Posted on

2 1

False positives and ML

Computers sometimes come to the wrong conclusions. That's because of different reasons. The model (Machine Learning algorithm) may be incorrect, it may be not enough data and so on.

Lets take the simple flower data set and find the number of false positives. The Python program below calculates:

#!/usr/bin/python3
from sklearn import datasets
from sklearn.naive_bayes import GaussianNB

iris = datasets.load_iris()
gnb = GaussianNB()
y_pred = gnb.fit(iris.data, iris.target).predict(iris.data)
print("Number of false positives out of a total %d points : %d"  % (iris.data.shape[0],(iris.target != y_pred).sum()))
Enter fullscreen mode Exit fullscreen mode

That's 6 errors out of 150. You could say it's not much, but it depends on what kind of data you are dealing with and what kind of fault tolerance is allowed.

Predictive algorithms sometimes come to the wrong conclusion. There are 4 possible outcomes:

In an ideal situation, it would score 100% and there would be only true positives and true negatives. In practice algorithms often are less accurate.

For a toy program that's not such a big of a deal, but what if the algorithm is driving your car or flying the plane you sit in?

Indeed, an error in your self driving airplane could be a disaster:

You want to optimize your algorithm as much as possible, with lots of training and test data.

Related links:

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay