


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_( lowerCamelCase_					)       ->		tuple:
    return (data["data"], data["target"])



def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		np.ndarray:
    _lowercase			:				int 						=						XGBRegressor(verbosity=0				,					random_state=42					)
    xgb.fit(lowerCamelCase_				,					lowerCamelCase_					)
    # Predict target for test data
    _lowercase			:				int 						=						xgb.predict(lowerCamelCase_					)
    _lowercase			:				Optional[Any] 						=						predictions.reshape(len(lowerCamelCase_					)				,					1					)
    return predictions



def 							UpperCamelCase_( )       ->		None:
    _lowercase			:				Tuple 						=						fetch_california_housing()
    _lowercase						,							_lowercase			:				Any 						=						data_handling(lowerCamelCase_					)
    _lowercase						,							_lowercase						,							_lowercase						,							_lowercase			:				Optional[Any] 						=						train_test_split(
        lowerCamelCase_				,					lowerCamelCase_				,					test_size=0.25				,					random_state=1					)
    _lowercase			:				Optional[int] 						=						xgboost(lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)
    # Error printing
    print(F'''Mean Absolute Error : {mean_absolute_error(lowerCamelCase_				,					lowerCamelCase_					)}'''					)
    print(F'''Mean Square Error  : {mean_squared_error(lowerCamelCase_				,					lowerCamelCase_					)}'''					)


if __name__ == "__main__":
 import doctest

 doctest.testmod(verbose=True)
 main()








'''simple docstring'''


import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict
@pytest.mark.parametrize(
    '''split_dict'''					,		[
        SplitDict(),
        SplitDict({'''train''': SplitInfo(name='''train'''					,		num_bytes=1337					,		num_examples=42					,		dataset_name='''my_dataset''' )} ),
        SplitDict({'''train''': SplitInfo(name='''train'''					,		num_bytes=1337					,		num_examples=42 )} ),
        SplitDict({'''train''': SplitInfo()} ),
    ]					,		)
def 						snake_case_       (UpperCamelCase			:    SplitDict ):





							'''simple docstring'''


							_a      	=							split_dict._to_yaml_list()
							assert len(UpperCamelCase ) == len(UpperCamelCase )
							_a      	=							SplitDict._from_yaml_list(UpperCamelCase )
							for split_name, split_info in split_dict.items():
														# dataset_name field is deprecated, and is therefore not part of the YAML dump
														_a      	=							None
														# the split name of split_dict takes over the name of the split info object
														_a      	=							split_name
							assert split_dict == reloaded

@pytest.mark.parametrize(
    '''split_info'''					,		[SplitInfo(), SplitInfo(dataset_name=UpperCamelCase ), SplitInfo(dataset_name='''my_dataset''' )] )
def 						snake_case_       (UpperCamelCase			:    List[str] ):





							'''simple docstring'''


							_a      	=							asdict(SplitDict({'''train''': split_info} ) )
							assert "dataset_name" in split_dict_asdict["train"]
							assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name

