【发布时间】:2020-03-16 19:38:45
【问题描述】:
我已经手动实现了一个多元线性回归类,现在我正在研究度量方法。我曾尝试手动计算 AIC 和 BIC 分数,但结果不正确。原因是我没有使用对数似然函数,而是使用了 SSE 方法。您能否建议我如何更改实现以计算完整的 AIC 和 BIC 分数?
这是我的方法现在的样子:
def AIC_BIC(self, actual = None, pred = None):
if actual is None:
actual = self.response
if pred is None:
pred = self.response_pred
n = len(actual)
k = self.num_features
residual = np.subtract(pred, actual)
RSS = np.sum(np.power(residual, 2))
AIC = n * np.log(RSS / n) + 2 * k
BIC = n * np.log(RSS / n) + k * np.log(n)
return (AIC, BIC)
请尝试给我一个手动方法,而不是图书馆电话。谢谢!
【问题讨论】:
-
请查看stackoverflow.com/questions/7458391/…,因为我的旧笔记说它讨论了多元回归的 AIC 计算。
-
谢谢,我去看看
标签: python python-3.x machine-learning linear-regression data-science