Linear Regression 2 Flashcards

(24 cards)

1
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Linear Regression?

A

A supervised learning algorithm used to model the relationship between input features and a continuous target variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the equation for a simple linear regression model?

A

y = mX + b, where m is the coefficient (slope) and b is the intercept.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the general form of multivariate linear regression?

A

y = m1x1 + m2x2 + … + mn*xn + b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which library in Python provides LinearRegression?

A

from sklearn.linear_model import LinearRegression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you import train_test_split?

A

from sklearn.model_selection import train_test_split

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you define X and y for simple linear regression?

A

X = df[[‘feature’]], y = df[‘target’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you create and train a simple linear regression model?

A

reg = LinearRegression(); reg.fit(X, y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you make predictions with a simple model?

A

reg.predict([[value]])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you view the slope (m) of the regression line?

A

reg.coef_

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you view the intercept (b) of the regression line?

A

reg.intercept_

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you handle missing values in features like ‘bedrooms’?

A

df[‘bedrooms’] = df[‘bedrooms’].fillna(df[‘bedrooms’].median())

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you define X and y for multivariate regression?

A

X = df[[‘feature1’, ‘feature2’, …]], y = df[‘target’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you train a multivariable model?

A

reg.fit(X, y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you make a multivariable prediction?

A

reg.predict([[val1, val2, val3]])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What do the values in reg.coef_ represent?

A

The weight (impact) of each feature on the predicted output.

17
Q

How do you split data into training and testing sets?

A

train_test_split(X, y, test_size=0.3, random_state=101)

18
Q

What is the purpose of test_size in train_test_split?

A

To specify the proportion of data used for testing (e.g., 0.3 = 30%).

19
Q

What does random_state do in train_test_split?

A

Ensures reproducible splits every time you run the code.

20
Q

How do you visualize actual vs predicted values?

A

plt.scatter(y_test, predictions); plt.xlabel(‘Actual’); plt.ylabel(‘Predicted’)

21
Q

How do you plot a regression line in seaborn?

A

sns.lmplot(x=’feature’, y=’target’, data=df)

22
Q

Which metrics are used to evaluate regression models?

A

MAE, MSE, RMSE from sklearn.metrics

23
Q

How do you compute RMSE?

A

np.sqrt(mean_squared_error(y_test, predictions))

24
Q

What does a lower RMSE mean?

A

The model predictions are closer to the actual values.