





import numpy

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





def        lowerCamelCase__   (  _UpperCAmelCase     , _UpperCAmelCase="train"			)  ->					int:
				return calculate_hypothesis_value(_UpperCAmelCase     , _UpperCAmelCase			) - output(
				    _UpperCAmelCase     , _UpperCAmelCase			)





def        lowerCamelCase__   (  _UpperCAmelCase			)  ->					str:
				lowerCamelCase			=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        lowerCamelCase__   (  _UpperCAmelCase     , _UpperCAmelCase			)  ->					int:
				if data_set == "train":
								return train_data[example_no][1]
				elif data_set == "test":
								return test_data[example_no][1]
				return None





def        lowerCamelCase__   (  _UpperCAmelCase     , _UpperCAmelCase			)  ->					Union[str, Any]:
				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__   (  _UpperCAmelCase     , _UpperCAmelCase=m			)  ->					Dict:
				lowerCamelCase			=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        lowerCamelCase__   (  _UpperCAmelCase			)  ->					Tuple:
				lowerCamelCase			=summation_of_cost_derivative(_UpperCAmelCase     , _UpperCAmelCase			) / m
				return cost_derivative_value





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





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












# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.:
#   python ./utils/get_modified_files.py utils src tests examples
#
# it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered
# since the output of this script is fed into Makefile commands it doesn't print a newline after the results

import re
import subprocess
import sys


UpperCAmelCase__  :     Union[str, Any]   			=subprocess.check_output('''git merge-base main HEAD'''.split()).decode('''utf-8''')
UpperCAmelCase__  :     List[str]   			=(
    subprocess.check_output(F"git diff --diff-filter=d --name-only {fork_point_sha}".split()).decode('''utf-8''').split()
)

UpperCAmelCase__  :     Tuple   			='''|'''.join(sys.argv[1:])
UpperCAmelCase__  :     List[str]   			=re.compile(rF"^({joined_dirs}).*?\.py$")

UpperCAmelCase__  :     Any   			=[x for x in modified_files if regex.match(x)]
print(''' '''.join(relevant_modified_files), end='''''')





