"""simple docstring"""



import math






class  snake_case__      :


 def 						a__   ( self    ,		lowerCamelCase    ,		lowerCamelCase						):
        __a       =    0.0
        __a       =    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 						a__   ( self    ,		lowerCamelCase    ,		lowerCamelCase    ,		lowerCamelCase    ,		lowerCamelCase						):







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



def 	_lowerCamelCase(	):
       # Training Examples ( m, n )
       __a       =    [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

                     # Compute the winning vector
                     __a       =    self_organizing_map.get_winner(UpperCamelCase__   ,    UpperCamelCase__				)

                     # Update the winning vector
                     __a       =    self_organizing_map.update(UpperCamelCase__   ,    UpperCamelCase__   ,    UpperCamelCase__   ,    UpperCamelCase__				)

    # classify test sample
       __a       =    [0, 0, 0, 1]
       __a       =    self_organizing_map.get_winner(UpperCamelCase__   ,    UpperCamelCase__				)

       # 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_   (      UpperCamelCase__			,		UpperCamelCase__ = " "		):
      UpperCamelCase__     : Optional[int]											=					[]

      UpperCamelCase__     : int											=					0
      for index, char in enumerate(UpperCamelCase__		):
            if char == separator:
                  split_words.append(string[last_index:index]		)
                  UpperCamelCase__     : int											=					index + 1
            elif index + 1 == len(UpperCamelCase__		):
                  split_words.append(string[last_index : index + 1]		)
      return split_words


if __name__ == "__main__":
    from doctest import testmod

    testmod()


