Question: Problem Construct a module by the name of DataAnalysis . py , which has a class LinearRegression, and two functions split data ( ) and

Problem
Construct a module by the name of DataAnalysis.py, which has a class LinearRegression,
and two functions split data() and pairwiseplot(). Use this module in a different file to
fit linear regression on california housing data. Use split data to split the data into two
sets namely, training and test. Use training data to fit the regression and evaluate quality
of the fit using test data. See below for the required details related to functions and the class.
class LinearRegression
constructor init () function[this function instantiates an object of the class and takes
fit intercept=True as an argument]. fit intercept takes True as a default argument,
which indicates that intercept needs to be calculated for linear regression.
fit()[it takes X(features) and y(targets) to fit a linear regression]
predict()[it takes the test data and predicts the target values.]
mean squared error()[it takes predicted and actual target values to calculate the mean
squared error.]
coeff [attribute which returns the coefficients of regression]
intercept [attribute which returns the intercept of the regression]
plot()[plots the predicted and actual target values on same graph]
split data()
it should take X, y and the size of test data(test size) as the arguments(test size) to
split the data into training and test datasets.
pairwiseplot()
This function takes X(set of features) as an argument and plot the pairwise scatter
plots of all the features.
Instructions
Use matplotlib, numpy and pandas modules.
Do not use any function from sklearn and seaborn libraries except for loading the
fetch california housing data.
All graphs should be nice looking. Use proper labels, titles, markers, sizes, colors, etc
to finish your graphs.
Search the internet to find the formula you need to cod multi linear regression.

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!