


"""simple docstring"""




import math
class 			SCREAMING_SNAKE_CASE__  :
      def 	SCREAMING_SNAKE_CASE							(	self    :	int					,							SCREAMING_SNAKE_CASE__    :	Tuple					,							SCREAMING_SNAKE_CASE__    :	List[Any]					)		->      int:
             a_ :		List[Any]							=  0.0
             a_ :		Optional[Any]							=  0.0
             for i in range(len(SCREAMING_SNAKE_CASE__					)					):
                    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 	SCREAMING_SNAKE_CASE							(	self    :	Dict					,							SCREAMING_SNAKE_CASE__    :	int					,							SCREAMING_SNAKE_CASE__    :	Optional[int]					,							SCREAMING_SNAKE_CASE__    :	Any					,							SCREAMING_SNAKE_CASE__    :	Any					)		->      list[list[int | float]]:







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







def 	SCREAMING_SNAKE_CASE_						(      )     ->		List[Any]:

       """simple docstring"""

       a_ :		str							=  [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

       for _ in range(lowerCamelCase__    ):
              for j in range(len(lowerCamelCase__    )    ):
                     # training sample
                     a_ :		Union[str, Any]							=  training_samples[j]

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

                     # Update the winning vector
                     a_ :		List[str]							=  self_organizing_map.update(lowerCamelCase__  ,   lowerCamelCase__  ,   lowerCamelCase__  ,   lowerCamelCase__    )

    # classify test sample
       a_ :		List[Any]							=  [0, 0, 0, 1]
       a_ :		Dict							=  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()






def 	SCREAMING_SNAKE_CASE_						(      __A			:      list    )     ->		bool:

       """simple docstring"""

       if not isinstance(__A  ,   __A    ):
              raise ValueError('Input series is not valid, valid series - [2, 4, 6]'    )
       if len(__A    ) == 0:
              raise ValueError('Input list must be a non empty list'    )
       if len(__A    ) == 1:
              return True
       a_ :		Tuple							=  series[1] - series[0]
       for index in range(len(__A    ) - 1    ):
              if series[index + 1] - series[index] != common_diff:
                     return False
       return True







def 	SCREAMING_SNAKE_CASE_						(      __A			:      list    )     ->		float:

       """simple docstring"""

       if not isinstance(__A  ,   __A    ):
              raise ValueError('Input series is not valid, valid series - [2, 4, 6]'    )
       if len(__A    ) == 0:
              raise ValueError('Input list must be a non empty list'    )
       a_ :		str							=  0
       for val in series:
              answer += val
       return answer / len(__A    )


if __name__ == "__main__":
   import doctest

   doctest.testmod()


