


"""simple docstring"""



import numpy

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







def 						__lowerCAmelCase		(		lowercase						:						Any		,							lowercase						:						Union[str, Any]="train"				)			->		str:


    """simple docstring"""





    return calculate_hypothesis_value(lowercase		,							lowercase				) - output(
        lowercase		,							lowercase				)







def 						__lowerCAmelCase		(		lowercase						:						Tuple				)			->		Union[str, Any]:


    """simple docstring"""





    snake_case					:   Any         =					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 						__lowerCAmelCase		(		lowercase						:						List[str]		,							lowercase						:						Union[str, Any]				)			->		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		(		lowercase						:						Dict		,							lowercase						:						Optional[int]				)			->		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		(		lowercase						:						Any		,							lowercase						:						str=m				)			->		Tuple:


    """simple docstring"""





    snake_case					:   Union[str, Any]         =					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 						__lowerCAmelCase		(		lowercase						:						Optional[Any]				)			->		Dict:


    """simple docstring"""





    snake_case					:   Tuple         =					summation_of_cost_derivative(lowercase		,							lowercase				) / m
    return cost_derivative_value







def 						__lowerCAmelCase		(		)			->		str:


    """simple docstring"""





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







def 						__lowerCAmelCase		(		)			->		Union[str, 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()









"""simple docstring"""



# 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


__snake_case         =					subprocess.check_output("""git merge-base main HEAD""".split()).decode("""utf-8""")
__snake_case         =					(
    subprocess.check_output(F'''git diff --diff-filter=d --name-only {fork_point_sha}'''.split()).decode("""utf-8""").split()
)

__snake_case         =					"""|""".join(sys.argv[1:])
__snake_case         =					re.compile(RF'''^({joined_dirs}).*?\.py$''')

__snake_case         =					[x for x in modified_files if regex.match(x)]
print(""" """.join(relevant_modified_files), end="""""")





