The following code statement return errors, probably coming from function arguments help me solve this.
#calculating b and a to find the linear regression:
class calculate:
def sum_of_xtrain(x_train):
sum_xtrain = 0
for i in range(0,len(x_train)):
sum_xtrain += x_train[i]
i +=1
return sum_xtrain
def sum_of_ytrain(y_train):
sum_ytrain = 0
for i in range(0,len(y_train)):
sum_ytrain += y_train[i]
i +=1
def sum_of_product_of_xytrain(x_train,y_train):
sum_of_product = 0
for i in range(0, len(x_train)):
sum_of_product += x_train[i]*y_train[i]
i += 1
def square_x_train(x_train):
square_x = 0
for i in range(0, len(x_train)):
square_x += x_train[i] * x_train[i]
i += 1
a = calculate()
print(a.sum_of_xtrain(x_train))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_9172\2110094580.py in <module>
28
29 a = calculate()
---> 30 print(a.sum_of_xtrain(x_train))
31
32
TypeError: sum_of_xtrain() takes 1 positional argument but 2 were given
Data is a simple example of common data used in linear regression test programs. I want to calculate the value of a and b in y = a + bx
.