Skip to content

Commit

Permalink
implemented divergence measure
Browse files Browse the repository at this point in the history
  • Loading branch information
JustGlowing committed Aug 27, 2024
1 parent 1dd68be commit d8e95cb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions minisom.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,18 @@ def quantization_error(self, data):
self._check_input_len(data)
return norm(data-self.quantization(data), axis=1).mean()

def divergence_measure(self, data):
"""Returns the divergence measure computed as
sum_i, sum_c (neighborhood(c, sigma) * || d_i - w_c ||^2
"""
divergence = []
for d in data:
divergence.append(multiply(self.neighborhood(self.winner(d),
self._sigma),
norm(d-self.get_weights(),
axis=2)).sum())
return sum(divergence)

def topographic_error(self, data):
"""Returns the topographic error computed by finding
the best-matching and second-best-matching neuron in the map
Expand Down

0 comments on commit d8e95cb

Please sign in to comment.