1.
Comparison of Linear Regression and Logistic Regression
Linear regression and logistic regression are commonly used predictive models in data
analytics. However, they are used for different types of prediction problems depending on
the nature of the outcome variable.
Aspect Linear Regression Logistic Regression
Purpose Predict continuous Predict categorical
numerical values outcomes
Dependent Variable Continuous values such as Binary or categorical
revenue or sales outcomes
Output Numeric prediction Probability between 0 and
1
Model Function Linear equation Logistic (sigmoid) function
Typical Use Cases Sales forecasting, demand Customer churn prediction,
prediction fraud detection
2. Business Scenario Where a Decision Tree is Preferred
A decision tree is often preferred when the relationship between variables is complex or
non-linear and when the model must be easily interpretable.
For example, a bank deciding whether to approve or reject loan applications may use a
decision tree. The model can consider factors such as income, credit score, employment
status, and existing debts. The tree structure clearly shows the decision rules used to
approve or reject loans.
This transparency makes decision trees easier for managers and stakeholders to
understand compared to models like logistic regression.
3. Advantages of Random Forest Over a Single Decision Tree
• Higher prediction accuracy due to combining results from multiple trees.
• Reduced overfitting because predictions are averaged across many models.
• Better performance with large datasets and many variables.
• Ability to measure feature importance.
4. Difference Between R² and Accuracy
Metric R² (R-Squared) Accuracy
Used For Regression models Classification models
Meaning Explains how much Percentage of correct
variance is captured by the predictions
model
Value Range 0 to 1 (sometimes 0 to 1
negative)
Interpretation Higher value indicates Higher value indicates
better model fit better prediction
performance
5. Preprocessing Steps Before Building Predictive Models in Scikit-
Learn
• Handling missing data by removing rows or filling values using mean, median, or
mode.
• Encoding categorical variables using techniques such as label encoding or one-hot
encoding.
• Feature scaling using methods such as StandardScaler or MinMaxScaler.
• Splitting the dataset into training and testing sets.
• Detecting and removing outliers that may affect model performance.