Question

In: Computer Science

Logistic Regression and the Cross Entropy Cost. What are they similar in? Give me please some...

Logistic Regression and the Cross Entropy Cost. What are they similar in? Give me please some explanation or examples, that shows their similarity

Solutions

Expert Solution

Logistic regression:

Logistic regression is just a generalized linear model, so there is a linear regression lurking in here whose errors are supposed to be normally distributed, and from which you can get confidence intervals in the usual way.

It can also be defined as Logistic regression is a classification algorithm used to assign observations to a discrete set of classes. Unlike linear regression which outputs continuous number values, logistic regression transforms its output using the logistic sigmoid function to return a probability value which can then be mapped to two or more discrete classes.

Cross-Entropy :

Cross-entropy cost measures the performance of a classification model whose output is a probability value between 0 and 1. Cross-entropy loss increases as the predicted probability diverge from the actual label

For logistic regression, it’s a bit more complicated. The cost function we use is called Cross-Entropy, also known as Log Loss. Cross-entropy loss is split into two separate cost functions when dealing with a binary classification

The cross-entropy between two probability distributions p and q over the same underlying set of events measures the average number of bits needed to identify an event drawn from the set if a coding scheme used for the set is optimized for an estimated probability distribution q, rather than the true distribution p.

Cross-entropy loss can be divided into two separate cost functions: one for y=1 and one for y=0

for example:

def costFunction(features, labels, weights): # define a cost function

    observations = len(labels)

predictions = predict(features, weights)

class1Cost = -labels*np.log(predictions)    # It will take error when table is 1

class2Cost = (1-labels)*np.log(1-predictions) # It will take error when label is 0

cost = class1Cost + class2Cost # It will find the sum of two costs

cost = cost.sum() / observations # it will give average cost

return cost

The above code will return the cost of the feature.


Related Solutions

In the exer- cise, you will implement logistic regression algorithm using SGA, similar to the logistic...
In the exer- cise, you will implement logistic regression algorithm using SGA, similar to the logistic regression algorithm that you have seen in class. You will work with the datasets attached to the assignment and complete the lo- gisticRegression.py file to learn the coefficients and predict binary class labels. The data comes from breast cancer diagnosis where each sample (30 features) is labeled by a diagnose: either M (malignant) or B (be- nign) (recorded in the 31-st column in the...
For what type of dependent variable is logistic regression appropriate? Give an example of such a...
For what type of dependent variable is logistic regression appropriate? Give an example of such a variable. In what metric are logistic regression coefficients? What can we do to them to make them more interpretable, and how would we interpret the resulting translated coefficients? (Understanding and Using Statistics for Criminology and Criminal Justice)
When should logistic regression be used for data analysis? What is the assumption of logistic regression?...
When should logistic regression be used for data analysis? What is the assumption of logistic regression? How to explain odds ratio?
What are the similarities and differences between multiple linear regression, and logistic regression? Please consider Typical...
What are the similarities and differences between multiple linear regression, and logistic regression? Please consider Typical Application (used when), assumptions needed, Data Type
What is binary logistic regression, and how to use it?
What is binary logistic regression, and how to use it?
What is binary logistic regression, and how to use it?
What is binary logistic regression, and how to use it?
Please describe Logistic Regression classification methods and its usage?
Please describe Logistic Regression classification methods and its usage?
Please find one medical dataset that is suitable for correlation, logistic regression and linear regression.
Please find one medical dataset that is suitable for correlation, logistic regression and linear regression.
What is the difference and similarities between SVM and Logistic Regression?
What is the difference and similarities between SVM and Logistic Regression?
Please give me some economics experience example you have done.
Please give me some economics experience example you have done.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT