Logistic Regression Exercise

Programming for Data Science is a subject we’ve designed to explore the various programming components of data science.
Author

Juma Shafara

Published

August 29, 2024

Keywords

data science, data analysis, programming, dataidea

Photo by DATAIDEA

Week 5: Logistic Regression

1. Making Predictions in Logistic Regression

  • Exercise: Implement a logistic regression model to classify data into two classes. Use a synthetic dataset with two features and evaluate the model’s accuracy using confusion matrix.

2. Logistic Regression and Bad Initialization Values

  • Exercise: Train a logistic regression model with various initialization strategies. Analyze how different initial weights affect the convergence and performance of the model.

3. Cross Entropy Loss Function

  • Exercise: Implement the cross-entropy loss function from scratch for a logistic regression model. Compare its output with PyTorch’s built-in torch.nn.CrossEntropyLoss function.

4. Softmax Activation in 1 Dimension

  • Exercise: Implement the softmax activation function for a vector of logits in a 1D tensor. Use this function to convert raw model outputs into probabilities and interpret the results.

What’s on your mind? Put it in the comments!

Back to top