Linear Regression Flashcards

(16 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 predict a continuous value based on one or more features.

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

What does the equation y = mX + b represent?

A

It represents the line of best fit where m is the slope (coefficient) and b is the intercept.

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

Which library provides LinearRegression in scikit-learn?

A

from sklearn import linear_model

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

How do you create a LinearRegression model?

A

reg = linear_model.LinearRegression()

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

How do you train (fit) a linear regression model?

A

reg.fit(X, y)

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

How do you make predictions using the trained model?

A

reg.predict([[value]])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
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
9
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
10
Q

What does reg.coef_ return?

A

The amount the output changes for each unit increase in input (slope).

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

What does reg.intercept_ return?

A

The predicted output value when the input is zero.

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

How do you visualize a scatter plot of the data?

A

Use plt.scatter(x, y, color=’red’)

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

How do you read a CSV file in pandas?

A

pd.read_csv(‘filename.csv’)

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

How do you drop a column from a DataFrame?

A

df.drop(‘column_name’, axis=1)

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

What kind of output does Linear Regression predict?

A

A continuous (numeric) value.

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

Why do we use Linear Regression?

A

To model relationships between variables and predict numerical outcomes.