






from __future__ import annotations

from collections.abc import Iterator
from typing import Any




class  UpperCamelCase_      :



	'''simple docstring'''




	def __init__(       self       ,			a					)       ->    List[str]:
								snake_case_				=							data
								snake_case_				=							None






class  UpperCamelCase_      :



	'''simple docstring'''




	def __init__(       self					)       ->    str:
								snake_case_				=							None
								snake_case_				=							None




	def __iter__(       self					)       ->    Iterator[Any]:
								snake_case_				=							self.head
								while self.head:
															yield node.data
															snake_case_				=							node.next
															if node == self.head:
																						break




	def __len__(       self					)       ->    int:
								return sum(1 for _ in self					)




	def __repr__(       self					)       ->    Any:
								return "->".join(str(a					) for item in iter(self					)					)




	def 							_UpperCamelCase			(       self       ,			a					)       ->    None:
								self.insert_nth(len(self					)       ,			a					)




	def 							_UpperCamelCase			(       self       ,			a					)       ->    None:
								self.insert_nth(0       ,			a					)




	def 							_UpperCamelCase			(       self       ,			a       ,			a					)       ->    None:
								if index < 0 or index > len(self					):
															raise IndexError('list index out of range.'					)
								snake_case_				=							Node(a					)
								if self.head is None:
															snake_case_				=							new_node  # first node points itself
															snake_case_				=							snake_case_				=							new_node
								elif index == 0:  # insert at head
															snake_case_				=							self.head
															snake_case_				=							snake_case_				=							new_node
								else:
															snake_case_				=							self.head
															for _ in range(index - 1					):
																						snake_case_				=							temp.next
															snake_case_				=							temp.next
															snake_case_				=							new_node
															if index == len(self					) - 1:  # insert at tail
																						snake_case_				=							new_node




	def 							_UpperCamelCase			(       self					)       ->    List[Any]:
								return self.delete_nth(0					)




	def 							_UpperCamelCase			(       self					)       ->    Any:
								return self.delete_nth(len(self					) - 1					)




	def 							_UpperCamelCase			(       self       ,			a = 0					)       ->    Any:
								if not 0 <= index < len(self					):
															raise IndexError('list index out of range.'					)
								snake_case_				=							self.head
								if self.head == self.tail:  # just one node
															snake_case_				=							snake_case_				=							None
								elif index == 0:  # delete head node
															snake_case_				=							self.tail.next.next
															snake_case_				=							self.head.next
								else:
															snake_case_				=							self.head
															for _ in range(index - 1					):
																						snake_case_				=							temp.next
															snake_case_				=							temp.next
															snake_case_				=							temp.next.next
															if index == len(self					) - 1:  # delete at tail
																						snake_case_				=							temp
								return delete_node.data






	def 							_UpperCamelCase			(       self					)       ->    bool:
								return len(self					) == 0






def 						__UpperCAmelCase			(     ):
							snake_case_				=							CircularLinkedList()
							assert len(a_) == 0
							assert circular_linked_list.is_empty() is True
							assert str(a_) == ""

							try:
														circular_linked_list.delete_front()
														raise AssertionError  # This should not happen
							except IndexError:
														assert True  # This should happen

							try:
														circular_linked_list.delete_tail()
														raise AssertionError  # This should not happen
							except IndexError:
														assert True  # This should happen

							try:
														circular_linked_list.delete_nth(-1)
														raise AssertionError
							except IndexError:
														assert True

							try:
														circular_linked_list.delete_nth(0)
														raise AssertionError
							except IndexError:
														assert True

							assert circular_linked_list.is_empty() is True
							for i in range(5):
														assert len(a_) == i
														circular_linked_list.insert_nth(a_							,     i + 1)
							assert str(a_) == "->".join(str(a_) for i in range(1							,     6))

							circular_linked_list.insert_tail(6)
							assert str(a_) == "->".join(str(a_) for i in range(1							,     7))
							circular_linked_list.insert_head(0)
							assert str(a_) == "->".join(str(a_) for i in range(0							,     7))

							assert circular_linked_list.delete_front() == 0
							assert circular_linked_list.delete_tail() == 6
							assert str(a_) == "->".join(str(a_) for i in range(1							,     6))
							assert circular_linked_list.delete_nth(2) == 3

							circular_linked_list.insert_nth(2							,     3)
							assert str(a_) == "->".join(str(a_) for i in range(1							,     6))

							assert circular_linked_list.is_empty() is False


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





