Regression Analysis Overview
- 30Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary purpose of regression analysis?
What is the primary purpose of regression analysis?
30 questions
- 1
What is the primary purpose of regression analysis?
- A
To visualize data in scatter plots and histograms
- B
To understand the relationship between two or more variables by creating a predictive model
- C
To replace missing values in a dataset
- D
To classify data points into discrete categories
Correct answer
BTo understand the relationship between two or more variables by creating a predictive model
Explanation
Regression analysis creates a predictive model that quantifies the relationship between a dependent variable and one or more independent variables, enabling predictions and understanding of trends.
- A
- 2
In linear regression, what does the equation y=mx+c represent?
- A
A sigmoid function used for classification
- B
A hyperplane in multiple dimensions
- C
A straight line where m is the slope and c is the intercept
- D
A quadratic curve where m is the curvature and c is the vertex
Correct answer
CA straight line where m is the slope and c is the intercept
Explanation
In simple linear regression, the model is a straight line defined by y=mx+c, where m (slope) indicates the change in y per unit change in x, and c (intercept) is the value of y when x=0.
- A
- 3
What is the role of the 'residual' in linear regression?
- A
The slope of the best-fit line
- B
The difference between the observed value and the predicted value
- C
The average of all observed values
- D
The coefficient of determination
Correct answer
BThe difference between the observed value and the predicted value
Explanation
A residual is the difference between the actual observed value and the value predicted by the regression model. It measures the error for each data point.
- A
- 4
The best-fit line in linear regression is found by minimizing which quantity?
- A
The mean absolute error (MAE)
- B
The R-squared value
- C
The total sum of squares (TSS)
- D
The residual sum of squares (RSS)
Correct answer
DThe residual sum of squares (RSS)
Explanation
The best-fit line minimizes the sum of squared residuals (RSS), which quantifies the overall discrepancy between observed and predicted values.
- A
- 5
Simple linear regression differs from multiple linear regression in that:
- A
Simple linear regression is used for classification, while multiple is for regression
- B
Simple linear regression requires normally distributed errors, while multiple does not
- C
Simple linear regression uses one independent variable, while multiple uses two or more
- D
Simple linear regression cannot have an intercept term
Correct answer
CSimple linear regression uses one independent variable, while multiple uses two or more
Explanation
Simple linear regression models the relationship between one dependent and one independent variable. Multiple linear regression extends this to two or more independent variables.
- A
- 6
In multiple linear regression, what does the coefficient bi represent when the model is y=b0+b1x1+b2x2+…?
- A
The correlation between xi and y
- B
The probability that xi is a significant predictor
- C
The expected change in y for a one-unit change in xi, holding all other variables constant
- D
The overall importance of the i-th variable relative to the target
Correct answer
CThe expected change in y for a one-unit change in xi, holding all other variables constant
Explanation
Each coefficient bi indicates how much the dependent variable y is expected to increase (or decrease) when that independent variable increases by one unit, assuming all other predictors remain unchanged.
- A
- 7
What is the primary purpose of splitting data into training and testing sets?
- A
To increase the size of the dataset for better training
- B
To evaluate how well the model generalizes to new, unseen data
- C
To reduce the number of features in the model
- D
To ensure all data points are used for both training and testing
Correct answer
BTo evaluate how well the model generalizes to new, unseen data
Explanation
Splitting data into training and testing sets allows us to assess model performance on data not used during training, which indicates how well the model will perform on new data and helps detect overfitting.
- A
- 8
The coefficient of determination (R2) measures:
- A
The correlation between the dependent and independent variables
- B
The proportion of variance in the dependent variable explained by the independent variables
- C
The slope of the regression line
- D
The average error between predicted and actual values
Correct answer
BThe proportion of variance in the dependent variable explained by the independent variables
Explanation
R2 represents the fraction of the total variance in the dependent variable that is explained by the regression model. It ranges from 0 to 1, with higher values indicating a better fit.
- A
- 9
Adjusted R2 is preferred over R2 because it:
- A
Is easier to interpret than R2
- B
Measures the root mean square error
- C
Always increases when a new variable is added
- D
Penalizes the inclusion of irrelevant independent variables
Correct answer
DPenalizes the inclusion of irrelevant independent variables
Explanation
Adjusted R2 adjusts for the number of predictors in the model, increasing only if the new variable improves the model more than expected by chance. It thus discourages adding useless variables.
- A
- 10
In logistic regression, the output of the model is transformed into a probability using:
- A
The linear function mx+c
- B
The exponential function emx+c
- C
The sigmoid function 1+e−(mx+c)1
- D
The logarithmic function ln(mx+c)
Correct answer
CThe sigmoid function 1+e−(mx+c)1
Explanation
Logistic regression applies the sigmoid (logistic) function to the linear combination mx+c to map any real-valued number into a probability between 0 and 1.
- A
- 11
Which cost function is commonly minimized in logistic regression?
- A
Mean absolute error (MAE)
- B
Residual sum of squares (RSS)
- C
Log loss (cross-entropy)
- D
Mean squared error (MSE)
Correct answer
CLog loss (cross-entropy)
Explanation
Logistic regression uses log loss (also known as cross-entropy) as the cost function because it quantifies the difference between predicted probabilities and actual binary labels more effectively than MSE.
- A
- 12
When classes are imbalanced in a classification problem, the model tends to:
- A
Be biased toward the majority class
- B
Perform equally well on both classes
- C
Become completely random
- D
Automatically adjust the decision threshold
Correct answer
ABe biased toward the majority class
Explanation
Most classification algorithms aim to minimize overall error, so they become biased toward the majority class. This results in poor recall for the minority class unless techniques like upsampling or threshold adjustment are applied.
- A
- 13
A confusion matrix for a binary classifier shows:
- A
The correlation between predicted and actual values
- B
The feature importance scores
- C
The probability distribution of each class
- D
The counts of true positives, true negatives, false positives, and false negatives
Correct answer
DThe counts of true positives, true negatives, false positives, and false negatives
Explanation
A confusion matrix tabulates the performance of a classification model by comparing predicted labels to actual labels. It contains four cells: TP, TN, FP, FN.
- A
- 14
Recall (sensitivity) for a given class is calculated as:
- A
TN+FPTN
- B
TP+TN+FP+FNTP+TN
- C
TP+FPTP
- D
TP+FNTP
Correct answer
DTP+FNTP
Explanation
Recall is the proportion of actual positive cases that are correctly identified by the model: TP+FNTP.
- A
- 15
One assumption of linear regression is homoscedasticity, which means:
- A
The variance of errors is constant across all levels of the independent variable
- B
The errors are normally distributed
- C
The relationship between X and Y is linear
- D
The independent variables are uncorrelated with each other
Correct answer
AThe variance of errors is constant across all levels of the independent variable
Explanation
Homoscedasticity assumes that the spread of residuals is roughly equal for all predicted values. Heteroscedasticity, where variance changes, can violate this assumption.
- A
- 16
Multicollinearity in multiple linear regression refers to:
- A
High correlation among independent variables
- B
The presence of outliers in the data
- C
Non-linear relationship between variables
- D
High correlation between independent and dependent variables
Correct answer
AHigh correlation among independent variables
Explanation
Multicollinearity occurs when two or more independent variables are highly correlated, making it difficult to estimate their individual effects and potentially inflating standard errors.
- A
- 17
Which of the following is NOT a typical assumption of linear regression?
- A
Errors are independent of each other
- B
Errors are normally distributed with mean zero
- C
The dependent variable is binary
- D
The relationship between predictors and target is linear
Correct answer
CThe dependent variable is binary
Explanation
Linear regression assumes a continuous dependent variable, not binary. Binary outcomes are typically modeled with logistic regression.
- A
- 18
Outliers in the data can severely affect linear regression because:
- A
Outliers always increase the R-squared value
- B
Linear regression is incapable of handling any outliers
- C
Outliers cause the model to overfit the training data
- D
The best-fit line can be pulled toward the outliers, reducing model accuracy
Correct answer
DThe best-fit line can be pulled toward the outliers, reducing model accuracy
Explanation
Because linear regression minimizes squared errors, extreme outliers can disproportionately influence the fitted line, leading to a model that does not represent the majority of the data well.
- A
- 19
When a variable's p-value in regression output is large (e.g., > 0.05), it suggests:
- A
The variable is highly correlated with the target
- B
The variable may not be a statistically significant predictor
- C
The variable should be transformed into a log scale
- D
The coefficient for that variable is zero
Correct answer
BThe variable may not be a statistically significant predictor
Explanation
A large p-value (typically above 0.05) indicates that the observed relationship between the predictor and target could reasonably occur by chance, so the variable is not statistically significant at that confidence level.
- A
- 20
What is the purpose of using gradient descent in linear regression?
- A
To compute the p-values of the coefficients
- B
To select the most important features
- C
To iteratively find the coefficients that minimize the cost function
- D
To normalize the data before modeling
Correct answer
CTo iteratively find the coefficients that minimize the cost function
Explanation
Gradient descent is an optimization algorithm that updates the model parameters (coefficients) repeatedly to reduce the cost function (e.g., RSS), eventually finding a minimum.
- A
- 21
In the context of regression, what does 'overfitting' mean?
- A
The model performs well on training data but poorly on new data
- B
The model has too few parameters to capture the data pattern
- C
The model assumes linearity when the relationship is non-linear
- D
The model's residuals are normally distributed
Correct answer
AThe model performs well on training data but poorly on new data
Explanation
Overfitting occurs when a model learns the training data too closely, including noise, and fails to generalize to unseen data, leading to high variance.
- A
- 22
When examining a pair plot, what does it indicate if the density plots of two classes for a feature heavily overlap with similar central values?
- A
That feature is likely a poor predictor for distinguishing the classes
- B
The data contains many outliers
- C
That feature is the most important for classification
- D
The feature should be transformed using a log function
Correct answer
AThat feature is likely a poor predictor for distinguishing the classes
Explanation
If the distributions of a feature for different classes are nearly identical, that feature provides little discriminatory power. It is unlikely to improve classification accuracy.
- A
- 23
Missing values in a numerical column are often imputed with the median rather than the mean because:
- A
The median is easier to compute
- B
The median is less sensitive to outliers
- C
The median maintains the original distribution shape
- D
The mean always remains the same after imputation
Correct answer
BThe median is less sensitive to outliers
Explanation
The median is robust to outliers, while the mean can be heavily influenced by extreme values. Using the median for imputation reduces the risk of distorting the central tendency.
- A
- 24
A low variance filter in feature selection removes columns that:
- A
Contain only numerical data
- B
Have very little variation in their values, thus providing limited information
- C
Have a high number of missing values
- D
Are highly correlated with the target variable
Correct answer
BHave very little variation in their values, thus providing limited information
Explanation
Columns with near-zero variance (e.g., constant values or extremely imbalanced categories) are unlikely to be useful predictors and can be removed to simplify the model.
- A
- 25
In linear regression, what is the implication if the residual plot shows a clear pattern (e.g., a curve)?
- A
The model fits the data perfectly
- B
The R-squared value will be close to 1
- C
The relationship may be non-linear, and a linear model might not be appropriate
- D
The errors are homoscedastic
Correct answer
CThe relationship may be non-linear, and a linear model might not be appropriate
Explanation
A pattern in the residual plot (e.g., systematic increase or decrease) suggests that the linear model is not capturing the true relationship; non-linear terms or transformations may be needed.
- A
- 26
Which of the following is an advantage of logistic regression?
- A
It does not require any data preprocessing
- B
It assumes normally distributed independent variables
- C
It is highly effective for non-linear decision boundaries
- D
It can output probabilities for class membership
Correct answer
DIt can output probabilities for class membership
Explanation
Logistic regression provides probability estimates (via the sigmoid function) for each class, which can be thresholded to make hard classifications. This probabilistic output is valuable for risk assessment.
- A
- 27
What does the term 'linear' in linear regression refer to?
- A
The relationship between the dependent and independent variables must be linear
- B
The model uses only one independent variable
- C
The errors are linearly distributed
- D
The model is linear in the coefficients, not necessarily in the variables
Correct answer
DThe model is linear in the coefficients, not necessarily in the variables
Explanation
Linear regression is 'linear' because the predicted value is a linear combination of the model parameters (coefficients). The predictor variables themselves can be transformed (e.g., x2, logx), as long as the coefficients are not raised to powers or multiplied together.
- A
- 28
When using the
train_test_splitfunction from scikit-learn, what does the parametertest_size=0.3indicate?- A
30% of the features will be used for testing
- B
The test set will contain 30 observations
- C
30% of the data will be used for training and 70% for testing
- D
30% of the data will be used for testing and 70% for training
Correct answer
D30% of the data will be used for testing and 70% for training
Explanation
test_sizespecifies the proportion of the dataset to include in the test split. Here, 30% of the data is reserved for testing, and the remaining 70% is used for training. - A
- 29
In scikit-learn, after fitting a linear regression model, how can you obtain the coefficients?
- A
Using the
.score()method - B
Using the
.predict()method on the test data - C
Using the
.intercept_attribute - D
Using the
.coef_attribute of the fitted model
Correct answer
DUsing the
.coef_attribute of the fitted modelExplanation
The fitted linear regression model stores its coefficients (slopes) in the
.coef_attribute and the intercept in.intercept_. For multiple regression,.coef_is an array of coefficients. - A
- 30
What is the main difference between linear regression and logistic regression regarding the dependent variable?
- A
There is no difference; both can be used interchangeably
- B
Logistic regression uses least squares; linear regression uses maximum likelihood
- C
Linear regression requires a continuous dependent variable; logistic regression requires a categorical dependent variable
- D
Linear regression can only handle one independent variable; logistic regression can handle many
Correct answer
CLinear regression requires a continuous dependent variable; logistic regression requires a categorical dependent variable
Explanation
Linear regression is used when the outcome is continuous (e.g., price, weight). Logistic regression is used for classification where the outcome is categorical (usually binary).
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.