Logistic Regression Exercise
Programming for Data Science is a subject we’ve designed to explore the various programming components of data science.
Keywords
data science, data analysis, programming, 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.