import numpy

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




def       _snake_case	(   lowerCAmelCase							:   Optional[Any]   , lowerCAmelCase							:   Dict="train"	):
		"""simple docstring"""







		return calculate_hypothesis_value(lowerCAmelCase   , lowerCAmelCase	) - output(
		    lowerCAmelCase   , lowerCAmelCase	)




def       _snake_case	(   lowerCAmelCase							:   Optional[Any]	):
		"""simple docstring"""







		SCREAMING_SNAKE_CASE_  :		int				      =    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       _snake_case	(   lowerCAmelCase							:   Union[str, Any]   , lowerCAmelCase							:   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       _snake_case	(   lowerCAmelCase							:   Tuple   , lowerCAmelCase							:   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       _snake_case	(   lowerCAmelCase							:   List[str]   , lowerCAmelCase							:   str=m	):
		"""simple docstring"""







		SCREAMING_SNAKE_CASE_  :		List[str]				      =    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       _snake_case	(   lowerCAmelCase							:   Dict	):
		"""simple docstring"""







		SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    summation_of_cost_derivative(lowerCAmelCase   , lowerCAmelCase	) / m
		return cost_derivative_value




def       _snake_case	(   ):
		"""simple docstring"""







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




def       _snake_case	(   ):
		"""simple docstring"""







		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()

def       _snake_case	(   lowerCAmelCase							:   list	):
		"""simple docstring"""







		SCREAMING_SNAKE_CASE_  :		Dict				      =    len(lowerCAmelCase	)
		for i in range(1   , lowerCAmelCase	):
				SCREAMING_SNAKE_CASE_  :		int				      =    collection[i]
				SCREAMING_SNAKE_CASE_  :		Any				      =    0
				SCREAMING_SNAKE_CASE_  :		Tuple				      =    i - 1

				while low <= high:
						SCREAMING_SNAKE_CASE_  :		int				      =    (low + high) // 2
						if val < collection[mid]:
								SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    mid - 1
						else:
								SCREAMING_SNAKE_CASE_  :		Tuple				      =    mid + 1
				for j in range(lowerCAmelCase   , lowerCAmelCase   , -1	):
						SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    collection[j - 1]
				SCREAMING_SNAKE_CASE_  :		int				      =    val
		return collection


if __name__ == "__main__":
		__lowerCamelCase					:	Dict       =  input('''Enter numbers separated by a comma:\n''').strip()
		__lowerCamelCase					:	List[str]       =  [int(item) for item in user_input.split(''',''')]
		print(binary_insertion_sort(unsorted))
