Machine Learning Algorithm Quizzes

Linear Regression

Question 1

Which line of code correctly imports the Linear Regression model from scikit-learn?

Question 2

Which method is used to train a scikit-learn Linear Regression model on the training data (X_train, y_train)?

Question 3

To split a dataset into training and testing sets, you can use the __________ function from sklearn.model_selection.

Your answer here.

Question 4

Which of the following are common metrics used to evaluate the performance of a Linear Regression model?

Question 5

After fitting a LinearRegression model named lm, how do you access the model's intercept (the constant term in the regression equation)?

Question 6

In the context of preparing data for a machine learning model, the _____ library is most commonly used to load data from a CSV file into a DataFrame.

Your answer here.

Question 7

Given a pandas DataFrame df with columns ['bedrooms', 'sq_ft', 'price'], select all the correct ways to define the feature matrix X and the target vector y to predict the price.

Question 8

In a simple linear regression model price = b0 + b1 * size, what does the coefficient b1 (accessed via model.coef_) represent?

Question 9

After training a model named model, you use the model._____() method to generate predictions on new, unseen data (e.g., X_test).

Your answer here.

Question 10

Select the key assumptions of Linear Regression. (Note: This question relates to the statistical theory behind the model).

End of Quiz

Your final score is: 0 / 0

List of Questions

Question 1: Which line of code correctly imports the Linear Regression model from scikit-learn?

Answers: from sklearn.linear_model import LinearRegression.

Question 2: Which method is used to train a scikit-learn Linear Regression model on the training data (`X_train`, `y_train`)?

Answers: .fit(X_train, y_train).

Question 3: Which of the following are common metrics used to evaluate the performance of a Linear Regression model?

Answers: Mean Squared Error (MSE), R-squared (Coefficient of Determination).

Question 4: After fitting a `LinearRegression` model named `lm`, how do you access the model's intercept (the constant term in the regression equation)?

Answers: lm.intercept_.

Question 5: Given a pandas DataFrame `df` with columns `['bedrooms', 'sq_ft', 'price']`, select all the correct ways to define the feature matrix `X` and the target vector `y` to predict the price.

Answers: X = df[['bedrooms', 'sq_ft']]; y = df['price'], X = df.drop('price', axis=1); y = df['price'].

Question 6: In a simple linear regression model `price = b0 + b1 * size`, what does the coefficient `b1` (accessed via `model.coef_`) represent?

Answers: The change in price for a one-unit increase in size..

Question 7: Select the key assumptions of Linear Regression. (Note: This question relates to the statistical theory behind the model).

Answers: Linearity: The relationship between predictors and the outcome variable is linear., Homoscedasticity: The variance of the residuals is constant across all predicted values., Independence: The observations in the dataset are independent of each other..