MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / update

Method update

machine_learning/self_organizing_map.py:24–35  ·  view source on GitHub ↗

Update the winning vector. >>> SelfOrganizingMap().update([[1, 2, 3], [4, 5, 6]], [1, 2, 3], 1, 0.1) [[1, 2, 3], [3.7, 4.7, 6]]

(
        self, weights: list[list[int | float]], sample: list[int], j: int, alpha: float
    )

Source from the content-addressed store, hash-verified

22 return 0
23
24 def update(
25 self, weights: list[list[int | float]], sample: list[int], j: int, alpha: float
26 ) -> list[list[int | float]]:
27 """
28 Update the winning vector.
29
30 >>> SelfOrganizingMap().update([[1, 2, 3], [4, 5, 6]], [1, 2, 3], 1, 0.1)
31 [[1, 2, 3], [3.7, 4.7, 6]]
32 """
33 for i in range(len(weights)):
34 weights[j][i] += alpha * (sample[i] - weights[j][i])
35 return weights
36
37
38# Driver code

Callers 2

mainFunction · 0.95
plot_heterogeneityFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected