






"""simple docstring"""





import math


class      _lowercase :


      def _UpperCamelCase						(    self				:	Dict							,   a				:	list[list[float]]							,   a				:	list[int]						):





            """simple docstring"""







            __snake_case      :    List[str]  			=0.0
            __snake_case      :    List[str]  			=0.0
            for i in range(len(a						)						):
                  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				:	Optional[int]							,   a				:	list[list[int | float]]							,   a				:	list[int]							,   a				:	int							,   a				:	float						):





            """simple docstring"""







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



def     __lowercase					(    )					->					None:
      # Training Examples ( m, n )
      __snake_case      :    Optional[Any]  			=[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

      # weight initialization ( n, C )
      __snake_case      :    Union[str, Any]  			=[[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

      # training
      __snake_case      :    Union[str, Any]  			=SelfOrganizingMap()
      __snake_case      :    List[Any]  			=3
      __snake_case      :    Optional[int]  			=0.5

      for _ in range(a ):
            for j in range(len(a ) ):
                  # training sample
                  __snake_case      :    Any  			=training_samples[j]

                  # Compute the winning vector
                  __snake_case      :    Tuple  			=self_organizing_map.get_winner(a       ,		a )

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

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










"""simple docstring"""





from __future__ import annotations



def     __lowercase					(    a :				int       ,		a :				int )					->					list[str]:
      if partitions <= 0:
            raise ValueError('''partitions must be a positive number!''' )
      if partitions > number_of_bytes:
            raise ValueError('''partitions can not > number_of_bytes!''' )
      __snake_case      :    List[str]  			=number_of_bytes // partitions
      __snake_case      :    str  			=[]
      for i in range(a ):
            __snake_case      :    Optional[Any]  			=i * bytes_per_partition + 1
            __snake_case      :    Any  			=(
                number_of_bytes if i == partitions - 1 else (i + 1) * bytes_per_partition
            )
            allocation_list.append(f'''{start_bytes}-{end_bytes}''' )
      return allocation_list


if __name__ == "__main__":
    import doctest

    doctest.testmod()


