


import numpy

# List of input, output pairs
__snake_case   							=						(
    ((5, 2, 3), 1_5),
    ((6, 5, 9), 2_5),
    ((1_1, 1_2, 1_3), 4_1),
    ((1, 1, 1), 8),
    ((1_1, 1_2, 1_3), 4_1),
)
__snake_case   							=						(((5_1_5, 2_2, 1_3), 5_5_5), ((6_1, 3_5, 4_9), 1_5_0))
__snake_case   							=						[2, 4, 1, 5]
__snake_case   							=						len(train_data)
__snake_case   							=						0.009






def 		_A		(		_lowercase					,  _lowercase="train" )					-> Union[str, Any]:


     """simple docstring"""


     return calculate_hypothesis_value(_lowercase					,  _lowercase ) - output(
         _lowercase					,  _lowercase )






def 		_A		(		_lowercase )					-> str:


     """simple docstring"""


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






def 		_A		(		_lowercase					,  _lowercase )					-> List[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 		_A		(		_lowercase					,  _lowercase )					-> Tuple:


     """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 		_A		(		_lowercase					,  _lowercase=m )					-> List[str]:


     """simple docstring"""


     __UpperCamelCase =			0
     for i in range(_lowercase ):
          if index == -1:
               summation_value += _error(_lowercase )
          else:
               summation_value += _error(_lowercase ) * train_data[i][0][index]
     return summation_value






def 		_A		(		_lowercase )					-> Optional[int]:


     """simple docstring"""


     __UpperCamelCase =			summation_of_cost_derivative(_lowercase					,  _lowercase ) / m
     return cost_derivative_value






def 		_A		(		)					-> Any:


     """simple docstring"""


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






def 		_A		(		)					-> Optional[Any]:


     """simple docstring"""


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


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






import string






def 		_A		(		_lowercase )					-> None:


     """simple docstring"""


     for key in range(len(string.ascii_uppercase ) ):
          __UpperCamelCase =			''
          for symbol in message:
               if symbol in string.ascii_uppercase:
                    __UpperCamelCase =			string.ascii_uppercase.find(_lowercase )
                    __UpperCamelCase =			num - key
                    if num < 0:
                         __UpperCamelCase =			num + len(string.ascii_uppercase )
                    __UpperCamelCase =			translated + string.ascii_uppercase[num]
               else:
                    __UpperCamelCase =			translated + symbol
          print(f'''Decryption using Key #{key}: {translated}''' )






def 		_A		(		)					-> None:


     """simple docstring"""


     __UpperCamelCase =			input('Encrypted message: ' )
     __UpperCamelCase =			message.upper()
     decrypt(_lowercase )


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    main()


