'''simple docstring'''





import numpy

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





def 	lowerCAmelCase_				(					snake_case_       : List[Any]					,    snake_case_       : Optional[Any]="train"			)    ->      int:


     '''simple docstring'''




     return calculate_hypothesis_value(_snake_case					,    _snake_case			) - output(
         _snake_case					,    _snake_case			)





def 	lowerCAmelCase_				(					snake_case_       : Union[str, Any]			)    ->      str:


     '''simple docstring'''




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





def 	lowerCAmelCase_				(					snake_case_       : str					,    snake_case_       : str			)    ->      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 	lowerCAmelCase_				(					snake_case_       : str					,    snake_case_       : Union[str, Any]			)    ->      Optional[Any]:


     '''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 	lowerCAmelCase_				(					snake_case_       : Optional[Any]					,    snake_case_       : Tuple=m			)    ->      Optional[Any]:


     '''simple docstring'''




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





def 	lowerCAmelCase_				(					snake_case_       : Optional[int]			)    ->      Dict:


     '''simple docstring'''




     UpperCAmelCase_           =   summation_of_cost_derivative(_snake_case					,    _snake_case			) / m
     return cost_derivative_value





def 	lowerCAmelCase_				(					)    ->      str:


     '''simple docstring'''




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





def 	lowerCAmelCase_				(					)    ->      int:


     '''simple docstring'''




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


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








"""simple docstring"""
import math






def 		lowercase							(     _snake_case						:      int     )     ->bool:
	"""simple docstring"""





	if 1 < number < 4:
		# 2 and 3 are primes
		return True
	elif number < 2 or number % 2 == 0 or number % 3 == 0:
		# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
		return False

	# All primes number are in format of 6k +/- 1
	for i in range(5     ,   int(math.sqrt(_snake_case     ) + 1     )     ,   6     ):
		if number % i == 0 or number % (i + 2) == 0:
			return False
	return True






def 		lowercase							(     _snake_case						:      float = 0.1     )     ->int:
	"""simple docstring"""





	__snake_case	:						Tuple						=				3
	__snake_case	:						Any						=				3

	while primes / (2 * j - 1) >= ratio:
		for i in range(j * j + j + 1     ,   (j + 2) * (j + 2)     ,   j + 1     ):
			primes += is_prime(_snake_case     )
		j += 2
	return j


if __name__ == "__main__":
			import doctest

			doctest.testmod()





