





"""simple docstring"""





import numpy as np




def 						lowerCAmelCase_      (    lowercase_  :				Optional[Any]						):

 '''simple docstring'''






 return 1 / (1 + np.exp(-vector						))




def 						lowerCAmelCase_      (    lowercase_  :				str						):

 '''simple docstring'''






 return vector * sigmoid(_A						)


if __name__ == "__main__":
    import doctest

    doctest.testmod()



"""simple docstring"""



import math




class 		a_    :







    def   _snake_case       (      self      :							List[Any]  ,       __UpperCamelCase      :							list[list[float]]  ,       __UpperCamelCase      :							list[int]  )		->int:






        '''simple docstring'''






        _UpperCAmelCase        = 0.0
        _UpperCAmelCase        = 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   _snake_case       (      self      :							Dict  ,       __UpperCamelCase      :							list[list[int | float]]  ,       __UpperCamelCase      :							list[int]  ,       __UpperCamelCase      :							int  ,       __UpperCamelCase      :							float  )		->list[list[int | float]]:






        '''simple docstring'''






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







def 			_UpperCamelCase						(    )     ->	None:





    """simple docstring"""

    _UpperCAmelCase        = [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

            # Compute the winning vector
            _UpperCAmelCase        = self_organizing_map.get_winner(_A       ,   _A   )

            # Update the winning vector
            _UpperCAmelCase        = self_organizing_map.update(_A       ,   _A       ,   _A       ,   _A   )

    # classify test sample
    _UpperCAmelCase        = [0, 0, 0, 1]
    _UpperCAmelCase        = self_organizing_map.get_winner(_A       ,   _A   )

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