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
)
| 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 |
no outgoing calls
no test coverage detected