

from __future__ import annotations

import math

_SCREAMING_SNAKE_CASE  :						Optional[Any]         =    '''2020.9.26'''
_SCREAMING_SNAKE_CASE  :						Optional[int]         =    '''xcodz-dot, cclaus, dhruvmanila'''
def        UpperCAmelCase_     (		_A   ,	_A   ,	_A   ,	_A   ,	_A       ):





     '''simple docstring'''




     if not all(isinstance(_A   ,	(float, int)       ) for val in locals().values()       ):
          SCREAMING_SNAKE_CASE__					=					F'''Input values must either be float or int: {list(locals().values()       )}'''
          raise TypeError(_A       )
     SCREAMING_SNAKE_CASE__					=					((x * distance) / (z + distance)) * scale
     SCREAMING_SNAKE_CASE__					=					((y * distance) / (z + distance)) * scale
     return projected_x, projected_y
def        UpperCAmelCase_     (		_A   ,	_A   ,	_A   ,	_A   ,	_A       ):





     '''simple docstring'''




     if not isinstance(_A   ,	_A       ):
          raise TypeError('''Axis must be a str'''       )
     SCREAMING_SNAKE_CASE__					=					locals()
     del input_variables["axis"]
     if not all(isinstance(_A   ,	(float, int)       ) for val in input_variables.values()       ):
          SCREAMING_SNAKE_CASE__					=					(
              '''Input values except axis must either be float or int: '''
              F'''{list(input_variables.values()       )}'''
          )
          raise TypeError(_A       )
     SCREAMING_SNAKE_CASE__					=					(angle % 3_60) / 4_50 * 1_80 / math.pi
     if axis == "z":
          SCREAMING_SNAKE_CASE__					=					x * math.cos(_A       ) - y * math.sin(_A       )
          SCREAMING_SNAKE_CASE__					=					y * math.cos(_A       ) + x * math.sin(_A       )
          SCREAMING_SNAKE_CASE__					=					z
     elif axis == "x":
          SCREAMING_SNAKE_CASE__					=					y * math.cos(_A       ) - z * math.sin(_A       )
          SCREAMING_SNAKE_CASE__					=					z * math.cos(_A       ) + y * math.sin(_A       )
          SCREAMING_SNAKE_CASE__					=					x
     elif axis == "y":
          SCREAMING_SNAKE_CASE__					=					x * math.cos(_A       ) - z * math.sin(_A       )
          SCREAMING_SNAKE_CASE__					=					z * math.cos(_A       ) + x * math.sin(_A       )
          SCREAMING_SNAKE_CASE__					=					y
     else:
          raise ValueError('''not a valid axis, choose one of \'x\', \'y\', \'z\''''       )

     return new_x, new_y, new_z


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   print(F"{convert_to_ad(1.0, 2.0, 3.0, 10.0, 10.0) = }")
   print(F"{rotate(1.0, 2.0, 3.0, 'y', 90.0) = }")





import math






class  UpperCAmelCase__	:






  """simple docstring"""


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



def        UpperCAmelCase_     (		):





     '''simple docstring'''




     SCREAMING_SNAKE_CASE__					=					[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

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

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

    # classify test sample
     SCREAMING_SNAKE_CASE__					=					[0, 0, 0, 1]
     SCREAMING_SNAKE_CASE__					=					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()


