Skip to content

Commit

Permalink
add aic bic metric of model fit
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengp0 committed Feb 14, 2024
1 parent b998dc7 commit bbda09e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/limetr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,16 @@ def get_degree_of_freedom(model: LimeTr):
ub[np.isclose(ub, 0.0)] = 0.0

return k - 0.5 * ((lb < 0) + (ub > 0)).sum()


def get_aic(model: LimeTr):
degree_of_freedom = get_degree_of_freedom(model)
return -2 * model.objective(model.soln) + 2 * degree_of_freedom


def get_bic(model: LimeTr):
degree_of_freedom = get_degree_of_freedom(model)
return (
-2 * model.objective(model.soln)
+ np.log(model.N * model.inlier_percentage) * degree_of_freedom
)

0 comments on commit bbda09e

Please sign in to comment.