

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 							__SCREAMING_SNAKE_CASE							(			lowerCAmelCase:					dict	)				->    Tuple:
				return (data["data"], data["target"])

def 							__SCREAMING_SNAKE_CASE							(			lowerCAmelCase:					np.ndarray					, lowerCAmelCase:					np.ndarray					, lowerCAmelCase:					np.ndarray	)				->    List[Any]:
				_UpperCAmelCase    :						Tuple							=      XGBRegressor(verbosity=0					, random_state=42	)
				xgb.fit(__SCREAMING_SNAKE_CASE					, __SCREAMING_SNAKE_CASE	)
				# Predict target for test data
				_UpperCAmelCase    :						Union[str, Any]							=      xgb.predict(__SCREAMING_SNAKE_CASE	)
				_UpperCAmelCase    :						Tuple							=      predictions.reshape(len(__SCREAMING_SNAKE_CASE	)					, 1	)
				return predictions

def 							__SCREAMING_SNAKE_CASE							(			)				->    List[Any]:
				_UpperCAmelCase    :						Union[str, Any]							=      fetch_california_housing()
				_UpperCAmelCase    :						Any							=      data_handling(__SCREAMING_SNAKE_CASE	)
				_UpperCAmelCase    :						int							=      train_test_split(
				    __SCREAMING_SNAKE_CASE					, __SCREAMING_SNAKE_CASE					, test_size=0.25					, random_state=1	)
				_UpperCAmelCase    :						Union[str, Any]							=      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

from decimal import Decimal
from math import *  # noqa: F403

from sympy import diff

def 							__SCREAMING_SNAKE_CASE							(			lowerCAmelCase:					str					, lowerCAmelCase:					float | Decimal					, lowerCAmelCase:					float = 10**-10	)				->    float:
				_UpperCAmelCase    :						Optional[int]							=      a
				while True:
								_UpperCAmelCase    :						Tuple							=      Decimal(lowerCAmelCase	) - (
								    Decimal(eval(lowerCAmelCase	)	) / Decimal(eval(str(diff(lowerCAmelCase	)	)	)	)  # noqa: S307
								)
								# This number dictates the accuracy of the answer
								if abs(eval(lowerCAmelCase	)	) < precision:  # noqa: S307
												return float(lowerCAmelCase	)


# Let's Execute
if __name__ == "__main__":
					# Find root of trigonometric function
					# Find value of pi
					print(F'''The root of sin(x) = 0 is {newton_raphson("sin(x)", 2)}''')
					# Find root of polynomial
					print(F'''The root of x**2 - 5*x + 2 = 0 is {newton_raphson("x**2 - 5*x + 2", 0.4)}''')
					# Find Square Root of 5
					print(F'''The root of log(x) - 1 = 0 is {newton_raphson("log(x) - 1", 2)}''')
					# Exponential Roots
					print(F'''The root of exp(x) - 1 = 0 is {newton_raphson("exp(x) - 1", 0)}''')


