
'''simple docstring'''


import numpy

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




def lowercase_	(   _lowercase			,       _lowercase="train"				)     ->							Optional[Any]:
					'''simple docstring'''

					return calculate_hypothesis_value(_lowercase			,       _lowercase				) - output(
					    _lowercase			,       _lowercase				)




def lowercase_	(   _lowercase				)     ->							Optional[Any]:
					'''simple docstring'''

					lowerCamelCase_					:      Optional[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 lowercase_	(   _lowercase			,       _lowercase				)     ->							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 lowercase_	(   _lowercase			,       _lowercase				)     ->							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 lowercase_	(   _lowercase			,       _lowercase=m				)     ->							Any:
					'''simple docstring'''

					lowerCamelCase_					:      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 lowercase_	(   _lowercase				)     ->							Union[str, Any]:
					'''simple docstring'''

					lowerCamelCase_					:      Dict     =		summation_of_cost_derivative(_lowercase			,       _lowercase				) / m
					return cost_derivative_value




def lowercase_	(   )     ->							int:
					'''simple docstring'''

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




def lowercase_	(   )     ->							str:
					'''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'''


import qiskit




def lowercase_	(   _lowercase			,       _lowercase				)     ->							qiskit.result.counts.Counts:
					'''simple docstring'''

					lowerCamelCase_					:      Optional[Any]     =		qiskit.Aer.get_backend('''aer_simulator'''				)

					# Create a Quantum Circuit acting on the q register
					lowerCamelCase_					:      Optional[int]     =		qiskit.QuantumCircuit(_lowercase			,       _lowercase				)

					# Apply X (NOT) Gate to Qubits 0 & 1
					circuit.x(0				)
					circuit.x(1				)

					# Map the quantum measurement to the classical bits
					circuit.measure([0, 1]			,       [0, 1]				)

					# Execute the circuit on the qasm simulator
					lowerCamelCase_					:      Optional[int]     =		qiskit.execute(_lowercase			,       _lowercase			,       shots=1_000				)

					# Return the histogram data of the results of the experiment.
					return job.result().get_counts(_lowercase				)


if __name__ == "__main__":
					__lowercase							:   List[Any]					=     single_qubit_measure(2, 2)
					print(f'Total count for various states are: {counts}')


