






from __future__ import annotations

import math

import numpy as np
from numpy.linalg import norm





def 						__UpperCAmelCase			(     a_							,     a_):
							return math.sqrt(sum(pow(a - b							,     2) for a, b in zip(a_							,     a_)))





def 						__UpperCAmelCase			(     a_							,     a_):

							if dataset.ndim != value_array.ndim:
														snake_case_				=							(
														    'Wrong input data\'s dimensions... '
														    f'''dataset : {dataset.ndim}, value_array : {value_array.ndim}'''
														)
														raise ValueError(a_)

							try:
														if dataset.shape[1] != value_array.shape[1]:
																					snake_case_				=							(
																					    'Wrong input data\'s shape... '
																					    f'''dataset : {dataset.shape[1]}, value_array : {value_array.shape[1]}'''
																					)
																					raise ValueError(a_)
							except IndexError:
														if dataset.ndim != value_array.ndim:
																					raise TypeError('Wrong shape')

							if dataset.dtype != value_array.dtype:
														snake_case_				=							(
														    'Input data have different datatype... '
														    f'''dataset : {dataset.dtype}, value_array : {value_array.dtype}'''
														)
														raise TypeError(a_)

							snake_case_				=							[]

							for value in value_array:
														snake_case_				=							euclidean(a_							,     dataset[0])
														snake_case_				=							dataset[0].tolist()

														for dataset_value in dataset[1:]:
																					snake_case_				=							euclidean(a_							,     a_)

																					if dist > temp_dist:
																												snake_case_				=							temp_dist
																												snake_case_				=							dataset_value.tolist()

														answer.append([vector, dist])

							return answer





def 						__UpperCAmelCase			(     a_							,     a_):
							return np.dot(a_							,     a_) / (norm(a_) * norm(a_))


if __name__ == "__main__":
	import doctest

	doctest.testmod()













import numpy as np
from sklearn.datasets import fetch_california_housing
from sklearn.metrics import mean_absolute_error, mean_squared_error
from sklearn.model_selection import train_test_split
from xgboost import XGBRegressor





def 						__UpperCAmelCase			(     a_):
							return (data["data"], data["target"])





def 						__UpperCAmelCase			(     a_							,     a_							,     a_):
							snake_case_				=							XGBRegressor(verbosity=0							,     random_state=42)
							xgb.fit(a_							,     a_)
							# Predict target for test data
							snake_case_				=							xgb.predict(a_)
							snake_case_				=							predictions.reshape(len(a_)							,     1)
							return predictions





def 						__UpperCAmelCase			(     ):
							snake_case_				=							fetch_california_housing()
							snake_case_			,		snake_case_				=							data_handling(a_)
							snake_case_			,		snake_case_			,		snake_case_			,		snake_case_				=							train_test_split(
							    a_							,     a_							,     test_size=0.25							,     random_state=1)
							snake_case_				=							xgboost(a_							,     a_							,     a_)
							# Error printing
							print(f'''Mean Absolute Error : {mean_absolute_error(a_							,     a_)}''')
							print(f'''Mean Square Error  : {mean_squared_error(a_							,     a_)}''')


if __name__ == "__main__":
	import doctest

	doctest.testmod(verbose=True)
	main()





