I have implemented a multiple linear regression class by hand and right now I am working on the metrics methods. I have tried to calculate the AIC and BIC scores manually, but the results weren't correct. The reason is that I didn't use the Log Likelihood function but went with the SSE approach. Could you please suggest me how to change the implementation to compute the full AIC and BIC scores?
Here is how my method looks like right now:
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)
And please try to give me a manual approach and not a library call. Thanks!