concept score in category machine learning

appears as: scores, score, The score, score, scores, The scores
Grokking Machine Learning

This is an excerpt from Manning's book Grokking Machine Learning.

I try to compare machine learning with other subjects, such as music. Musical theory and practice are complicated subjects. But when we think of music, we do not think of scores and scales, we think of songs and melodies. And then I wondered, is machine learning the same? Is it really just a bunch of formulas and code, or is there a melody behind that?

Now we calculate score every sentence by adding the scores of all its words. If the score is positive, then we predict that the sentence is happy, and if the score is negative, we predict that it is sad. For example, let’s calculate it the sentences “I feel awful today” and “Everything is wonderful, I am delighted!. We can see that according to our model, the first sentence is sad, and the second one is happy.

Figure 4.18. As before, we have two misclassified points. The one on the left is not so badly classified, since it is close to the line, whereas the point in the right is far from the line, so it is badly misclassified. Notice that the score of the point in the left is 1, while the score of the point in the right is 6. Thus, the score is higher if the point is badly misclassified.

Furthermore, the scores are the following:

Finally, the prediction is simply 1 (happy) if the score is greater than or equal to zero, or 0 (sad) if the score is less than zero.

Let’s begin by coding the score function and the prediction. Both receive as input, the weights of the model and the bias, and the features of one data point. The score function returns the score that the model gives to that data point, and the prediction function returns a 1 if the score is greater than or equal to zero, and a 0 if the score is less than zero.

def score(weights, bias, features):
return features.dot(weights) + bias        #A
 

It’s also useful to code the error function for one point. Recall that the error is zero if the point is correctly classified, and the absolute value of the score if the point is misclassified. This function takes as input the weights and bias of the model, and the features and label of one data point.

Human-in-the-Loop Machine Learning

This is an excerpt from Manning's book Human-in-the-Loop Machine Learning.

Table 2.2: An example data file, with the ID, actual text, the Active Learning Samping strategy that was chosen, and the score for that sampling strategy.

Text ID

Text

Label

Sampling Strategy

Score

596124

Flood warning for Dolores Lake residents

1

low confidence

0.5872

58503

First aid workers arrive for earthquake relief

1

random

0.6234

23173

Cyclists are lost trying to navigate new bike lanes

0

random

0.0937

You can see in the example that a “Cyclist” is predicted with a 0.919 score. The scores that might have been “Pedestrian”, “Sign” or “Animal” are 0.014, 0.050 and 0.0168. The four scores total to 1.0, which makes the score like a probability or confidence. For example, you could interpret 0.919 as 91.9% confidence that object is a “Cyclist”. This interpretation is a simplification and it is unlikely that the model is correct 91.9% of the time that it sees objects like this one: it can be widely different. This won’t always matter. If you are ranking the predictions to find the “most uncertain” for human review, the actual uncertainty scores won’t matter. However, even the rank order can change depending on how you interpret the outputs from your model, so it is important to know exactly what statistics are generating these confidences.

In the rest of this chapter, you will learn how to take a set of predictions from your model and implement the most common algorithms for calculating “uncertainty” from those scores. But before you try to derive uncertainty from your models scores, you first need to be able to interpret the true meaning of the scores from your model.

def softmax(self, scores, base=math.e):
        """Returns softmax array for array of scores
       
        Converts a set of raw scores from a model (logits) into a
        probability distribution via softmax.
           
        The probability distribution will be a set of real numbers
        such that each is in the range 0-1.0 and the sum is 1.0.
   
        Assumes input is a pytorch tensor: tensor([1.0, 4.0, 2.0, 3.0])
            
        Keyword arguments:
            prediction -- a pytorch tensor of any positive/negative real numbers.
            base -- the base for the exponential (default e)
        """
        exps = (base**scores.to(dtype=torch.float)) # exponential for each value in array
        sum_exps = torch.sum(exps) # sum of all exponentials
 
        prob_dist = exps / sum_exps # normalize exponentials
        return prob_dist

Therefore, when softmax normalizes the exponentials by dividing by all of them: the division of exponentials is essentially subtracting the absolute value of the scores. In other words, it is only the relative difference between the scores from your model that counts with softmax, not their actual values.

We can get an intuition for this by seeing it graphically. Let’s take our scores from the example above of (1.0 ,4.0 ,2.0 ,3.0) and create scenarios where we add 10, 100 and -3 to each of them, so we are changing the sum of scores but keeping the difference between each score the exact same. As Figure 3.4 shows, the probability distributions are identical even though the raw scores differ considerably in each of the four sets of predictions. This is because the difference between each of the four raw scores was identical. The difference between the raw scores from the model is the only factor that counts in the final probability distribution under softmax. The difference between 4 and 3 will be the same as the difference between 104 and 103. This is an important limitation to understand. Clearly, the model that has scores of 104 vs 103 is a lot more uncertain than a model with scores of 4 vs 3, and more advanced uncertainty sampling will take this into account. But for the most common uncertainty sampling algorithms and for any black-box use of Machine Learning predictions, this assumption needs to be understood.

Figure 3.4: Softmax equivalencies: four different model scores that give identical probability distributions under softmax. The four softmax probability distributions are identical, despite coming from very different model scores, showing that it is only difference between the scores that matters. For example, the scores of (1, 4, 2, 3) will give the exact same probability distribution by softmax as (101, 104, 102, 103).
Machine Learning Bookcamp

This is an excerpt from Manning's book Machine Learning Bookcamp.

Instead of helping, the new features made the score a lot worse. Luckily, we have validation to help us spot this problem. In the next section, we will see why it happens and how to deal with it.

Figure 3.39 The score the model calculates for a customer with a month-to-month contract and 12 months of tenure


What does the ideal ranking model do?
A. When applied to the validation data, it scores the customers such that for non-churning customers the score is always lower than for churning ones.
B. It scores non-churning customers higher than churning ones.