1. Home
  2. Explore
  3. Computer Science
  4. Linear Regression Overview

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Linear Regression Overview

  • 38Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Regression Basics

What is the primary purpose of regression analysis?

38 questions

  1. 1

    What is the primary purpose of regression analysis?

    1. A

      To find the average of a dependent variable across different groups

    2. B

      To understand the relationship between two or more variables by creating a predictive model

    3. C

      To classify data into distinct categories based on independent variables

    4. D

      To reduce the dimensionality of a dataset without losing information

    Correct answer
    B

    To 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.

  2. 2

    Which of the following is a requirement for the dependent variable in linear regression?

    1. A

      It must be normally distributed

    2. B

      It must have the same variance across all levels of independent variables

    3. C

      It must be a continuous numerical value

    4. D

      It must be a categorical variable with two levels

    Correct answer
    C

    It must be a continuous numerical value

    Explanation

    Linear regression requires the dependent variable to be continuous numerical, as the model predicts a continuous outcome.

  3. 3

    What does a simple linear regression model assume about the relationship between the dependent and independent variable?

    1. A

      The relationship is always negative

    2. B

      The relationship is always positive

    3. C

      The relationship is linear and can be represented by a straight line

    4. D

      The relationship is curved and requires polynomial terms

    Correct answer
    C

    The 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+cy = mx + cy=mx+c.

  4. 4

    In linear regression, what are the coefficients (slope and intercept) representing?

    1. A

      The number of data points that lie exactly on the regression line

    2. B

      The probability that the dependent variable is correctly predicted

    3. C

      The strength and direction of the relationship between independent and dependent variables

    4. D

      The percentage of variance explained by the model

    Correct answer
    C

    The strength and direction of the relationship between independent and dependent variables

    Explanation

    The slope (mmm) indicates how much yyy changes per unit change in xxx, and the intercept (ccc) is the value of yyy when x=0x=0x=0.

  5. 5

    What is the residual in linear regression?

    1. A

      The total sum of squares of the dependent variable

    2. B

      The squared difference between two independent variables

    3. C

      The difference between the actual value and the predicted value of the dependent variable

    4. D

      The difference between the independent variable and its mean

    Correct answer
    C

    The difference between the actual value and the predicted value of the dependent variable

    Explanation

    A residual is the error term: ei=yiāˆ’y^ie_i = y_i - \hat{y}_iei​=yiā€‹āˆ’y^​i​, representing the difference between observed and predicted values.

  6. 6

    How is the best fit line determined in linear regression?

    1. A

      By minimizing the sum of absolute residuals

    2. B

      By minimizing the sum of squared residuals (RSS)

    3. C

      By maximizing the correlation coefficient between actual and predicted values

    4. D

      By maximizing the number of data points that lie exactly on the line

    Correct answer
    B

    By minimizing the sum of squared residuals (RSS)

    Explanation

    The ordinary least squares (OLS) method finds the line that minimizes the sum of squared residuals.

  7. 7

    In multiple linear regression, what does the coefficient m1m_1m1​ represent?

    1. A

      The change in the dependent variable for a one-unit change in x1x_1x1​, holding other variables constant

    2. B

      The total effect of all independent variables on the dependent variable

    3. C

      The intercept of the regression plane with the x1x_1x1​ axis

    4. D

      The correlation between x1x_1x1​ and the dependent variable

    Correct answer
    A

    The change in the dependent variable for a one-unit change in x1x_1x1​, holding other variables constant

    Explanation

    Each coefficient represents the partial effect: the change in yyy per unit change in that predictor, with all others held constant.

  8. 8

    What is the equation of the hyperplane in multiple linear regression?

    1. A

      y=β0+β1x1+β2x2+⋯+βnxny = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \cdots + \beta_n x_ny=β0​+β1​x1​+β2​x2​+⋯+βn​xn​

    2. B

      y=β0+β1x1+β2x12+β3x2y = \beta_0 + \beta_1 x_1 + \beta_2 x_1^2 + \beta_3 x_2y=β0​+β1​x1​+β2​x12​+β3​x2​

    3. C

      y=β0+β1x1x2+β2x2y = \beta_0 + \beta_1 x_1 x_2 + \beta_2 x_2y=β0​+β1​x1​x2​+β2​x2​

    4. D

      y=β0+log⁔(x1)+β2x2y = \beta_0 + \log(x_1) + \beta_2 x_2y=β0​+log(x1​)+β2​x2​

    Correct answer
    A

    y=β0+β1x1+β2x2+⋯+βnxny = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \cdots + \beta_n x_ny=β0​+β1​x1​+β2​x2​+⋯+βn​xn​

    Explanation

    Multiple linear regression uses a linear combination of independent variables: y=β0+β1x1+β2x2+…+βnxny = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \ldots + \beta_n x_ny=β0​+β1​x1​+β2​x2​+…+βn​xn​.

  9. 9

    What does the coefficient of determination (R2R^2R2) measure?

    1. A

      The correlation between the independent and dependent variables

    2. B

      The probability that the model is correct

    3. C

      The standard deviation of the residuals

    4. D

      The proportion of variance in the dependent variable explained by the model

    Correct answer
    D

    The proportion of variance in the dependent variable explained by the model

    Explanation

    R2R^2R2 indicates how much of the total variance in yyy is accounted for by the regression model. It ranges from 0 to 1.

  10. 10

    Why is adjusted R2R^2R2 preferred over R2R^2R2 when evaluating multiple regression models?

    1. A

      Adjusted R2R^2R2 is easier to compute than R2R^2R2

    2. B

      Adjusted R2R^2R2 penalizes the inclusion of irrelevant independent variables

    3. C

      Adjusted R2R^2R2 always increases when a new variable is added

    4. D

      Adjusted R2R^2R2 measures the correlation between actual and predicted values

    Correct answer
    B

    Adjusted R2R^2R2 penalizes the inclusion of irrelevant independent variables

    Explanation

    Adjusted R2R^2R2 adjusts for the number of predictors, decreasing if useless variables are added, thus preventing overfitting.

  11. 11

    What does the correlation coefficient (rrr) indicate about the relationship between two variables?

    1. A

      The probability that the relationship is statistically significant

    2. B

      The percentage of variance explained by the independent variable

    3. C

      The strength and direction of a linear relationship, ranging from -1 to +1

    4. D

      The slope of the regression line

    Correct answer
    C

    The strength and direction of a linear relationship, ranging from -1 to +1

    Explanation

    rrr measures the linear relationship: +1 indicates perfect positive, -1 perfect negative, 0 no linear relationship.

  12. 12

    What is the Root Mean Squared Error (RMSE) in the context of regression?

    1. A

      The mean absolute error between actual and predicted values

    2. B

      The square root of the average of squared residuals

    3. C

      The sum of squared residuals divided by the number of observations

    4. D

      The square of the correlation coefficient

    Correct answer
    B

    The square root of the average of squared residuals

    Explanation

    RMSE = 1nāˆ‘i=1n(yiāˆ’y^i)2\sqrt{\frac{1}{n}\sum_{i=1}^n (y_i - \hat{y}_i)^2}n1ā€‹āˆ‘i=1n​(yiā€‹āˆ’y^​i​)2​, providing an average error magnitude in the same units as yyy.

  13. 13

    Which assumption of linear regression states that the residuals should have constant variance across all levels of the independent variable?

    1. A

      Homoscedasticity

    2. B

      Linearity

    3. C

      Normality of errors

    4. D

      Independence of errors

    Correct answer
    A

    Homoscedasticity

    Explanation

    Homoscedasticity means the spread of residuals is roughly equal for all fitted values. Heteroscedasticity violates this assumption.

  14. 14

    What problem occurs when independent variables in a multiple regression are highly correlated with each other?

    1. A

      Heteroscedasticity

    2. B

      Multicollinearity

    3. C

      Autocorrelation

    4. D

      Overfitting

    Correct answer
    B

    Multicollinearity

    Explanation

    Multicollinearity inflates standard errors and makes coefficient estimates unstable. It violates the assumption of independent predictors.

  15. 15

    How do outliers affect linear regression models?

    1. A

      They always improve the model by providing more information

    2. B

      They can pull the regression line heavily, reducing model accuracy

    3. C

      They only affect the intercept, not the slope

    4. D

      They have no effect because the model averages all data points

    Correct answer
    B

    They 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.

  16. 16

    Which method is commonly used to handle missing values in a numeric column when the data is missing at random?

    1. A

      Ignore the missing values and proceed

    2. B

      Delete all rows with missing values

    3. C

      Fill with the mode of the column

    4. D

      Impute with the median of the column

    Correct answer
    D

    Impute 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.

  17. 17

    What is the purpose of splitting data into training and testing sets?

    1. A

      To reduce the number of features used in the model

    2. B

      To ensure the model has 100% accuracy on the training set

    3. C

      To increase the size of the dataset for better training

    4. D

      To evaluate the model's performance on unseen data and avoid overfitting

    Correct answer
    D

    To 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.

  18. 18

    When converting categorical variables with no ordinal relationship (e.g., color) into numbers, which encoding technique is appropriate?

    1. A

      One-hot encoding

    2. B

      Label encoding

    3. C

      Ordinal encoding

    4. D

      Binary encoding

    Correct answer
    A

    One-hot encoding

    Explanation

    One-hot encoding creates binary columns for each category without implying any order, suitable for nominal variables.

  19. 19

    What is the purpose of a low variance filter in data preprocessing?

    1. A

      To remove rows with missing values

    2. B

      To remove columns that have very little variation and thus low predictive power

    3. C

      To scale all features to have zero variance

    4. D

      To combine highly correlated features into one

    Correct answer
    B

    To 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.

  20. 20

    In the context of linear regression, what does gradient descent do?

    1. A

      It splits the data into training and testing sets

    2. B

      It iteratively adjusts the coefficients to minimize the cost function

    3. C

      It standardizes the independent variables

    4. D

      It calculates the correlation matrix of the predictors

    Correct answer
    B

    It 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.

  21. 21

    What is the role of the learning rate in gradient descent?

    1. A

      It controls the step size of each iteration towards the minimum

    2. B

      It regularizes the model to prevent overfitting

    3. C

      It sets the initial values of the coefficients

    4. D

      It determines the number of iterations to perform

    Correct answer
    A

    It 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.

  22. 22

    In the R demo, which function was used to create a histogram of the price column?

    1. A

      barplot(diamonds$price)

    2. B

      ggplot(diamonds) + geom_histogram(aes(x = price))

    3. C

      hist(diamonds$price, col = 'blue')

    4. D

      plot(diamonds$price, type = 'h')

    Correct answer
    B

    ggplot(diamonds) + geom_histogram(aes(x = price))

    Explanation

    The presenter used ggplot with geom_histogram to visualize the distribution of diamond prices.

  23. 23

    In the Python demo with the iris dataset, what was the dependent variable?

    1. A

      Sepal length

    2. B

      Sepal width

    3. C

      Petal length

    4. D

      Species

    Correct answer
    A

    Sepal length

    Explanation

    The model predicted sepal length based on petal length.

  24. 24

    What is the main difference between simple and multiple linear regression?

    1. A

      Simple linear regression has one independent variable; multiple has more than one

    2. B

      Simple linear regression requires a normally distributed dependent variable

    3. C

      Multiple linear regression can only handle numerical independent variables

    4. D

      Simple linear regression uses a curved line; multiple uses a straight line

    Correct answer
    A

    Simple linear regression has one independent variable; multiple has more than one

    Explanation

    The number of independent variables distinguishes them: one predictor vs. multiple predictors.

  25. 25

    Which of the following is NOT an assumption of linear regression?

    1. A

      The residuals are independent of each other

    2. B

      The independent variables must be normally distributed

    3. C

      The relationship between the dependent and independent variables is linear

    4. D

      The residuals have constant variance (homoscedasticity)

    Correct answer
    B

    The 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.

  26. 26

    What does a residual plot with a funnel-shaped pattern (spread increasing with fitted values) indicate?

    1. A

      Multicollinearity

    2. B

      Heteroscedasticity

    3. C

      Normality of errors

    4. D

      Linearity assumption is satisfied

    Correct answer
    B

    Heteroscedasticity

    Explanation

    A funnel pattern suggests that the variance of residuals changes with the predicted value, violating homoscedasticity.

  27. 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)?

    1. A

      The second model used fewer data points

    2. B

      The first model accounted for outliers better

    3. C

      The second model had more independent variables but they were less predictive of price

    4. D

      The second model overfitted the training data

    Correct answer
    C

    The 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.

  28. 28

    What is a hyperplane in the context of multiple linear regression?

    1. A

      A line that best separates data into classes

    2. B

      A curved surface that fits nonlinear relationships

    3. C

      A flat surface in a multi-dimensional space that represents the regression equation

    4. D

      A type of decision boundary used in classification

    Correct answer
    C

    A 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 yyy and the predictors.

  29. 29

    Why is linear regression considered a 'white box' model?

    1. A

      Its coefficients have clear interpretable meanings

    2. B

      It requires no data preprocessing

    3. C

      It is easier to code than other models

    4. D

      It can only be used for regression, not classification

    Correct answer
    A

    Its coefficients have clear interpretable meanings

    Explanation

    Linear regression provides interpretable coefficients that directly quantify the effect of each predictor, unlike black box models.

  30. 30

    What technique can be used to handle multicollinearity by combining correlated variables into new orthogonal components?

    1. A

      Regularization (Ridge/Lasso)

    2. B

      Removing all correlated variables manually

    3. C

      One-hot encoding

    4. D

      Principal Component Analysis (PCA)

    Correct answer
    D

    Principal Component Analysis (PCA)

    Explanation

    PCA transforms correlated variables into uncorrelated principal components, which can then be used as predictors.

  31. 31

    In the R diamond demo, what was the purpose of using the filter() function from the dplyr package?

    1. A

      To compute summary statistics for each cut

    2. B

      To sort the diamonds by price

    3. C

      To extract a subset of diamonds with cut='Premium' and price > $5000

    4. D

      To remove missing values from the dataset

    Correct answer
    C

    To 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.

  32. 32

    What does the lm() function in R return?

    1. A

      A summary table of correlation coefficients

    2. B

      A plot of the regression line

    3. C

      A linear model object containing coefficients and other statistics

    4. D

      A data frame with predicted values

    Correct answer
    C

    A 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.

  33. 33

    In the Python demo, which library was used to import the train_test_split function?

    1. A

      sklearn.metrics

    2. B

      sklearn.model_selection

    3. C

      sklearn.linear_model

    4. D

      sklearn.preprocessing

    Correct answer
    B

    sklearn.model_selection

    Explanation

    train_test_split is in sklearn.model_selection for splitting data.

  34. 34

    What is the range of the correlation coefficient rrr?

    1. A

      Between -āˆž and +āˆž

    2. B

      Between -100 and +100

    3. C

      Between 0 and 1

    4. D

      Between -1 and +1 inclusive

    Correct answer
    D

    Between -1 and +1 inclusive

    Explanation

    rrr is normalized to lie between -1 (perfect negative) and +1 (perfect positive).

  35. 35

    If the R2R^2R2 value of a model is 0.85, what does this indicate?

    1. A

      85% of the variance in the dependent variable is explained by the model

    2. B

      The model is overfitted

    3. C

      The model has a 15% error rate

    4. D

      85% of the predictions are exactly correct

    Correct answer
    A

    85% of the variance in the dependent variable is explained by the model

    Explanation

    R2=0.85R^2 = 0.85R2=0.85 means the model accounts for 85% of the variability in yyy.

  36. 36

    Which encoding technique introduces an arbitrary order into categorical variables and should be used only when the categories have a natural order?

    1. A

      One-hot encoding

    2. B

      Target encoding

    3. C

      Label encoding

    4. D

      Dummy encoding

    Correct answer
    C

    Label encoding

    Explanation

    Label encoding assigns integers 0,1,2,… to categories, implying order. It is suitable for ordinal data but not nominal.

  37. 37

    In the R demo, what was the RMSE for the first model (price ~ carat)?

    1. A

      ~2000

    2. B

      ~1002

    3. C

      ~500

    4. D

      ~1574

    Correct answer
    B

    ~1002

    Explanation

    The presenter computed RMSE ā‰ˆ 1002 for the simple linear model with carat.

  38. 38

    What is the purpose of the fillna() or fill_na() function in data preprocessing?

    1. A

      To replace missing values with a specified value (e.g., median)

    2. B

      To create dummy variables for categorical data

    3. C

      To scale numeric columns to have zero mean

    4. D

      To remove rows with any missing values

    Correct answer
    A

    To 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.

Question 1 of 38
Question 1 of 38

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent