


import math







class 				snake_case__:







						'''simple docstring'''




						def 						lowercase_ (				self   ,						__lowercase   ,						__lowercase							)					->    int:
										lowerCAmelCase_ :      Any    				=				0.0
										lowerCAmelCase_ :      Tuple    				=				0.0
										for i in range(len(__lowercase							)							):
														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 						lowercase_ (				self   ,						__lowercase   ,						__lowercase   ,						__lowercase   ,						__lowercase							)					->    list[list[int | float]]:
										for i in range(len(__lowercase							)							):
														weights[j][i] += alpha * (sample[i] - weights[j][i])
										return weights






def 			lowerCAmelCase (		)-> None:
				# Training Examples ( m, n )
				lowerCAmelCase_ :      List[str]    				=				[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

				# training
				lowerCAmelCase_ :      List[Any]    				=				SelfOrganizingMap()
				lowerCAmelCase_ :      Optional[int]    				=				3
				lowerCAmelCase_ :      Optional[Any]    				=				0.5

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

												# Compute the winning vector
												lowerCAmelCase_ :      Any    				=				self_organizing_map.get_winner(lowerCAmelCase_ ,   lowerCAmelCase_ )

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

    # classify test sample
				lowerCAmelCase_ :      Any    				=				[0, 0, 0, 1]
				lowerCAmelCase_ :      List[str]    				=				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 			lowerCAmelCase (		lowerCAmelCase_ ,   lowerCAmelCase_ ,   lowerCAmelCase_ ,   )-> tuple:
				if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1:
								raise ValueError('''You cannot supply more or less than 2 values''' )
				elif electron_conc < 0:
								raise ValueError('''Electron concentration cannot be negative in a semiconductor''' )
				elif hole_conc < 0:
								raise ValueError('''Hole concentration cannot be negative in a semiconductor''' )
				elif intrinsic_conc < 0:
								raise ValueError(
								    '''Intrinsic concentration cannot be negative in a semiconductor''' )
				elif electron_conc == 0:
								return (
								    "electron_conc",
								    intrinsic_conc**2 / hole_conc,
								)
				elif hole_conc == 0:
								return (
								    "hole_conc",
								    intrinsic_conc**2 / electron_conc,
								)
				elif intrinsic_conc == 0:
								return (
								    "intrinsic_conc",
								    (electron_conc * hole_conc) ** 0.5,
								)
				else:
								return (-1, -1)


if __name__ == "__main__":
						import doctest

						doctest.testmod()