Data Science Supervised Learning Models Questions and Answers 1 — Questions and Answers
Question 1: A data science team is building a model to predict the probability of customer churn (a binary outcome). The team decides to use a Logistic Regression model. Which of the following best describes the fundamental nature of Logistic Regression?
- It is a regression algorithm that fits a linear equation to continuous target variables.
- It is a classification algorithm that models the probability of a discrete outcome by applying a sigmoid function to a linear combination of features. (Correct answer)
- It is an algorithm that primarily functions by finding the optimal hyperplane to separate data points into different classes.
- It is a non-parametric algorithm that classifies new data points based on the majority class of its nearest neighbors.
Correct answer: It is a classification algorithm that models the probability of a discrete outcome by applying a sigmoid function to a linear combination of features.
Logistic Regression is fundamentally a classification algorithm, not a regression algorithm, despite its name. It is used to predict a binary or categorical outcome. It calculates the probability of an instance belonging to a certain class by passing a linear combination of the input features through a logistic (sigmoid) function, which outputs a value between 0 and 1.
Question 2: A team is developing a model to classify handwritten digits from 0 to 9. They are concerned about the model being too complex and memorizing the noise in the training data, which could lead to poor performance on new, unseen digits. Which supervised learning technique directly addresses this problem by adding a penalty term to the loss function to discourage overly complex models?
- Cross-Validation
- Feature Scaling
- Regularization (Correct answer)
- Dimensionality Reduction
Correct answer: Regularization
Regularization is a set of techniques used to prevent overfitting in machine learning models. It works by adding a penalty term to the model's loss function, which discourages the model from assigning excessive weight to its parameters, thereby reducing complexity. Common types include L1 (Lasso) and L2 (Ridge) regularization.
Question 3: Which of the following is a primary advantage of using a Random Forest model over a single Decision Tree?
- Higher interpretability and ease of visualization.
- Faster training time on large datasets.
- Reduced risk of overfitting and improved generalization. (Correct answer)
- Requires less data preprocessing, such as feature scaling.
Correct answer: Reduced risk of overfitting and improved generalization.
A Random Forest is an ensemble method that builds multiple decision trees and merges their predictions. This process of averaging predictions from many trees, each trained on a different subset of the data, significantly reduces the model's variance and makes it less prone to overfitting compared to a single, deep decision tree.
Question 4: A data scientist is working with a dataset that has a non-linear decision boundary between two classes. Which algorithm is particularly effective at handling such data by implicitly mapping the input features into a higher-dimensional space?
- Linear Regression
- Logistic Regression
- K-Nearest Neighbors (KNN)
- Support Vector Machine (SVM) with a non-linear kernel (Correct answer)
Correct answer: Support Vector Machine (SVM) with a non-linear kernel
Support Vector Machines (SVMs) can efficiently perform a non-linear classification using what is called the kernel trick. By applying a non-linear kernel function (like the Radial Basis Function or Polynomial kernel), the algorithm can find a separating hyperplane in a higher-dimensional space without explicitly computing the coordinates of the data in that space, making it effective for non-linear problems.
Question 5: A developer is building a simple recommendation system for an e-commerce site. The goal is to suggest products to a user based on the purchases of the 'k' most similar users. This approach is a direct application of which supervised learning algorithm?
- K-Nearest Neighbors (KNN) (Correct answer)
- Naive Bayes
- Decision Tree
- Support Vector Machine (SVM)
Correct answer: K-Nearest Neighbors (KNN)
The K-Nearest Neighbors (KNN) algorithm is a non-parametric method used for classification and regression. In a classification context, it classifies a new data point based on the features of its 'k' nearest neighbors in the training set. This principle is directly applicable to recommendation systems, where 'neighbors' are similar users and the 'class' is the product to recommend.
Question 6: The Naive Bayes classifier is a popular algorithm for text classification tasks like spam filtering. Its effectiveness relies on a simplifying assumption that is often not true in the real world. What is this 'naive' assumption?
- That all features follow a normal (Gaussian) distribution.
- That the dataset has no missing values.
- That all features are conditionally independent of each other, given the class. (Correct answer)
- That the model must be trained on a very large dataset to be effective.
Correct answer: That all features are conditionally independent of each other, given the class.
The 'naive' in Naive Bayes comes from its core assumption: that all input features are conditionally independent of each other given the class label. For example, in spam filtering, it assumes the presence of the word 'money' is independent of the presence of the word 'free', given that the email is spam. While this is rarely true, the algorithm often performs surprisingly well in practice.
A data science team is building a model to predict the probability of customer churn (a binary outcome).
The team decides to use a Logistic Regression model.
Which of the following best describes the fundamental nature of Logistic Regression?