


"""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       _a			(				SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		return (data["data"], data["target"])
def       _a			(				SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				XGBRegressor(verbosity=0						,    random_state=42					)
		xgb.fit(__SCREAMING_SNAKE_CASE						,    __SCREAMING_SNAKE_CASE					)
		# Predict target for test data
		lowercase__						=				xgb.predict(__SCREAMING_SNAKE_CASE					)
		lowercase__						=				predictions.reshape(len(__SCREAMING_SNAKE_CASE					)						,    1					)
		return predictions
def       _a			(				):


		"""simple docstring"""




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






import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
			import torch

			from transformers.activations import gelu_new, gelu_python, get_activation


@require_torch
class 	_a							(      unittest.TestCase      ):

							def 				lowerCamelCase_			(							self:     Dict							)      ->       Any:





									"""simple docstring"""







									lowercase__						=				torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]							)
									lowercase__						=				get_activation('''gelu'''							)
									self.assertTrue(torch.allclose(gelu_python(UpperCamelCase_							)   ,						torch_builtin(UpperCamelCase_							)							)							)
									self.assertFalse(torch.allclose(gelu_python(UpperCamelCase_							)   ,						gelu_new(UpperCamelCase_							)							)							)

							def 				lowerCamelCase_			(							self:     Optional[int]							)      ->       str:





									"""simple docstring"""







									lowercase__						=				torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]							)
									lowercase__						=				get_activation('''gelu'''							)
									lowercase__						=				get_activation('''gelu_10'''							)

									lowercase__						=				torch_builtin(UpperCamelCase_							)
									lowercase__						=				geluaa(UpperCamelCase_							)

									lowercase__						=				torch.where(y_gelu_aa < 10.0   ,						1   ,						0							)

									self.assertTrue(torch.max(UpperCamelCase_							).item() == 10.0							)
									self.assertTrue(torch.allclose(y_gelu * clipped_mask   ,						y_gelu_aa * clipped_mask							)							)

							def 				lowerCamelCase_			(							self:     Union[str, Any]							)      ->       Tuple:





									"""simple docstring"""







									get_activation('''gelu'''							)
									get_activation('''gelu_10'''							)
									get_activation('''gelu_fast'''							)
									get_activation('''gelu_new'''							)
									get_activation('''gelu_python'''							)
									get_activation('''gelu_pytorch_tanh'''							)
									get_activation('''linear'''							)
									get_activation('''mish'''							)
									get_activation('''quick_gelu'''							)
									get_activation('''relu'''							)
									get_activation('''sigmoid'''							)
									get_activation('''silu'''							)
									get_activation('''swish'''							)
									get_activation('''tanh'''							)
									with self.assertRaises(UpperCamelCase_							):
											get_activation('''bogus'''							)
									with self.assertRaises(UpperCamelCase_							):
											get_activation(UpperCamelCase_							)


							def 				lowerCamelCase_			(							self:     Tuple							)      ->       int:





									"""simple docstring"""







									lowercase__						=				get_activation('''gelu'''							)
									lowercase__						=				1
									lowercase__						=				get_activation('''gelu'''							)
									self.assertEqual(acta.a   ,						1							)
									with self.assertRaises(UpperCamelCase_							):
											lowercase__						=				acta.a


