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






     '''simple docstring'''



     return (data["data"], data["target"])







def 					__a   (		A    ,				A    ,				A      ):






     '''simple docstring'''



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







def 					__a   (		):






     '''simple docstring'''



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


if __name__ == "__main__":
 import doctest

 doctest.testmod(verbose=True)
 main()





"""simple docstring"""


import unittest

from huggingface_hub import hf_hub_download

from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor
from transformers.pipelines import VideoClassificationPipeline, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_decord,
    require_tf,
    require_torch,
    require_torch_or_tf,
    require_vision,
)

from .test_pipelines_common import ANY






@is_pipeline_test
@require_torch_or_tf
@require_vision
@require_decord
class    a__    (   unittest.TestCase	):
   snake_case_							=      MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING


   def 	snake_case__	(     self,				_UpperCAmelCase,				_UpperCAmelCase,				_UpperCAmelCase  ):
        '''simple docstring'''



        lowercase__				 =							hf_hub_download(
            repo_id="nateraw/video-demo",				filename="archery.mp4",				repo_type="dataset"  )
        lowercase__				 =							VideoClassificationPipeline(model=_UpperCAmelCase,				image_processor=_UpperCAmelCase,				top_k=2  )
        lowercase__				 =							[
            example_video_filepath,
            "https://huggingface.co/datasets/nateraw/video-demo/resolve/main/archery.mp4",
        ]
        return video_classifier, examples


   def 	snake_case__	(     self,				_UpperCAmelCase,				_UpperCAmelCase  ):
        '''simple docstring'''



        for example in examples:
             lowercase__				 =							video_classifier(_UpperCAmelCase  )

             self.assertEqual(
                 _UpperCAmelCase,				[
                     {"score": ANY(_UpperCAmelCase  ), "label": ANY(_UpperCAmelCase  )},
                     {"score": ANY(_UpperCAmelCase  ), "label": ANY(_UpperCAmelCase  )},
                 ],				)


   @require_torch
   def 	snake_case__	(     self  ):
        '''simple docstring'''



        lowercase__				 =							"hf-internal-testing/tiny-random-VideoMAEForVideoClassification"
        lowercase__				 =							VideoMAEFeatureExtractor(
            size={"shortest_edge": 10},				crop_size={"height": 10, "width": 10}  )
        lowercase__				 =							pipeline(
            "video-classification",				model=_UpperCAmelCase,				feature_extractor=_UpperCAmelCase,				frame_sampling_rate=4  )

        lowercase__				 =							hf_hub_download(repo_id="nateraw/video-demo",				filename="archery.mp4",				repo_type="dataset"  )
        lowercase__				 =							video_classifier(_UpperCAmelCase,				top_k=2  )
        self.assertEqual(
            nested_simplify(_UpperCAmelCase,				decimals=4  ),				[{"score": 0.5_199, "label": "LABEL_0"}, {"score": 0.4_801, "label": "LABEL_1"}],				)

        lowercase__				 =							video_classifier(
            [
                video_file_path,
                video_file_path,
            ],				top_k=2,				)
        self.assertEqual(
            nested_simplify(_UpperCAmelCase,				decimals=4  ),				[
                [{"score": 0.5_199, "label": "LABEL_0"}, {"score": 0.4_801, "label": "LABEL_1"}],
                [{"score": 0.5_199, "label": "LABEL_0"}, {"score": 0.4_801, "label": "LABEL_1"}],
            ],				)


   @require_tf
   def 	snake_case__	(     self  ):
        '''simple docstring'''



        pass




