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

  • 25Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Regression Fundamentals

What is the primary purpose of regression analysis?

25 questions

  1. 1

    What is the primary purpose of regression analysis?

    Model answer

    Regression analysis helps understand the relationship between a dependent variable and one or more independent variables by creating a predictive model.

    Explanation

    Regression quantifies how changes in independent variables affect the dependent variable, enabling prediction and inference.

  2. 2

    In regression, what is the difference between a dependent variable and an independent variable?

    Model answer

    The dependent variable is the outcome being predicted, while independent variables are the predictors used to explain or forecast the dependent variable.

    Explanation

    For example, predicting GRE score (dependent) from CGPA (independent).

  3. 3

    What distinguishes simple linear regression from multiple linear regression?

    Model answer

    Simple linear regression has one independent variable, whereas multiple linear regression has two or more independent variables.

    Explanation

    Simple: y=mx+cy = mx + cy=mx+c; Multiple: y=β0+β1x1+β2x2+…y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \ldotsy=β0​+β1​x1​+β2​x2​+…

  4. 4

    Write the general equation for a simple linear regression line and identify the coefficients.

    Model answer

    y=mx+cy = mx + cy=mx+c where mmm is the slope and ccc is the y-intercept.

    Explanation

    The slope indicates how much yyy changes per unit change in xxx; the intercept is the value of yyy when x=0x=0x=0.

  5. 5

    What is a residual in linear regression?

    Model answer

    A residual is the difference between the actual observed value and the value predicted by the regression line.

    Explanation

    Residual = actual yyy - predicted yyy. Minimizing the sum of squared residuals is the goal for finding the best fit line.

  6. 6

    How is the best fit line determined in linear regression?

    Model answer

    The best fit line minimizes the sum of squared residuals (RSS) – the line with the smallest RSS is chosen.

    Explanation

    This ordinary least squares (OLS) method ensures the line fits the data as closely as possible.

  7. 7

    What does the slope coefficient represent in a simple linear regression model?

    Model answer

    The slope represents the expected change in the dependent variable for a one‑unit increase in the independent variable.

    Explanation

    For example, if y=6.8x+261y = 6.8x + 261y=6.8x+261, a 1‑unit increase in CGPA is associated with a 6.8‑point increase in GRE score.

  8. 8

    What is the equation for a multiple linear regression model with three independent variables?

    Model answer

    y=β0+β1x1+β2x2+β3x3y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_3y=β0​+β1​x1​+β2​x2​+β3​x3​

    Explanation

    Each βi\beta_iβi​ measures the effect of xix_ixi​ while holding other variables constant.

  9. 9

    Why is it necessary to split data into training and testing sets?

    Model answer

    To evaluate how well the model generalizes to unseen data, preventing overfitting and giving a realistic performance estimate.

    Explanation

    Training set builds the model; testing set assesses its predictive accuracy on new data.

  10. 10

    What does the R‑value (coefficient of correlation) indicate about the relationship between two variables?

    Model answer

    It measures the strength and direction of a linear relationship, ranging from -1 to +1. Values near ±1 indicate a strong linear relationship; 0 implies no linear relationship.

    Explanation

    Positive R means variables move together; negative R means they move in opposite directions.

  11. 11

    How is R‑squared (R2R^2R2) interpreted in linear regression?

    Model answer

    R2R^2R2 represents the proportion of variance in the dependent variable that is explained by the independent variables in the model.

    Explanation

    An R2R^2R2 of 0.8 means 80% of the variance in yyy is accounted for by the predictors.

  12. 12

    Why is adjusted R2R^2R2 preferred over R2R^2R2 when comparing models with different numbers of predictors?

    Model answer

    Adjusted R2R^2R2 penalizes the inclusion of irrelevant variables, preventing overfitting, whereas R2R^2R2 always increases when more variables are added.

    Explanation

    Adjusted R2R^2R2 adjusts for the number of predictors, giving a more honest measure of model fit.

  13. 13

    What is RMSE and how is it calculated?

    Model answer

    RMSE (Root Mean Squared Error) is the square root of the average squared differences between actual and predicted values. It measures the average prediction error.

    Explanation

    RMSE=1n∑i=1n(yi−y^i)2RMSE = \sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_i)^2}RMSE=n1​∑i=1n​(yi​−y^​i​)2​

  14. 14

    What does it mean if the residual sum of squares (RSS) is zero?

    Model answer

    It means the model predicts all observed values perfectly with no error, which is practically impossible with real data.

    Explanation

    Zero RSS would imply the regression line passes through every data point.

  15. 15

    What is multicollinearity and why is it problematic in linear regression?

    Model answer

    Multicollinearity occurs when independent variables are highly correlated. It inflates coefficient standard errors, making estimates unstable and harder to interpret.

    Explanation

    The algorithm assumes predictors are independent; violation weakens predictive power and reliability.

  16. 16

    List the key assumptions of linear regression.

    Model answer
    1. Linearity of relationship; 2. Independence of errors; 3. Homoscedasticity (constant variance of errors); 4. Normality of errors; 5. No multicollinearity among predictors.

    Explanation

    Violations can lead to biased estimates, poor predictions, and invalid inferences.

  17. 17

    What does homoscedasticity mean in the context of linear regression?

    Model answer

    Homoscedasticity means the variance of residuals is constant across all levels of the independent variables.

    Explanation

    If variance increases with predicted values (heteroscedasticity), standard errors may be inaccurate.

  18. 18

    How do outliers affect linear regression models?

    Model answer

    Outliers can pull the regression line toward themselves, distorting the slope and intercept and reducing model accuracy.

    Explanation

    Linear regression is sensitive to outliers; they should be detected and handled before model building.

  19. 19

    Why is a low variance filter applied to features before model building?

    Model answer

    Columns with very little variance (e.g., almost all same value) provide no predictive information and are removed to reduce noise and complexity.

    Explanation

    For instance, if almost all cars have the same fuel type, that column won't help predict price.

  20. 20

    When should one‑hot encoding be used instead of label encoding for categorical variables?

    Model answer

    One‑hot encoding should be used for nominal categorical variables (no natural order) to avoid introducing false ordinal relationships.

    Explanation

    For gender (male/female), label encoding (0,1) implies an order that doesn't exist; one‑hot creates binary columns without order.

  21. 21

    Describe two common strategies for handling missing data in a numeric column.

    Model answer
    1. Replace with median (robust to outliers). 2. Use model‑based imputation (e.g., MICE) that predicts missing values from other features.

    Explanation

    Median is preferred over mean when outliers are present. MICE creates multiple imputations using chained equations.

  22. 22

    What function in R is used to fit a linear regression model, and what are its primary arguments?

    Model answer

    The lm() function, with formula (dependent ~ independent) and data (data frame).

    Explanation

    Example: lm(price ~ carat, data = diamonds).

  23. 23

    In the Python demo using sklearn, what is the purpose of the train_test_split function?

    Model answer

    It splits the dataset into random training and testing subsets, typically with a specified test size (e.g., 0.3 for 30% test).

    Explanation

    This ensures the model is evaluated on unseen data to gauge generalization.

  24. 24

    How does gradient descent help find the best fit line in linear regression?

    Model answer

    Gradient descent iteratively adjusts slope and intercept to minimize the cost function (RSS) by moving in the direction of steepest descent.

    Explanation

    It uses partial derivatives to update coefficients step by step until convergence to the minimum error.

  25. 25

    What does the predict() function do after fitting a linear regression model in R?

    Model answer

    It uses the fitted model to generate predicted values for new data (typically the test set).

    Explanation

    Example: predict(model, newdata = test) returns predicted yyy values.

1 of 25
Question 1 of 25

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent