Question: import numpy as np import csv with open(D:/hw6_2/scale_calibration.csv,'r') as c: #open a file in directory of this script for reading rawdata = list(csv.reader(c,delimiter=,)) #make a

import numpy as np import csv

with open("D:/hw6_2/scale_calibration.csv",'r') as c: #open a file in directory of this script for reading rawdata = list(csv.reader(c,delimiter=",")) #make a list of data in file

def linear_coeffs(X, Y): Y = np.array(y) X = [] for x_i in x: X.append([1, x_i]) B = np.matmul( np.matmul( np.linalg.inv( np.matmul(np.transpose(X), X) ), np.transpose(X) ), Y ) return B exampledata = np.array(rawdata[1:],dtype=np.float) #convert to data array x = exampledata[:,1] y = exampledata[:,2]

print(linear_coeffs(x, y))

i need help understanding error: " return B ^ SyntaxError: 'return' outside function".

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!