sklearn中預測模型的score函數
阿新 • • 發佈:2018-06-28
ESS 最好的 near sample spa lan urn eight 期望
sklearn.linear_model
.LinearRegression.score
score(self, X, y, sample_weight=None)
Returns the coefficient of determination R^2 of the prediction.
The coefficient R^2 is defined as (1 - u/v), where u is the residual sum of squares ((y_true - y_pred) ** 2).sum() and v is the total sum of squares ((y_true - y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R^2 score of 0.0.
作用:返回該次預測的系數R2
其中R2 =(1-u/v)。
u=((y_true - y_pred) ** 2).sum() v=((y_true - y_true.mean()) ** 2).sum()
其中可能得到的最好的分數是1,並且可能是負值(因為模型可能會變得更加糟糕)。當一個模型不論輸入何種特征值,其總是輸出期望的y的時候,此時返回0。
sklearn中預測模型的score函數