Skip to content

Commit

Permalink
Update geoshapley.py
Browse files Browse the repository at this point in the history
Incorporate the suggestion from #10
  • Loading branch information
Ziqi-Li authored Sep 24, 2024
1 parent 6d0af88 commit e5d593b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions geoshapley/geoshapley.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ def _kernel_geoshap_single(self, x, reference):
y = self.predict_f(V).reshape(-1)

#Solve WLS
ZTw = np.dot(Z.T, np.diag(weights))

#ZTw = np.dot(Z.T, np.diag(weights))
ZTw = Z.T * weights

phi = np.linalg.solve(np.dot(ZTw, Z), np.dot(ZTw, y))

return phi
Expand Down Expand Up @@ -383,4 +384,4 @@ def check_additivity(self,atol=1e-5):
total = np.sum(self.primary,axis=1) + self.geo + np.sum(self.geo_intera,axis=1)

print("Components add up to model prediction: ",
np.allclose(total+self.base_value, self.predict_f(self.X_geo).reshape(-1), atol=atol))
np.allclose(total+self.base_value, self.predict_f(self.X_geo).reshape(-1), atol=atol))

0 comments on commit e5d593b

Please sign in to comment.