






import numpy

# List of input, output pairs
UpperCamelCase__ =			(
    ((5, 2, 3), 15),
    ((6, 5, 9), 25),
    ((11, 12, 13), 41),
    ((1, 1, 1), 8),
    ((11, 12, 13), 41),
)
UpperCamelCase__ =			(((515, 22, 13), 555), ((61, 35, 49), 150))
UpperCamelCase__ =			[2, 4, 1, 5]
UpperCamelCase__ =			len(train_data)
UpperCamelCase__ =			0.0_09




def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase						,		_UpperCamelCase="train"							):


   """simple docstring"""




   return calculate_hypothesis_value(__UpperCAmelCase						,		__UpperCAmelCase							) - output(
       __UpperCAmelCase						,		__UpperCAmelCase							)




def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase							):


   """simple docstring"""




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




def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase						,		_UpperCamelCase							):


   """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 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase						,		_UpperCamelCase							):


   """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 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase						,		_UpperCamelCase=m							):


   """simple docstring"""




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




def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase							):


   """simple docstring"""




   lowercase_	:    str           =     summation_of_cost_derivative(__UpperCAmelCase						,		__UpperCAmelCase							) / m
   return cost_derivative_value




def 		__SCREAMING_SNAKE_CASE					(  ):


   """simple docstring"""




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




def 		__SCREAMING_SNAKE_CASE					(  ):


   """simple docstring"""




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


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












'''simple docstring'''
def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase							):


   """simple docstring"""




   lowercase_	:    Any           =     False
   while is_sorted is False:  # Until all the indices are traversed keep looping
      lowercase_	:    List[str]           =     True
      for i in range(0						,		len(_UpperCamelCase							) - 1						,		2							):  # iterating over all even indices
         if input_list[i] > input_list[i + 1]:
            lowercase_    ,		lowercase_	:    Union[str, Any]           =     input_list[i + 1], input_list[i]
            # swapping if elements not in order
            lowercase_	:    Any           =     False

      for i in range(1						,		len(_UpperCamelCase							) - 1						,		2							):  # iterating over all odd indices
         if input_list[i] > input_list[i + 1]:
            lowercase_    ,		lowercase_	:    Tuple           =     input_list[i + 1], input_list[i]
            # swapping if elements not in order
            lowercase_	:    List[Any]           =     False
   return input_list


if __name__ == "__main__":
 print('Enter list to be sorted')
 UpperCamelCase__ =			[int(x) for x in input().split()]
 # inputing elements of the list in one line
 UpperCamelCase__ =			odd_even_sort(input_list)
 print('The sorted list is')
 print(sorted_list)




