






import math


class        __UpperCamelCase    :







	def  _a   (  self      :							int       ,				_lowerCAmelCase      :							list[list[float]]       ,				_lowerCAmelCase      :							list[int]			)		-> int:
		"""simple docstring"""







		__lowercase             =  0.0
		__lowercase             =  0.0
		for i in range(len(_lowerCAmelCase			)			):
			da += math.pow((sample[i] - weights[0][i])       ,				2			)
			da += math.pow((sample[i] - weights[1][i])       ,				2			)
			return 0 if da > da else 1
		return 0







	def  _a   (  self      :							str       ,				_lowerCAmelCase      :							list[list[int | float]]       ,				_lowerCAmelCase      :							list[int]       ,				_lowerCAmelCase      :							int       ,				_lowerCAmelCase      :							float			)		-> list[list[int | float]]:
		"""simple docstring"""







		for i in range(len(_lowerCAmelCase			)			):
			weights[j][i] += alpha * (sample[i] - weights[j][i])
		return weights





def 				snake_case  (     ):




	'''simple docstring'''







	__lowercase             =  [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

	# weight initialization ( n, C )
	__lowercase             =  [[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

	# training
	__lowercase             =  SelfOrganizingMap()
	__lowercase             =  3
	__lowercase             =  0.5

	for _ in range(lowerCamelCase					):
		for j in range(len(lowerCamelCase					)					):
			# training sample
			__lowercase             =  training_samples[j]

			# Compute the winning vector
			__lowercase             =  self_organizing_map.get_winner(lowerCamelCase				,  lowerCamelCase					)

			# Update the winning vector
			__lowercase             =  self_organizing_map.update(lowerCamelCase				,  lowerCamelCase				,  lowerCamelCase				,  lowerCamelCase					)

    # classify test sample
	__lowercase             =  [0, 0, 0, 1]
	__lowercase             =  self_organizing_map.get_winner(lowerCamelCase				,  lowerCamelCase					)

	# results
	print(F'Clusters that the test sample belongs to : {winner}'					)
	print(F'Weights that have been trained : {weights}'					)


# running the main() function
if __name__ == "__main__":
						main()










from __future__ import annotations





def 				snake_case  (     lowerCamelCase					):




	'''simple docstring'''







	if not nums:
		return 0
	__lowercase             =  nums[0]
	__lowercase             =  0
	for num in nums[1:]:
		__lowercase       ,						__lowercase             =  (
		    max_excluding + num,
		    max(lowerCamelCase				,  lowerCamelCase					),
		)
	return max(lowerCamelCase				,  lowerCamelCase					)


if __name__ == "__main__":
						import doctest

						doctest.testmod()

