


'''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		=(((5_15, 22, 13), 5_55), ((61, 35, 49), 1_50))
__A		=[2, 4, 1, 5]
__A		=len(train_data)
__A		=0.0_0_9







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__="train"   ):
			return calculate_hypothesis_value(_lowerCAmelCase	, _lowerCAmelCase   ) - output(
			    _lowerCAmelCase	, _lowerCAmelCase   )







def       _UpperCamelCase (						UpperCamelCase__   ):
			UpperCAmelCase__					:   Union[str, Any]       				=       0
			for i in range(len(_lowerCAmelCase   ) - 1   ):
						hyp_val += data_input_tuple[i] * parameter_vector[i + 1]
			hyp_val += parameter_vector[0]
			return hyp_val







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__   ):



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







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__   ):



			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       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__=m   ):
			UpperCAmelCase__					:   int       				=       0
			for i in range(_lowerCAmelCase   ):
						if index == -1:
									summation_value += _error(_lowerCAmelCase   )
						else:
									summation_value += _error(_lowerCAmelCase   ) * train_data[i][0][index]
			return summation_value







def       _UpperCamelCase (						UpperCamelCase__   ):
			UpperCAmelCase__					:   int       				=       summation_of_cost_derivative(_lowerCAmelCase	, _lowerCAmelCase   ) / m
			return cost_derivative_value







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







def       _UpperCamelCase (						):



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


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



'''simple docstring'''



def       _UpperCamelCase (						UpperCamelCase__ = 1_0	, UpperCamelCase__ = 2_2   ):
			UpperCAmelCase__					:   List[str]       				=       range(1	, UpperCamelCase__   )
			UpperCAmelCase__					:   int       				=       range(1	, UpperCamelCase__   )
			return sum(
			    1 for power in powers for base in bases if len(str(base**power   )   ) == power   )


if __name__ == "__main__":
		print(f"""{solution(10, 22) = }""")