# Error calculation in Logistic Regression

Data Science Asked on December 11, 2020

Suppose we have a linear regression model that predicts an item’s price. If the item’s prediction is 8 USD and the actual value is 10 USD, then it is clear that the error is pow(10-8, 2)=4.
But how is the error calculated when there are more than two classes?

For example, the model that predicts the numbers trained on the MNIST dataset. In this case we have 10 labels that mark the actual values – range between 0-9. But if we use the sigmoid function for the activation then the range for possible predicted values is between 0-1. Right? How can we compare these values if they are on a different scale? For example, the sigmoid function outputs the values 0.5 and we have to compare it to 3?

The problem here is that you are comparing a regression problem with a classification problem. Classifying MNIST digits is treated as a classification task because it is assumed that predicting the wrong digit is always bad, regardless of how "close" you are to the right answer. One could even argue that predicting a 9 instead of a 3 is a better guess than predicting 5 for instance.

If you want really want to compare the values, I would simply pick the class with the highest value and use this as the regression prediction.

Answered by Valentin Calomme on December 11, 2020

## Related Questions

### Does label encoding an entire dataset cause data leakage?

3  Asked on August 26, 2021

### Why is Spark’s LinearRegressionWithSGD very slow locally?

1  Asked on August 26, 2021 by nikola-stojiljkovic

### Random Forest with 2D features

1  Asked on August 26, 2021 by beinje

### Public datasets that show “cyclical” behavior

1  Asked on August 26, 2021 by tom-solberg

### Help interpreting GAN output, and how to fix it?

1  Asked on August 25, 2021

### conversion of dictionary to json to be sent to requests.post

1  Asked on August 25, 2021

### Understanding The Vertical and Horizontal stack in conditional gated Pixelcnn paper

2  Asked on August 25, 2021

### Calculating the entropy of a neural network

1  Asked on August 25, 2021 by donkey

### Logistic regression does cannot converge without poor model performance

2  Asked on August 25, 2021

### Handling features with multiple values per instance in Python for Machine Learning model

1  Asked on August 25, 2021 by sums22

### pandas data frame doesn’t show any thing ,when view as data frame in pycharm

2  Asked on August 25, 2021 by khk

### Mathematics: Writing down a three-class classifier confusion matrix

1  Asked on August 25, 2021

### Checkerboard artefacts vs distinct objects in GANs

0  Asked on August 25, 2021

### What is the best to identify the proper hierarchy of this data?

1  Asked on August 25, 2021 by steven-cunden

### Interpreting the results based on Granger Causality test

1  Asked on August 25, 2021

### Pandas copy() different columns from different dataframes to a new dataframe

1  Asked on August 25, 2021

### Time series normalization using min max technique

2  Asked on August 24, 2021

### Magenta MusicVAE/GrooVAE conditioning

0  Asked on August 24, 2021 by johannes-ebster

### Knowledge Graph as an input to a neural network

1  Asked on August 24, 2021 by anascmidt

### Passing Dependency/Constituency trees to a Neural Machine Translator

1  Asked on August 24, 2021