SL: Linear Regression Flashcards

1
Q

Lib to split train and test data?

A

From sklearn.model_selection import train_test_split

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

Lib for linear regression?

A

From sklearn.linear_model import LinearRegression

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

Lib to check model performance?

A

From sklearn.metrics import mean_square_error

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

Code to split data into train & test?

A

X_train,x_test,y_train,y_test = train_test_split(x,y, test_size=0.30, random_state=1)

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

train data on LinearRegression()

A

regression_model = LinearRegression()
regression_model.fit(X_train, y_train)

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

get score of LinearRegression model

A

regression_model.score(X_train, y_train)

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

What is the most popular ML technique

A

Linear regression

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

What does Linear regression identify?

A

It identifies straight line relationships between two variables

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

Linear regression example scenarios?

A

Does heavy car have low mileage

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

First step in identifying relationships between two variables using linear regression?

A

Draw a scatter plot between mpg & weight

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

What is the relationship between mpg and weight

A

Negative relationships

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

How does positive relation look like?

A

If you draw a line in scatter plot the line goes up wards is positive relation

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

How does a negative relation look like?

A

If you draw a line between scatter plot the line will go down wards is called negative relation

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

What is non linear regression?

A

If you have scatter plot where straight line can not be drawn is non linear regression or no relationship

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

Can we relay visualization as our only technique to find relation between two variables?

A

No

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

What is covariance?

A

It quantify the linear relationships between two variables

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

Covariance formula

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

Data visualization is sufficient to identify the relationship between two variables?

A

No that is only the first step

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

Points on 1 & 3 quadrant contribute to

A

Positive relation

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

Points on 2 & 4 quadrant contribute to

A

Negative relation

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

Points on all quadrant contribute to

A

Non linear relation

22
Q

Non linear relation covariance number?

A

0

23
Q

Larger positive covariance number represent

A

Positive relation

24
Q

Larger negative covariance number represent

A

Negative relation

25
Q

Which technique is used to measure the association of two variables

A

Covariance

26
Q

Covariance value is largely affected by

A

Unit of measure

27
Q

Formula for covariance unit normalization

A
28
Q

Max covariance between two variables is

A

1

29
Q

Linear meaning?

A

Straight line

30
Q

Eucledian space?

A

Point on a graph of x and y axis

31
Q

what is Linear regression?

A

Linear regression is a statistical method used to establish a relationship between a dependent variable and one or more independent variables.

32
Q

what are the types of linear regression?

A

The two main types of linear regression are simple linear regression and multiple linear regression.

33
Q

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

A

Simple linear regression involves one independent variable and one dependent variable. Multiple linear regression involves two or more independent variables and one dependent variable.

34
Q

What is the formula for simple linear regression?

A

y = mx + b, where y is the dependent variable, x is the independent variable, m is the slope, and b is the y-intercept.

35
Q

What is the formula for multiple linear regression?

A

y = b0 + b1x1 + b2x2 + … + bnxn, where y is the dependent variable, x1, x2, …, xn are the independent variables, and b0, b1, b2, …, bn are the coefficients.

36
Q

How do you plot the regression line in a simple linear regression model?

A

You can plot the regression line in a simple linear regression model using the scatter and plot functions of the matplotlib library.

37
Q

What is the difference between L1 and L2 regularization?

A

L1 regularization adds a penalty term to the loss function that is proportional to the absolute value of the coefficients, while L2 regularization adds a penalty term that is proportional to the square of the coefficients.

38
Q

How do you perform L1 regularization in a linear regression model in Python?

A

You can perform L1 regularization in a linear regression model using the Lasso regression algorithm in scikit-learn.

39
Q

How do you perform L2 regularization in a linear regression model in Python?

A

You can perform L2 regularization in a linear regression model using the Ridge regression algorithm in scikit-learn

40
Q

What is cross-validation, and why is it important?

A

Cross-validation is a technique used to evaluate the performance of a model by partitioning the data into training and validation sets multiple times. It is important because it helps to reduce the risk of overfitting and provides a more accurate estimate of the model’s performance.

41
Q

How do you perform cross-validation in a linear regression model in Python?

A

You can perform cross-validation in a linear regression model using the cross_val_score function in scikit-learn

42
Q

How do you evaluate the performance of a linear regression model?

A

You can evaluate the performance of a linear regression model using metrics such as mean squared error (MSE), root mean squared error (RMSE), mean absolute error (MAE), R-squared, and adjusted R-squared.

43
Q

How do you perform feature scaling in a linear regression model in Python?

A

You can perform feature scaling in a linear regression model using techniques such as standardization and normalization

44
Q

How do you perform feature selection in a linear regression model in Python?

A

You can perform feature selection in a linear regression model using techniques such as forward selection, backward elimination, and stepwise regression.

45
Q

How do you handle categorical variables in a linear regression model in Python?

A

You can handle categorical variables in a linear regression model using techniques such as one-hot encoding and ordinal encoding

46
Q

How do you handle missing values in a linear regression model in Python?

A

You can handle missing values in a linear regression model using techniques such as mean imputation, median imputation, and forward filling.

47
Q

How do you handle outliers in a linear regression model in Python?

A

You can handle outliers in a linear regression model using techniques such as removing outliers, transforming the data, and using robust regression methods

48
Q

what is Noise?

A

Noise is something which is not expected to repeat.

49
Q

what is Under fit?

A

Did not capture required info.

50
Q

what is Over fit?

A

Captured required info & captured noise as well