'''simple docstring'''

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__      ):


      '''simple docstring'''






      return (data["data"], data["target"])



def 							UpperCamelCase__			(			a__			,      a__			,      a__      ):


      '''simple docstring'''






      _lowerCAmelCase										=XGBRegressor(verbosity=0			,      random_state=4_2      )
      xgb.fit(a__			,      a__      )
      # Predict target for test data
      _lowerCAmelCase										=xgb.predict(a__      )
      _lowerCAmelCase										=predictions.reshape(len(a__      )			,      1      )
      return predictions



def 							UpperCamelCase__			(			):


      '''simple docstring'''






      _lowerCAmelCase										=fetch_california_housing()
      _lowerCAmelCase						,				_lowerCAmelCase										=data_handling(a__      )
      _lowerCAmelCase						,				_lowerCAmelCase						,				_lowerCAmelCase						,				_lowerCAmelCase										=train_test_split(
          a__			,      a__			,      test_size=0.25			,      random_state=1      )
      _lowerCAmelCase										=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()






'''simple docstring'''

from __future__ import annotations

from typing import Any
class   SCREAMING_SNAKE_CASE			:







		"""simple docstring"""






		def __init__(   self		,						__A				) ->     None:
								_lowerCAmelCase										=num_of_nodes
								_lowerCAmelCase										=[]
								_lowerCAmelCase										={}






		def 		UpperCamelCase__       (   self		,						__A		,						__A		,						__A				) ->     None:
								self.m_edges.append([u_node, v_node, weight]				)






		def 		UpperCamelCase__       (   self		,						__A				) ->     int:

								if self.m_component[u_node] == u_node:
														return u_node
								return self.find_component(self.m_component[u_node]				)






		def 		UpperCamelCase__       (   self		,						__A				) ->     None:

								if self.m_component[u_node] != u_node:
														for k in self.m_component:
																				_lowerCAmelCase										=self.find_component(__A				)






		def 		UpperCamelCase__       (   self		,						__A		,						__A		,						__A				) ->     None:

								if component_size[u_node] <= component_size[v_node]:
														_lowerCAmelCase										=v_node
														component_size[v_node] += component_size[u_node]
														self.set_component(__A				)

								elif component_size[u_node] >= component_size[v_node]:
														_lowerCAmelCase										=self.find_component(__A				)
														component_size[u_node] += component_size[v_node]
														self.set_component(__A				)






		def 		UpperCamelCase__       (   self				) ->     None:
								_lowerCAmelCase										=[]
								_lowerCAmelCase										=0

								_lowerCAmelCase										=[-1] * self.m_num_of_nodes

								# A list of components (initialized to all of the nodes)
								for node in range(self.m_num_of_nodes				):
														self.m_component.update({node: node}				)
														component_size.append(1				)

								_lowerCAmelCase										=self.m_num_of_nodes

								while num_of_components > 1:
														for edge in self.m_edges:
																				_lowerCAmelCase						,				_lowerCAmelCase						,				_lowerCAmelCase										=edge

																				_lowerCAmelCase										=self.m_component[u]
																				_lowerCAmelCase										=self.m_component[v]

																				if u_component != v_component:

																										for component in (u_component, v_component):
																																if (
																																    minimum_weight_edge[component] == -1
																																    or minimum_weight_edge[component][2] > w
																																):
																																						_lowerCAmelCase										=[u, v, w]

														for edge in minimum_weight_edge:
																				if isinstance(__A		,						__A				):
																										_lowerCAmelCase						,				_lowerCAmelCase						,				_lowerCAmelCase										=edge

																										_lowerCAmelCase										=self.m_component[u]
																										_lowerCAmelCase										=self.m_component[v]

																										if u_component != v_component:
																																mst_weight += w
																																self.union(__A		,						__A		,						__A				)
																																print(F'''Added edge [{u} - {v}]\nAdded weight: {w}\n'''				)
																																num_of_components -= 1

														_lowerCAmelCase										=[-1] * self.m_num_of_nodes
								print(F'''The total weight of the minimal spanning tree is: {mst_weight}'''				)



def 							UpperCamelCase__			(			):


						'''simple docstring'''








if __name__ == "__main__":
							import doctest

							doctest.testmod()





