Multi LR Expl
Multi LR Expl
%matplotlib inline
fig = plt.figure(figsize=(8,7))
ax = fig.add_subplot(111, projection='3d')
ax.set_zlabel('MPG')
ax.set_xlabel('No. of Cylinders')
ax.set_zlabel('MPG'): Sets the label for the z-axis to 'MPG' (Miles per Ga
llon).
ax.set_ylabel('Weight (1000 lbs)'): Sets the label for the y-axis to 'Weig
ht (1000 lbs)'.
# scatter plot with response variable and 2 predictors
X = df.drop(['mpg'], axis=1)
y = df['mpg']
lm = LinearRegression()
# train model
lm.fit(X_train, y_train)
lm.fit(X_train, y_train): Trains the linear regression model using the trai
ning data (X_train and y_train).
beta_0 = float(lm.intercept_)