





'''simple docstring'''

import numpy

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

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase="train"      )						->					Union[str, Any]:

   '''simple docstring'''







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

def 						__magic_name__       (							__UpperCAmelCase      )						->					List[Any]:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       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 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					Optional[int]:

   '''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 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					str:

   '''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 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase=m      )						->					Optional[int]:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       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 						__magic_name__       (							__UpperCAmelCase      )						->					Union[str, Any]:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       summation_of_cost_derivative(__UpperCAmelCase							,	__UpperCAmelCase      ) / m
   return cost_derivative_value

def 						__magic_name__       (							)						->					Any:

   '''simple docstring'''







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

def 						__magic_name__       (							)						->					str:

   '''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'''

from __future__ import annotations

import bisect

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase = 0							,	__UpperCAmelCase = -1      )						->					int:

   '''simple docstring'''







   if hi < 0:
      __SCREAMING_SNAKE_CASE      							=       len(__UpperCAmelCase      )

   while lo < hi:
      __SCREAMING_SNAKE_CASE      							=       lo + (hi - lo) // 2
      if sorted_collection[mid] < item:
         __SCREAMING_SNAKE_CASE      							=       mid + 1
      else:
         __SCREAMING_SNAKE_CASE      							=       mid

   return lo

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase = 0							,	__UpperCAmelCase = -1      )						->					int:

   '''simple docstring'''







   if hi < 0:
      __SCREAMING_SNAKE_CASE      							=       len(__UpperCAmelCase      )

   while lo < hi:
      __SCREAMING_SNAKE_CASE      							=       lo + (hi - lo) // 2
      if sorted_collection[mid] <= item:
         __SCREAMING_SNAKE_CASE      							=       mid + 1
      else:
         __SCREAMING_SNAKE_CASE      							=       mid

   return lo

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase = 0							,	__UpperCAmelCase = -1      )						->					None:

   '''simple docstring'''







   sorted_collection.insert(bisect_left(__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase      )							,	__UpperCAmelCase      )

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase = 0							,	__UpperCAmelCase = -1      )						->					None:

   '''simple docstring'''







   sorted_collection.insert(bisect_right(__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase      )							,	__UpperCAmelCase      )

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					int | None:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       0
   __SCREAMING_SNAKE_CASE      							=       len(__UpperCAmelCase      ) - 1

   while left <= right:
      __SCREAMING_SNAKE_CASE      							=       left + (right - left) // 2
      __SCREAMING_SNAKE_CASE      							=       sorted_collection[midpoint]
      if current_item == item:
         return midpoint
      elif item < current_item:
         __SCREAMING_SNAKE_CASE      							=       midpoint - 1
      else:
         __SCREAMING_SNAKE_CASE      							=       midpoint + 1
   return None

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					int | None:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       bisect.bisect_left(__UpperCAmelCase							,	__UpperCAmelCase      )
   if index != len(__UpperCAmelCase      ) and sorted_collection[index] == item:
      return index
   return None

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase      )						->					int | None:

   '''simple docstring'''







   if right < left:
      return None

   __SCREAMING_SNAKE_CASE      							=       left + (right - left) // 2

   if sorted_collection[midpoint] == item:
      return midpoint
   elif sorted_collection[midpoint] > item:
      return binary_search_by_recursion(__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase							,	midpoint - 1      )
   else:
      return binary_search_by_recursion(__UpperCAmelCase							,	__UpperCAmelCase							,	midpoint + 1							,	__UpperCAmelCase      )


if __name__ == "__main__":
    a        =						input("Enter numbers separated by comma:\n").strip()
    a        =						sorted(int(item) for item in user_input.split(","))
    a        =						int(input("Enter a single number to be found in the list:\n"))
    a        =						binary_search(collection, target)
    if result is None:
        print(F'''{target} was not found in {collection}.''')
    else:
        print(F'''{target} was found at position {result} in {collection}.''')





