Skip to content

Commit

Permalink
going back
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirva Patel authored and Hirva Patel committed Oct 10, 2023
1 parent 72625f8 commit 98e910c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions polire/idw/idw.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,13 @@ def _predict(self, X):
"""

dist = self.distance(self.X, X)
for i in range(len(dist)):
for j in range(len(dist[0])):
if (dist[i][j]==0):
dist[i][j] = 1.0e-10

weights = 1 / np.power(dist, self.exponent)
result = (weights * self.y[:, None]).sum(axis=0) / weights.sum(axis=0)

# if point is from train data, ground truth must not change
# for i in range(X.shape[0]):
# mask = np.equal(X[i], self.X).all(axis=1)
# if mask.any():
# result[i] = (self.y * mask).sum()
for i in range(X.shape[0]):
mask = np.equal(X[i], self.X).all(axis=1)
if mask.any():
result[i] = (self.y * mask).sum()

return result

0 comments on commit 98e910c

Please sign in to comment.