/Logistic_Regression_From_Scratch

Logistic regression is a statistical technique primarily used for binary classification tasks. It predicts the probability of a binary outcome based on one or more predictor variables. Unlike linear regression, which predicts continuous outcomes, logistic regression deals with categorical outcomes.

Primary LanguageJupyter Notebook

Logistic Regression for Classification🪂🪂

Logistic regression is a statistical method used for binary classification problems. It models the probability that a given input belongs to a particular class. It's a type of regression analysis where the dependent variable is categorical (binary in this case), unlike linear regression where the dependent variable is continuous.

TextClassificationExample_spam

In logistic regression, the logistic function (also known as the sigmoid function) is used to model the probability:

Screenshot 2024-04-06 224333_sigmoid

Cost Function

The cost function in logistic regression is used to measure the accuracy of the model's predictions. A common cost function for logistic regression is the binary cross-entropy loss function, also known as log loss:

Screenshot 2024-04-06 224100_cost

The goal is to minimize this cost function by adjusting the parameters during the training process using optimization algorithms like gradient descent.

Confusion Matrix:

A confusion matrix is a table that is often used to describe the performance of a classification model on a set of test data for which the true values are known. It allows visualization of the performance of an algorithm.

Here's how a confusion matrix is typically structured for binary classification:

Screenshot 2024-04-06 224321_matrix

True Positive (TP): The cases where the model correctly predicts the positive class.

True Negative (TN): The cases where the model correctly predicts the negative class.

False Positive (FP): The cases where the model incorrectly predicts the positive class.

False Negative (FN): The cases where the model incorrectly predicts the negative class.

From the confusion matrix, various performance metrics like accuracy, precision, recall, and F1-score can be calculated, which provide insight into the model's performance.

These topics covered provide a fundamental understanding of logistic regression for classification, the associated cost function, and how performance is evaluated using a confusion matrix.