



'''simple docstring'''





import math






class        lowerCAmelCase_:
  '''simple docstring'''




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







def    _SCREAMING_SNAKE_CASE  (       ):



    """simple docstring"""





    lowerCAmelCase__ :  Dict							      =					[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

    # training
    lowerCAmelCase__ :  List[Any]							      =					SelfOrganizingMap()
    lowerCAmelCase__ :  Dict							      =					3
    lowerCAmelCase__ :  Optional[Any]							      =					0.5

    for _ in range(UpperCamelCase			):
        for j in range(len(UpperCamelCase			)			):
            # training sample
            lowerCAmelCase__ :  Optional[int]							      =					training_samples[j]

            # Compute the winning vector
            lowerCAmelCase__ :  Dict							      =					self_organizing_map.get_winner(UpperCamelCase							,    UpperCamelCase			)

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

    # classify test sample
    lowerCAmelCase__ :  Union[str, Any]							      =					[0, 0, 0, 1]
    lowerCAmelCase__ :  str							      =					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()







'''simple docstring'''





def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase = "The quick brown fox jumps over the lazy dog"							,    ):



    """simple docstring"""





    lowerCAmelCase__ :  str							      =					set()

    # Replace all the whitespace in our sentence
    lowerCAmelCase__ :  Tuple							      =					input_str.replace(""" """							,    """"""			)
    for alpha in input_str:
        if "a" <= alpha.lower() <= "z":
            frequency.add(alpha.lower()			)
    return len(UpperCamelCase			) == 26
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase = "The quick brown fox jumps over the lazy dog"							,    ):



    """simple docstring"""





    lowerCAmelCase__ :  Any							      =					[False] * 26
    for char in input_str:
        if char.islower():
            lowerCAmelCase__ :  Optional[Any]							      =					True
        elif char.isupper():
            lowerCAmelCase__ :  Any							      =					True
    return all(UpperCamelCase			)
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase = "The quick brown fox jumps over the lazy dog"							,    ):



    """simple docstring"""





    return len({char for char in input_str.lower() if char.isalpha()}			) == 26
def    _SCREAMING_SNAKE_CASE  (       ):



    """simple docstring"""





    from timeit import timeit

    lowerCAmelCase__ :  Union[str, Any]							      =					"""from __main__ import is_pangram, is_pangram_faster, is_pangram_fastest"""
    print(timeit("""is_pangram()"""							,    setup=UpperCamelCase			)			)
    print(timeit("""is_pangram_faster()"""							,    setup=UpperCamelCase			)			)
    print(timeit("""is_pangram_fastest()"""							,    setup=UpperCamelCase			)			)
    # 5.348480500048026, 2.6477354579837993, 1.8470395830227062
    # 5.036091582966037, 2.644472333951853,  1.8869528750656173


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 benchmark()


