def score(self,X_test,y_test):
"""
returns the score on test set
<PARAMETERS>
X : input features of testing set (numpy array, list)
y : values to map to of testing set (numpy array, list)
<return type>
returns score (int)
"""
y_test = np.reshape(y_test,(y_test.shape[0],1))
if self.normalize_ == True:
X_test = self.normalize(X_test)
X_test = self.add_bias(X_test)
self.predict(X_test)
u = np.square(y_test - self.predictions).sum()
v = np.square(y_test - y_test.mean()).sum()
self.score = 1 - u/v
return self.score
评论列表
文章目录