


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()








def      lowerCamelCase_						(			UpperCamelCase__							: str					,	UpperCamelCase__							: int )	->			list:





				"""simple docstring"""


				__lowerCamelCase									=       word.split()

				def justify(UpperCamelCase__							: list					,	UpperCamelCase__							: int					,	UpperCamelCase__							: int ) -> str:
								__lowerCamelCase									=       max_width - width
								__lowerCamelCase									=       len(UpperCamelCase__ )
								if len(UpperCamelCase__ ) == 1:
												# if there is only word in line
												# just insert overall_spaces_count for the remainder of line
												return line[0] + " " * overall_spaces_count
								else:
												__lowerCamelCase									=       words_count - 1
												# num_spaces_between_words_list[i] : tells you to insert
												# num_spaces_between_words_list[i] spaces
												# after word on line[i]
												__lowerCamelCase									=       spaces_to_insert_between_words * [
												    overall_spaces_count // spaces_to_insert_between_words
												]
												__lowerCamelCase									=       (
												    overall_spaces_count % spaces_to_insert_between_words
												)
												# distribute spaces via round robin to the left words
												for i in range(UpperCamelCase__ ):
																num_spaces_between_words_list[i] += 1
												__lowerCamelCase									=       []
												for i in range(UpperCamelCase__ ):
																# add the word
																aligned_words_list.append(line[i] )
																# add the spaces to insert
																aligned_words_list.append(num_spaces_between_words_list[i] * ' ' )
												# just add the last word to the sentence
												aligned_words_list.append(line[-1] )
												# join the aligned words list to form a justified line
												return "".join(UpperCamelCase__ )

				__lowerCamelCase									=       []
				__lowerCamelCase									=       []
				__lowerCamelCase									=       0
				for word in words:
								if width + len(UpperCamelCase__ ) + len(UpperCamelCase__ ) <= max_width:
												# keep adding words until we can fill out max_width
												# width = sum of length of all words (without overall_spaces_count)
												# len(word) = length of current word
												# len(line) = number of overall_spaces_count to insert between words
												line.append(UpperCamelCase__ )
												width += len(UpperCamelCase__ )
								else:
												# justify the line and add it to result
												answer.append(justify(UpperCamelCase__					,	UpperCamelCase__					,	UpperCamelCase__ ) )
												# reset new line and new width
												__lowerCamelCase			,		__lowerCamelCase									=       [word], len(UpperCamelCase__ )
				__lowerCamelCase									=       max_width - width - len(UpperCamelCase__ )
				answer.append(' '.join(UpperCamelCase__ ) + (remaining_spaces + 1) * ' ' )
				return answer


if __name__ == "__main__":
					from doctest import testmod

					testmod()


