





'''simple docstring'''


import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import ClassLabel, Features, Image
from .base import TaskTemplate






@dataclass(frozen=UpperCAmelCase_    )
class     lowerCAmelCase__ (				UpperCAmelCase_    ):

       '''simple docstring'''
       _lowerCamelCase								=field(default="image-classification"      , metadata={"include_in_asdict_even_if_is_default": True}    )
       _lowerCamelCase								=Features({"image": Image()}    )
       _lowerCamelCase								=Features({"labels": ClassLabel}    )
       _lowerCamelCase								="image"
       _lowerCamelCase								="labels"

       def 			__snake_case      ( self					:				int       ,     a__					:				Union[str, Any]						):
              if self.label_column not in features:
                     raise ValueError(f"Column {self.label_column} is not present in features."						)
              if not isinstance(features[self.label_column]       ,     a__						):
                     raise ValueError(f"Column {self.label_column} is not a ClassLabel."						)
              UpperCAmelCase  =						copy.deepcopy(self						)
              UpperCAmelCase  =						self.label_schema.copy()
              UpperCAmelCase  =						features[self.label_column]
              UpperCAmelCase  =						label_schema
              return task_template



       @property
       def 			__snake_case      ( self					:				List[str]						):
              return {
                  self.image_column: "image",
                  self.label_column: "labels",
              }








'''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 						snake_case_       (UpperCamelCase			:    dict ):





							'''simple docstring'''


							return (data["data"], data["target"])
def 						snake_case_       (UpperCamelCase			:    np.ndarray					,		UpperCamelCase			:    np.ndarray					,		UpperCamelCase			:    np.ndarray ):





							'''simple docstring'''


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





							'''simple docstring'''


							_a      	=							fetch_california_housing()
							_a	,				_a      	=							data_handling(UpperCamelCase )
							_a	,				_a	,				_a	,				_a      	=							train_test_split(
							    UpperCamelCase					,		UpperCamelCase					,		test_size=0.25					,		random_state=1 )
							_a      	=							xgboost(UpperCamelCase					,		UpperCamelCase					,		UpperCamelCase )
							# Error printing
							print(f'Mean Absolute Error : {mean_absolute_error(UpperCamelCase					,		UpperCamelCase )}' )
							print(f'Mean Square Error  : {mean_squared_error(UpperCamelCase					,		UpperCamelCase )}' )


if __name__ == "__main__":
				import doctest

				doctest.testmod(verbose=True)
				main()

