Sitemap

100 Days of Data Science: Day 2:

3 min readJul 14, 2024

--

Hey there! Day 2 of our interview preperation.Let’s get into it!

Press enter or click to view image in full size

1. Can you apply linear regression to non-linear features?
At first glance, you might think no. But if you have exponential data, you can take the log of it and then apply linear regression. Problem solved!

2. Explain how L1 Regularization affects feature selection:
L1 regularization adds the absolute value of weights to the loss function. This can shrink some weights to zero, effectively removing those features from the model. Think of it as an automatic feature selector!

3. Explain how L2 Regularization affects feature selection: L2 regularization minimizes the sum of the squared weights. This penalty keeps the weights smaller, which helps in preventing overfitting. It’s like keeping your model in check!

4. How does lambda affect regularization?
A small lambda means a complex model with higher weights, leading to overfitting. A lambda of 0 acts like OLS (Ordinary Least Squares), while a large lambda forces weights down, resulting in underfitting. It’s all about finding that sweet spot!

Get Lets Data Science’s stories in your inbox

Join Medium for free to get updates from this writer.

5. Why Support Vector Regression?
In simple linear regression, we focus on minimizing the error rate. In SVR, we fit the error within a specified threshold, allowing for a more robust model. It’s all about flexibility!

6. What is the bias-variance trade-off?
A complex model typically has low variance but high bias, leading to overfitting. Conversely, a simple model has high variance and low bias. The goal is to find a balance where both bias and variance errors are minimized. It’s a balancing act!

7. What is a confusion matrix?
The confusion matrix is a 2x2 table that summarizes the outcomes of a binary classifier. It helps derive key metrics like error rate, accuracy, specificity, sensitivity, precision, and recall. Consider it your model’s report card!

8. Basic measures from the confusion matrix:
— Error Rate: (FP + FN) / (P + N)
— Accuracy: (TP + TN) / (P + N)
— Sensitivity (Recall): TP / P
— Specificity: TN / N
— Precision: TP / (TP + FP)
— F-Score: (1 + b) * (PREC * REC) / (b² * PREC + REC), where b is typically 0.5, 1, or 2.

9. Difference between linear regression and logistic regression:
Linear regression is for numerical data, while logistic regression is designed for classification tasks. The process is similar; once you obtain the numerical value, you apply the sigmoid function to convert it into a probability between 0 and 1. Logistic regression handles binary dependent variables, while linear regression is used for continuous ones. Simple, right?

10. How do you handle categorical variables?
We often encode them using one-hot encoding or label encoding. Use one-hot encoding when order doesn’t matter and drop the first column to avoid the dummy variable trap, which helps prevent correlation in features. For ordinal data, label encoding is the way to go. Choosing the right strategy is key!

That’s a wrap for Day 2 ❤ ❤

--

--