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 DataAnalysispy 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 functionthis function instantiates an object of the class and takes
fit interceptTrue as an argument fit intercept takes True as a default argument,
which indicates that intercept needs to be calculated for linear regression.
fitit takes Xfeatures and ytargets to fit a linear regression
predictit takes the test data and predicts the target values.
mean squared errorit 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
plotplots the predicted and actual target values on same graph
split data
it should take X y and the size of test datatest size as the argumentstest size to
split the data into training and test datasets.
pairwiseplot
This function takes Xset 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
