拟合优度

Python 线性建模入门

Jason Vestuto

Data Scientist

三个不同的 R

建模:

  • RSS

评估:

  • RMSE
Python 线性建模入门

RMSE

residuals = y_model - y_data
RSS = np.sum( np.square(residuals) )
mean_squared_residuals = np.sum( np.square(residuals) ) / len(residuals)
MSE = np.mean( np.square(residuals) )
RMSE = np.sqrt(np.mean( np.square(residuals)))
RMSE = np.std(residuals)
Python 线性建模入门

代码中的 R²

偏差:

deviations = np.mean(y_data) - y_data
VAR = np.sum(np.square(deviations))

残差:

residuals = y_model - y_data
RSS = np.sum(np.square(residuals))

R²:

r_squared = 1 - (RSS / VAR)
r = correlation(y_data, y_model)
Python 线性建模入门

数据中的R²

海拔与距离的散点图,红色模型线穿过点,二者几乎水平、斜率为零

Python 线性建模入门

数据中的R²

海拔与距离的散点图,红色模型线穿过点,二者几乎水平、斜率很小

Python 线性建模入门

数据中的R²

海拔与距离的散点图,红色模型线穿过点,二者中等斜率,呈中等上升

Python 线性建模入门

数据中的R²

海拔与距离的散点图,红色模型线穿过点,二者斜率较大,呈陡峭上升

Python 线性建模入门

RMSE 与 R²

  • RMSE:剩余变异量
  • R²:线性解释的变异占比
Python 线性建模入门

Passons à la pratique !

Python 线性建模入门

Preparing Video For Download...