




"""simple docstring"""







a            =							{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

a            =							{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}





def 							lowercase    (snake_case__      :       str					,				snake_case__      :       Optional[Any]					,				snake_case__      :       Dict       )   ->     int:


				'''simple docstring'''






				lowerCAmelCase              = True
				lowerCAmelCase              = []

				for neighbour in graph[vert]:
								if not visited[neighbour]:
												order += topology_sort(a_					,				a_					,				a_       )

				order.append(a_       )

				return order





def 							lowercase    (snake_case__      :       Optional[Any]					,				snake_case__      :       Tuple					,				snake_case__      :       List[Any]       )   ->     Dict:


				'''simple docstring'''






				lowerCAmelCase              = True
				lowerCAmelCase              = [vert]

				for neighbour in reversed_graph[vert]:
								if not visited[neighbour]:
												component += find_components(a_					,				a_					,				a_       )

				return component






def 							lowercase    (snake_case__      :       int       )   ->     List[str]:


				'''simple docstring'''






				lowerCAmelCase              = len(a_       ) * [False]
				lowerCAmelCase              = {vert: [] for vert in range(len(a_       )       )}

				for vert, neighbours in graph.items():
								for neighbour in neighbours:
												reversed_graph[neighbour].append(a_       )

				lowerCAmelCase              = []
				for i, was_visited in enumerate(a_       ):
								if not was_visited:
												order += topology_sort(a_					,				a_					,				a_       )

				lowerCAmelCase              = []
				lowerCAmelCase              = len(a_       ) * [False]

				for i in range(len(a_       )       ):
								lowerCAmelCase              = order[len(a_       ) - i - 1]
								if not visited[vert]:
												lowerCAmelCase              = find_components(a_					,				a_					,				a_       )
												components_list.append(a_       )

				return components_list













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





