SL: Linear Regression Flashcards
Lib to split train and test data?
From sklearn.model_selection import train_test_split
Lib for linear regression?
From sklearn.linear_model import LinearRegression
Lib to check model performance?
From sklearn.metrics import mean_square_error
Code to split data into train & test?
X_train,x_test,y_train,y_test = train_test_split(x,y, test_size=0.30, random_state=1)
train data on LinearRegression()
regression_model = LinearRegression()
regression_model.fit(X_train, y_train)
get score of LinearRegression model
regression_model.score(X_train, y_train)
What is the most popular ML technique
Linear regression
What does Linear regression identify?
It identifies straight line relationships between two variables
Linear regression example scenarios?
Does heavy car have low mileage
First step in identifying relationships between two variables using linear regression?
Draw a scatter plot between mpg & weight
What is the relationship between mpg and weight
Negative relationships
How does positive relation look like?
If you draw a line in scatter plot the line goes up wards is positive relation
How does a negative relation look like?
If you draw a line between scatter plot the line will go down wards is called negative relation
What is non linear regression?
If you have scatter plot where straight line can not be drawn is non linear regression or no relationship
Can we relay visualization as our only technique to find relation between two variables?
No
What is covariance?
It quantify the linear relationships between two variables
Covariance formula
Data visualization is sufficient to identify the relationship between two variables?
No that is only the first step
Points on 1 & 3 quadrant contribute to
Positive relation
Points on 2 & 4 quadrant contribute to
Negative relation