Linear Regression Overview
- 38Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary purpose of regression analysis?
What is the primary purpose of regression analysis?
38 questions
- 1
What is the primary purpose of regression analysis?
- A
To find the average of a dependent variable across different groups
- B
To understand the relationship between two or more variables by creating a predictive model
- C
To classify data into distinct categories based on independent variables
- D
To reduce the dimensionality of a dataset without losing information
Correct answer
BTo understand the relationship between two or more variables by creating a predictive model
Explanation
Regression analysis helps understand the relationship between variables and builds a model to predict a dependent variable based on independent variables.
- A
- 2
Which of the following is a requirement for the dependent variable in linear regression?
- A
It must be normally distributed
- B
It must have the same variance across all levels of independent variables
- C
It must be a continuous numerical value
- D
It must be a categorical variable with two levels
Correct answer
CIt must be a continuous numerical value
Explanation
Linear regression requires the dependent variable to be continuous numerical, as the model predicts a continuous outcome.
- A
- 3
What does a simple linear regression model assume about the relationship between the dependent and independent variable?
- A
The relationship is always negative
- B
The relationship is always positive
- C
The relationship is linear and can be represented by a straight line
- D
The relationship is curved and requires polynomial terms
Correct answer
CThe relationship is linear and can be represented by a straight line
Explanation
Simple linear regression assumes a linear relationship, modeled as a straight line: y=mx+c.
- A
- 4
In linear regression, what are the coefficients (slope and intercept) representing?
- A
The number of data points that lie exactly on the regression line
- B
The probability that the dependent variable is correctly predicted
- C
The strength and direction of the relationship between independent and dependent variables
- D
The percentage of variance explained by the model
Correct answer
CThe strength and direction of the relationship between independent and dependent variables
Explanation
The slope (m) indicates how much y changes per unit change in x, and the intercept (c) is the value of y when x=0.
- A
- 5
What is the residual in linear regression?
- A
The total sum of squares of the dependent variable
- B
The squared difference between two independent variables
- C
The difference between the actual value and the predicted value of the dependent variable
- D
The difference between the independent variable and its mean
Correct answer
CThe difference between the actual value and the predicted value of the dependent variable
Explanation
A residual is the error term: eiā=yiāāy^āiā, representing the difference between observed and predicted values.
- A
- 6
How is the best fit line determined in linear regression?
- A
By minimizing the sum of absolute residuals
- B
By minimizing the sum of squared residuals (RSS)
- C
By maximizing the correlation coefficient between actual and predicted values
- D
By maximizing the number of data points that lie exactly on the line
Correct answer
BBy minimizing the sum of squared residuals (RSS)
Explanation
The ordinary least squares (OLS) method finds the line that minimizes the sum of squared residuals.
- A
- 7
In multiple linear regression, what does the coefficient m1ā represent?
- A
The change in the dependent variable for a one-unit change in x1ā, holding other variables constant
- B
The total effect of all independent variables on the dependent variable
- C
The intercept of the regression plane with the x1ā axis
- D
The correlation between x1ā and the dependent variable
Correct answer
AThe change in the dependent variable for a one-unit change in x1ā, holding other variables constant
Explanation
Each coefficient represents the partial effect: the change in y per unit change in that predictor, with all others held constant.
- A
- 8
What is the equation of the hyperplane in multiple linear regression?
- A
y=β0ā+β1āx1ā+β2āx2ā+āÆ+βnāxnā
- B
y=β0ā+β1āx1ā+β2āx12ā+β3āx2ā
- C
y=β0ā+β1āx1āx2ā+β2āx2ā
- D
y=β0ā+log(x1ā)+β2āx2ā
Correct answer
Ay=β0ā+β1āx1ā+β2āx2ā+āÆ+βnāxnā
Explanation
Multiple linear regression uses a linear combination of independent variables: y=β0ā+β1āx1ā+β2āx2ā+ā¦+βnāxnā.
- A
- 9
What does the coefficient of determination (R2) measure?
- A
The correlation between the independent and dependent variables
- B
The probability that the model is correct
- C
The standard deviation of the residuals
- D
The proportion of variance in the dependent variable explained by the model
Correct answer
DThe proportion of variance in the dependent variable explained by the model
Explanation
R2 indicates how much of the total variance in y is accounted for by the regression model. It ranges from 0 to 1.
- A
- 10
Why is adjusted R2 preferred over R2 when evaluating multiple regression models?
- A
Adjusted R2 is easier to compute than R2
- B
Adjusted R2 penalizes the inclusion of irrelevant independent variables
- C
Adjusted R2 always increases when a new variable is added
- D
Adjusted R2 measures the correlation between actual and predicted values
Correct answer
BAdjusted R2 penalizes the inclusion of irrelevant independent variables
Explanation
Adjusted R2 adjusts for the number of predictors, decreasing if useless variables are added, thus preventing overfitting.
- A
- 11
What does the correlation coefficient (r) indicate about the relationship between two variables?
- A
The probability that the relationship is statistically significant
- B
The percentage of variance explained by the independent variable
- C
The strength and direction of a linear relationship, ranging from -1 to +1
- D
The slope of the regression line
Correct answer
CThe strength and direction of a linear relationship, ranging from -1 to +1
Explanation
r measures the linear relationship: +1 indicates perfect positive, -1 perfect negative, 0 no linear relationship.
- A
- 12
What is the Root Mean Squared Error (RMSE) in the context of regression?
- A
The mean absolute error between actual and predicted values
- B
The square root of the average of squared residuals
- C
The sum of squared residuals divided by the number of observations
- D
The square of the correlation coefficient
Correct answer
BThe square root of the average of squared residuals
Explanation
RMSE = n1āāi=1nā(yiāāy^āiā)2ā, providing an average error magnitude in the same units as y.
- A
- 13
Which assumption of linear regression states that the residuals should have constant variance across all levels of the independent variable?
- A
Homoscedasticity
- B
Linearity
- C
Normality of errors
- D
Independence of errors
Correct answer
AHomoscedasticity
Explanation
Homoscedasticity means the spread of residuals is roughly equal for all fitted values. Heteroscedasticity violates this assumption.
- A
- 14
What problem occurs when independent variables in a multiple regression are highly correlated with each other?
- A
Heteroscedasticity
- B
Multicollinearity
- C
Autocorrelation
- D
Overfitting
Correct answer
BMulticollinearity
Explanation
Multicollinearity inflates standard errors and makes coefficient estimates unstable. It violates the assumption of independent predictors.
- A
- 15
How do outliers affect linear regression models?
- A
They always improve the model by providing more information
- B
They can pull the regression line heavily, reducing model accuracy
- C
They only affect the intercept, not the slope
- D
They have no effect because the model averages all data points
Correct answer
BThey can pull the regression line heavily, reducing model accuracy
Explanation
Linear regression is sensitive to outliers because the OLS method minimizes squared errors, causing outliers to have a disproportionate influence.
- A
- 16
Which method is commonly used to handle missing values in a numeric column when the data is missing at random?
- A
Ignore the missing values and proceed
- B
Delete all rows with missing values
- C
Fill with the mode of the column
- D
Impute with the median of the column
Correct answer
DImpute with the median of the column
Explanation
Median imputation is a robust method for numeric columns because the median is less affected by outliers than the mean.
- A
- 17
What is the purpose of splitting data into training and testing sets?
- A
To reduce the number of features used in the model
- B
To ensure the model has 100% accuracy on the training set
- C
To increase the size of the dataset for better training
- D
To evaluate the model's performance on unseen data and avoid overfitting
Correct answer
DTo evaluate the model's performance on unseen data and avoid overfitting
Explanation
Training on one set and testing on another mimics real-world performance and helps detect overfitting.
- A
- 18
When converting categorical variables with no ordinal relationship (e.g., color) into numbers, which encoding technique is appropriate?
- A
One-hot encoding
- B
Label encoding
- C
Ordinal encoding
- D
Binary encoding
Correct answer
AOne-hot encoding
Explanation
One-hot encoding creates binary columns for each category without implying any order, suitable for nominal variables.
- A
- 19
What is the purpose of a low variance filter in data preprocessing?
- A
To remove rows with missing values
- B
To remove columns that have very little variation and thus low predictive power
- C
To scale all features to have zero variance
- D
To combine highly correlated features into one
Correct answer
BTo remove columns that have very little variation and thus low predictive power
Explanation
If a column has almost constant values, it provides little information for prediction and can be dropped.
- A
- 20
In the context of linear regression, what does gradient descent do?
- A
It splits the data into training and testing sets
- B
It iteratively adjusts the coefficients to minimize the cost function
- C
It standardizes the independent variables
- D
It calculates the correlation matrix of the predictors
Correct answer
BIt iteratively adjusts the coefficients to minimize the cost function
Explanation
Gradient descent is an optimization algorithm that finds the coefficients that minimize the residual sum of squares or another cost function.
- A
- 21
What is the role of the learning rate in gradient descent?
- A
It controls the step size of each iteration towards the minimum
- B
It regularizes the model to prevent overfitting
- C
It sets the initial values of the coefficients
- D
It determines the number of iterations to perform
Correct answer
AIt controls the step size of each iteration towards the minimum
Explanation
The learning rate determines how much the coefficients are updated each step; too large can overshoot, too small slows convergence.
- A
- 22
In the R demo, which function was used to create a histogram of the price column?
- A
barplot(diamonds$price) - B
ggplot(diamonds) + geom_histogram(aes(x = price)) - C
hist(diamonds$price, col = 'blue') - D
plot(diamonds$price, type = 'h')
Correct answer
Bggplot(diamonds) + geom_histogram(aes(x = price))Explanation
The presenter used
ggplotwithgeom_histogramto visualize the distribution of diamond prices. - A
- 23
In the Python demo with the iris dataset, what was the dependent variable?
- A
Sepal length
- B
Sepal width
- C
Petal length
- D
Species
Correct answer
ASepal length
Explanation
The model predicted sepal length based on petal length.
- A
- 24
What is the main difference between simple and multiple linear regression?
- A
Simple linear regression has one independent variable; multiple has more than one
- B
Simple linear regression requires a normally distributed dependent variable
- C
Multiple linear regression can only handle numerical independent variables
- D
Simple linear regression uses a curved line; multiple uses a straight line
Correct answer
ASimple linear regression has one independent variable; multiple has more than one
Explanation
The number of independent variables distinguishes them: one predictor vs. multiple predictors.
- A
- 25
Which of the following is NOT an assumption of linear regression?
- A
The residuals are independent of each other
- B
The independent variables must be normally distributed
- C
The relationship between the dependent and independent variables is linear
- D
The residuals have constant variance (homoscedasticity)
Correct answer
BThe independent variables must be normally distributed
Explanation
Linear regression does not assume normality of independent variables; it assumes normality of residuals and linearity of relationship.
- A
- 26
What does a residual plot with a funnel-shaped pattern (spread increasing with fitted values) indicate?
- A
Multicollinearity
- B
Heteroscedasticity
- C
Normality of errors
- D
Linearity assumption is satisfied
Correct answer
BHeteroscedasticity
Explanation
A funnel pattern suggests that the variance of residuals changes with the predicted value, violating homoscedasticity.
- A
- 27
In the context of the diamond dataset demo, why was the RMSE for the second model (using x, y, z) higher than the first model (using carat)?
- A
The second model used fewer data points
- B
The first model accounted for outliers better
- C
The second model had more independent variables but they were less predictive of price
- D
The second model overfitted the training data
Correct answer
CThe second model had more independent variables but they were less predictive of price
Explanation
Adding poorly correlated predictors can increase error; RMSE was larger for the second model, indicating worse performance.
- A
- 28
What is a hyperplane in the context of multiple linear regression?
- A
A line that best separates data into classes
- B
A curved surface that fits nonlinear relationships
- C
A flat surface in a multi-dimensional space that represents the regression equation
- D
A type of decision boundary used in classification
Correct answer
CA flat surface in a multi-dimensional space that represents the regression equation
Explanation
A hyperplane is a generalization of a line/plane to higher dimensions; in multiple regression, it is the linear relationship between y and the predictors.
- A
- 29
Why is linear regression considered a 'white box' model?
- A
Its coefficients have clear interpretable meanings
- B
It requires no data preprocessing
- C
It is easier to code than other models
- D
It can only be used for regression, not classification
Correct answer
AIts coefficients have clear interpretable meanings
Explanation
Linear regression provides interpretable coefficients that directly quantify the effect of each predictor, unlike black box models.
- A
- 30
What technique can be used to handle multicollinearity by combining correlated variables into new orthogonal components?
- A
Regularization (Ridge/Lasso)
- B
Removing all correlated variables manually
- C
One-hot encoding
- D
Principal Component Analysis (PCA)
Correct answer
DPrincipal Component Analysis (PCA)
Explanation
PCA transforms correlated variables into uncorrelated principal components, which can then be used as predictors.
- A
- 31
In the R diamond demo, what was the purpose of using the
filter()function from thedplyrpackage?- A
To compute summary statistics for each cut
- B
To sort the diamonds by price
- C
To extract a subset of diamonds with cut='Premium' and price > $5000
- D
To remove missing values from the dataset
Correct answer
CTo extract a subset of diamonds with cut='Premium' and price > $5000
Explanation
The presenter used
filter()to create a subset of diamonds meeting certain conditions. - A
- 32
What does the
lm()function in R return?- A
A summary table of correlation coefficients
- B
A plot of the regression line
- C
A linear model object containing coefficients and other statistics
- D
A data frame with predicted values
Correct answer
CA linear model object containing coefficients and other statistics
Explanation
lm()fits a linear model and returns an object that stores the formula, coefficients, residuals, etc. - A
- 33
In the Python demo, which library was used to import the
train_test_splitfunction?- A
sklearn.metrics - B
sklearn.model_selection - C
sklearn.linear_model - D
sklearn.preprocessing
Correct answer
Bsklearn.model_selectionExplanation
train_test_splitis insklearn.model_selectionfor splitting data. - A
- 34
What is the range of the correlation coefficient r?
- A
Between -ā and +ā
- B
Between -100 and +100
- C
Between 0 and 1
- D
Between -1 and +1 inclusive
Correct answer
DBetween -1 and +1 inclusive
Explanation
r is normalized to lie between -1 (perfect negative) and +1 (perfect positive).
- A
- 35
If the R2 value of a model is 0.85, what does this indicate?
- A
85% of the variance in the dependent variable is explained by the model
- B
The model is overfitted
- C
The model has a 15% error rate
- D
85% of the predictions are exactly correct
Correct answer
A85% of the variance in the dependent variable is explained by the model
Explanation
R2=0.85 means the model accounts for 85% of the variability in y.
- A
- 36
Which encoding technique introduces an arbitrary order into categorical variables and should be used only when the categories have a natural order?
- A
One-hot encoding
- B
Target encoding
- C
Label encoding
- D
Dummy encoding
Correct answer
CLabel encoding
Explanation
Label encoding assigns integers 0,1,2,⦠to categories, implying order. It is suitable for ordinal data but not nominal.
- A
- 37
In the R demo, what was the RMSE for the first model (price ~ carat)?
- A
~2000
- B
~1002
- C
~500
- D
~1574
Correct answer
B~1002
Explanation
The presenter computed RMSE ā 1002 for the simple linear model with carat.
- A
- 38
What is the purpose of the
fillna()orfill_na()function in data preprocessing?- A
To replace missing values with a specified value (e.g., median)
- B
To create dummy variables for categorical data
- C
To scale numeric columns to have zero mean
- D
To remove rows with any missing values
Correct answer
ATo replace missing values with a specified value (e.g., median)
Explanation
fillna()(pandas) or similar functions fill missing values with replacement values like the median. - A

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