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     lowerCAmelCase_			(   _SCREAMING_SNAKE_CASE     :				dict			):
						return (data["data"], data["target"])






def     lowerCAmelCase_			(   _SCREAMING_SNAKE_CASE     :				np.ndarray		, _SCREAMING_SNAKE_CASE     :				np.ndarray		, _SCREAMING_SNAKE_CASE     :				np.ndarray			):
						UpperCamelCase_		:							int  =		XGBRegressor(verbosity=0		, random_state=42			)
						xgb.fit(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE			)
						# Predict target for test data
						UpperCamelCase_		:							List[str]  =		xgb.predict(_SCREAMING_SNAKE_CASE			)
						UpperCamelCase_		:							List[Any]  =		predictions.reshape(len(_SCREAMING_SNAKE_CASE			)		, 1			)
						return predictions






def     lowerCAmelCase_			(   ):
						UpperCamelCase_		:							List[str]  =		fetch_california_housing()
						UpperCamelCase_,UpperCamelCase_		:							Any  =		data_handling(_SCREAMING_SNAKE_CASE			)
						UpperCamelCase_,UpperCamelCase_,UpperCamelCase_,UpperCamelCase_		:							str  =		train_test_split(
						    _SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, test_size=0.25		, random_state=1			)
						UpperCamelCase_		:							Optional[int]  =		xgboost(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE			)
						# Error printing
						print(f'''Mean Absolute Error : {mean_absolute_error(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE			)}'''			)
						print(f'''Mean Square Error  : {mean_squared_error(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE			)}'''			)


if __name__ == "__main__":
	import doctest

	doctest.testmod(verbose=True)
	main()







from __future__ import annotations






def     lowerCAmelCase_			(   _SCREAMING_SNAKE_CASE     :				float		, _SCREAMING_SNAKE_CASE     :				float		, _SCREAMING_SNAKE_CASE     :				float		, ):
						if (electron_conc, hole_conc, intrinsic_conc).count(0			) != 1:
												raise ValueError("""You cannot supply more or less than 2 values"""			)
						elif electron_conc < 0:
												raise ValueError("""Electron concentration cannot be negative in a semiconductor"""			)
						elif hole_conc < 0:
												raise ValueError("""Hole concentration cannot be negative in a semiconductor"""			)
						elif intrinsic_conc < 0:
												raise ValueError(
												    """Intrinsic concentration cannot be negative in a semiconductor"""			)
						elif electron_conc == 0:
												return (
												    "electron_conc",
												    intrinsic_conc**2 / hole_conc,
												)
						elif hole_conc == 0:
												return (
												    "hole_conc",
												    intrinsic_conc**2 / electron_conc,
												)
						elif intrinsic_conc == 0:
												return (
												    "intrinsic_conc",
												    (electron_conc * hole_conc) ** 0.5,
												)
						else:
												return (-1, -1)


if __name__ == "__main__":
	import doctest

	doctest.testmod()






