def fit(self,x_train,y_train):
assert x_train.ndim==1,"only solve 2d problem"
assert len(x_train)==len(y_train),"wrong input"
x_mean=np.mean(x_train)
y_mean=np.mean(y_train)
num=(x_train-x_mean).dot(y_train-y_mean)
d=(x_train-x_mean).dot(x_train-x_mean)
self.a=num/d
self.b=y_mean-self.a*x_mean
return "a is %f , b is %f " % (self.a , self.b )
然后运行jupter报错
in fit(self, x_train, y_train)
14 self.a=num/d
15 self.b=y_mean-self.a*x_mean
—> 16 return "a is %f , b is %f " % (self.a , self.b )
17 def predict(self,x_p):
18 assert x_p.ndim==1,“wrong input”
TypeError: not enough arguments for format string
a和b都有值