Classifiers and Thresholds
Build a classifier to simulate a custom machine and learn the importance of thresholds through the process.
Today, machines play a crucial role in handling tasks that would be costly, time-consuming, or even impractical for humans to perform manually. From filtering emails to detecting fraud in financial transactions, these automated systems rely on machine learning to make accurate and efficient decisions. One of the most fundamental problems in machine learning is classification, a type of supervised learning where the goal is to assign an input to one of a predefined set of categories or classes.
In this lesson, we will explore the core concepts of classification, including how models process inputs to make predictions and how the decision threshold determines the final classification.
Classifier
Every machine takes an input, performs its respective function on that input, and produces an output. When this machine is configured/trained to predict a category/class label from a prespecified finite set of categories, it’s called a classifier.
For example, suppose we have a set of inputs, x, and the machine gives an output of either 1 or 0:
x (Input) | y (Output) |
4 | 1 |
-2 | 0 |
-3 | 1 |
7 | 0 |
Here, the possible class labels are 0 and 1, and the classifier’s job is to assign the correct label to each input.
Assume we have a library of pre-trained models, represented by three potential functions: , , and . Our task is to determine which of these models (functions) best simulates the behavior of the desired machine.
Try any integer
Now that you’ve tested the code above for each required entry, answer the following question:
Which function is best suited for our machine?
Prediction confidence
Prediction confidence is the level of certainty that a machine learning model has in its predictions, and it can be expressed through hard or soft predictions.
Hard prediction
Predicting actual class labels or is called hard prediction. It seems to be a desirable property of a classifier, but it’s generally difficult to model. This is because the classifiers are mathematical functions, and the constraint of discrete values on the output makes the function challenging to be approximated from data.
Soft prediction
Soft prediction is the prediction of class probabilities (a continuous value between 0 and 1) rather than the actual label values. This probability represents the model’s confidence score.
In our example, the functions are updated to return the probability () that the input ...