





import math





class 			lowerCAmelCase__:






       '''simple docstring'''


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






def     lowerCamelCase__			():
     _SCREAMING_SNAKE_CASE       :	List[Any]						    =							[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

     # training
     _SCREAMING_SNAKE_CASE       :	Optional[int]						    =							SelfOrganizingMap()
     _SCREAMING_SNAKE_CASE       :	Any						    =							3
     _SCREAMING_SNAKE_CASE       :	Dict						    =							0.5

     for _ in range(__snake_case	):
          for j in range(len(__snake_case	)	):
               # training sample
               _SCREAMING_SNAKE_CASE       :	List[Any]						    =							training_samples[j]

               # Compute the winning vector
               _SCREAMING_SNAKE_CASE       :	Tuple						    =							self_organizing_map.get_winner(__snake_case,       __snake_case	)

               # Update the winning vector
               _SCREAMING_SNAKE_CASE       :	Union[str, Any]						    =							self_organizing_map.update(__snake_case,       __snake_case,       __snake_case,       __snake_case	)

    # classify test sample
     _SCREAMING_SNAKE_CASE       :	Optional[int]						    =							[0, 0, 0, 1]
     _SCREAMING_SNAKE_CASE       :	int						    =							self_organizing_map.get_winner(__snake_case,       __snake_case	)

     # 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()






import cmath
import math






def     lowerCamelCase__			(__lowerCamelCase,       __lowerCamelCase,       __lowerCamelCase,       __lowerCamelCase	):
     _SCREAMING_SNAKE_CASE       :	Any						    =							math.radians(__lowerCamelCase	)
     _SCREAMING_SNAKE_CASE       :	Tuple						    =							math.radians(__lowerCamelCase	)

     # Convert voltage and current to rectangular form
     _SCREAMING_SNAKE_CASE       :	str						    =							cmath.rect(__lowerCamelCase,       __lowerCamelCase	)
     _SCREAMING_SNAKE_CASE       :	str						    =							cmath.rect(__lowerCamelCase,       __lowerCamelCase	)

     # Calculate apparent power
     return voltage_rect * current_rect


if __name__ == "__main__":
       import doctest

       doctest.testmod()