Question: Problem 2 ( Coding ) 1 2 pts: For the following tasks use the following California House Price Data: [ 1 ] 1 from sklearn.datasets

Problem 2(Coding)12 pts:
For the following tasks use the following California House Price Data:
[1]1 from sklearn.datasets import fetch_california_housing
2 housing = fetch_california_housing()
[20]1 data_x= pd.DataFrame(housing['data'], columns = housing.feature_names)
2 data_X.head(2)
1 data_y = housing.target
2 data_y|
array([4.526,3.585,3.521,dots,0.923,0.847,0.894])
1 data_y = housing.target
2 data_y|
array([4.526,3.585,3.521,dots,0.923,0.847,0.894])
Split the dataset into training and test sets of 80:20 ratio (use random_seed =2024) and test_size =
0.20. You must train the linear regression model using the training data and compute MSE using the test
dataset.
Apply Multiple Linear Regression (MLR) using normal (least square solution). You must not use any direct
or in-built package for MLR.
a.(2.5 pts) Check the five assumptions (mentioned in the classroom) of MLR (use - training dataset)
and proper interpretation - why the assumptions are met or not
b.(2 Pts) Derive the normal equation for linear regression.
c.(2 Pts) Apply the standardization technique to all features to ensure that all features have a
consistent scale. Utilize 'fit_transform' for the training data and 'transform' for the test data to
prevent data leakage.
d.(3 pts) Find optimal values of intercept and coefficients using the normal equation of the linear
regression (bopt=(xTx)-1xTy) using the training data. To avoid inverse matrix error, you may
use pseudo inverse (np.ling.pinv)
e.(1 pts) Find ( hat(y))(predict for each datapoints of x-test)- show in dataframe - making two columns:
y_actual & hat(y)_predict
f.(1+0.5=1.5pts) Finally, for the test dataset:
a. Calculate coefficient of determination (R2) and interpret the result
b. Find MSE (mean of sum of squares of error (residual)
Problem 2 ( Coding ) 1 2 pts: For the following

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!