

import math



class    _a						:


					'''simple docstring'''






					def   __A      (			self   ,	A__   ,	A__      ):
						A__							:   List[Any]					       =		0.0
						A__							:   int					       =		0.0
						for i in range(len(A__      )      ):
							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   ,	A__   ,	A__   ,	A__   ,	A__      ):







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



def 						UpperCamelCase ()					->				Any:
	A__							:   List[Any]					       =		[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

	# training
	A__							:   Tuple					       =		SelfOrganizingMap()
	A__							:   Union[str, Any]					       =		3
	A__							:   Optional[int]					       =		0.5

	for _ in range(lowerCamelCase__ ):
		for j in range(len(lowerCamelCase__ ) ):
			# training sample
			A__							:   int					       =		training_samples[j]

			# Compute the winning vector
			A__							:   str					       =		self_organizing_map.get_winner(lowerCamelCase__   ,				lowerCamelCase__ )

			# Update the winning vector
			A__							:   Optional[int]					       =		self_organizing_map.update(lowerCamelCase__   ,				lowerCamelCase__   ,				lowerCamelCase__   ,				lowerCamelCase__ )

    # classify test sample
	A__							:   Tuple					       =		[0, 0, 0, 1]
	A__							:   Optional[Any]					       =		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 typing import Any

def 						UpperCamelCase (lowercase_:			list )					->				list[Any]:
	if not input_list:
		return []
	A__							:   Any					       =		[input_list.count(lowercase_ ) for value in input_list]
	A__							:   List[Any]					       =		max(lowercase_ )  # Gets the maximum count in the input list.
	# Gets values of modes
	return sorted({input_list[i] for i, value in enumerate(lowercase_ ) if value == y} )


if __name__ == "__main__":
	import doctest

	doctest.testmod()



