



"""simple docstring"""




import numpy

# List of input, output pairs
_lowerCAmelCase    : List[Any]							=							(
    ((5, 2, 3), 15),
    ((6, 5, 9), 25),
    ((11, 12, 13), 41),
    ((1, 1, 1), 8),
    ((11, 12, 13), 41),
)
_lowerCAmelCase    : Tuple							=							(((5_15, 22, 13), 5_55), ((61, 35, 49), 1_50))
_lowerCAmelCase    : List[str]							=							[2, 4, 1, 5]
_lowerCAmelCase    : Optional[int]							=							len(train_data)
_lowerCAmelCase    : int							=							0.0_0_9

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[Any]						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]="train"    )  ->       Tuple:





     '''simple docstring'''

     return calculate_hypothesis_value(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ) - output(
         SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Tuple    )  ->       Dict:





     '''simple docstring'''

     _UpperCAmelCase      :     List[Any]        =   0
     for i in range(len(SCREAMING_SNAKE_CASE__    ) - 1    ):
          hyp_val += data_input_tuple[i] * parameter_vector[i + 1]
     hyp_val += parameter_vector[0]
     return hyp_val

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						str						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]    )  ->       str:





     '''simple docstring'''

     if data_set == "train":
          return train_data[example_no][1]
     elif data_set == "test":
          return test_data[example_no][1]
     return None

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Dict						,  SCREAMING_SNAKE_CASE__     :						Any    )  ->       Optional[int]:





     '''simple docstring'''

     if data_set == "train":
          return _hypothesis_value(train_data[example_no][0]    )
     elif data_set == "test":
          return _hypothesis_value(test_data[example_no][0]    )
     return None

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Union[str, Any]						,  SCREAMING_SNAKE_CASE__     :						Dict=m    )  ->       str:





     '''simple docstring'''

     _UpperCAmelCase      :     Optional[Any]        =   0
     for i in range(SCREAMING_SNAKE_CASE__    ):
          if index == -1:
               summation_value += _error(SCREAMING_SNAKE_CASE__    )
          else:
               summation_value += _error(SCREAMING_SNAKE_CASE__    ) * train_data[i][0][index]
     return summation_value

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Optional[Any]    )  ->       Tuple:





     '''simple docstring'''

     _UpperCAmelCase      :     Tuple        =   summation_of_cost_derivative(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ) / m
     return cost_derivative_value

def 						__snake_case						(				)  ->       Optional[Any]:





     '''simple docstring'''

     global parameter_vector
     # Tune these values to set a tolerance value for predicted output
     _UpperCAmelCase      :     List[str]        =   0.000_002
     _UpperCAmelCase      :     Optional[Any]        =   0
     _UpperCAmelCase      :     Union[str, Any]        =   0
     while True:
          j += 1
          _UpperCAmelCase      :     Optional[Any]        =   [0, 0, 0, 0]
          for i in range(0						,  len(SCREAMING_SNAKE_CASE__    )    ):
               _UpperCAmelCase      :     List[str]        =   get_cost_derivative(i - 1    )
               _UpperCAmelCase      :     Optional[int]        =   (
                   parameter_vector[i] - LEARNING_RATE * cost_derivative
               )
          if numpy.allclose(
              SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  atol=SCREAMING_SNAKE_CASE__						,  rtol=SCREAMING_SNAKE_CASE__						,  ):
               break
          _UpperCAmelCase      :     List[Any]        =   temp_parameter_vector
     print(("Number of iterations:", j)    )

def 						__snake_case						(				)  ->       str:





     '''simple docstring'''

     for i in range(len(SCREAMING_SNAKE_CASE__    )    ):
          print(("Actual output value:", output(SCREAMING_SNAKE_CASE__						,  "test"    ))    )
          print(("Hypothesis output:", calculate_hypothesis_value(SCREAMING_SNAKE_CASE__						,  "test"    ))    )


if __name__ == "__main__":
   run_gradient_descent()
   print("\nTesting gradient descent for a linear hypothesis function.\n")
   test_gradient_descent()





"""simple docstring"""




def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						list    )  ->       list:





     '''simple docstring'''

     if len(SCREAMING_SNAKE_CASE__    ) < 2:
          return collection

     def circle_sort_util(SCREAMING_SNAKE_CASE__     :						list						,  SCREAMING_SNAKE_CASE__     :						int						,  SCREAMING_SNAKE_CASE__     :						int    ) -> bool:
          _UpperCAmelCase      :     Dict        =   False

          if low == high:
               return swapped

          _UpperCAmelCase      :     str        =   low
          _UpperCAmelCase      :     Dict        =   high

          while left < right:
               if collection[left] > collection[right]:
                    _UpperCAmelCase    ,	_UpperCAmelCase      :     List[str]        =   (
                        collection[right],
                        collection[left],
                    )
                    _UpperCAmelCase      :     Optional[int]        =   True

               left += 1
               right -= 1

          if left == right and collection[left] > collection[right + 1]:
               _UpperCAmelCase    ,	_UpperCAmelCase      :     int        =   (
                   collection[right + 1],
                   collection[left],
               )

               _UpperCAmelCase      :     Union[str, Any]        =   True

          _UpperCAmelCase      :     Dict        =   low + int((high - low) / 2    )
          _UpperCAmelCase      :     Any        =   circle_sort_util(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
          _UpperCAmelCase      :     Optional[Any]        =   circle_sort_util(SCREAMING_SNAKE_CASE__						,  mid + 1						,  SCREAMING_SNAKE_CASE__    )

          return swapped or left_swap or right_swap

     _UpperCAmelCase      :     Tuple        =   True

     while is_not_sorted is True:
          _UpperCAmelCase      :     Dict        =   circle_sort_util(SCREAMING_SNAKE_CASE__						,  0						,  len(SCREAMING_SNAKE_CASE__    ) - 1    )

     return collection


if __name__ == "__main__":
 _lowerCAmelCase    : Dict							=							input("Enter numbers separated by a comma:\n").strip()
 _lowerCAmelCase    : Optional[Any]							=							[int(item) for item in user_input.split(",")]
 print(circle_sort(unsorted))
