Question: Question: Implement Linear regression using NumPy. You should implement your code in the provided linear _ regression.py file. This python file takes a csv file

Question:
Implement Linear regression using NumPy. You should implement your code in the provided linear_regression.py file. This python file takes a csv file and a list of features as input. From these list of features, the last feature will be the target label and the remaining ones will be your training inputs. For example, in the following usage scenario, linear.csv is the csv file and Writing is the target label, while Math and Reading are training inputs.
$python3 linear_regression.py linear.csv Math Reading Writing
Output the RMSE score of prediction.
-provided linear_regression.py file,is as follow:
import numpy as np
import pandas as pd
import math
import sys
import os
#Todo : define necessary functions
def linear_regression(data):
"""
data: input data matrix
return: rmse value
"""
#Todo : fill code here
return -1
# do not modify this function
def load_data():
filename = sys.argv[1]
feature_matrix = pd.read_csv(filename)
feature_matrix = feature_matrix.dropna()
features = sys.argv[2:]
#print(feature_matrix[features])
return feature_matrix
if __name__=="__main__":
data = load_data()
RMSE_SCORE = linear_regression(data)
print("RMSE score is : ", RMSE_SCORE)
-
linear.csvcontains in the following format: Math, Reading, Writing. There are 1001 lines of data structured in this way.also the image of inear.csv has been attched
 Question: Implement Linear regression using NumPy. You should implement your code

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 Databases Questions!