


'''simple docstring'''

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

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





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





		"""simple docstring"""




		_lowerCamelCase						=						field(default="audio-classification"    ,		metadata={"include_in_asdict_even_if_is_default": True}    )
		_lowerCamelCase						=						Features({"audio": Audio()}    )
		_lowerCamelCase						=						Features({"labels": ClassLabel}    )
		_lowerCamelCase						=						"audio"
		_lowerCamelCase						=						"labels"






		def 						snake_case	(					self    ,						UpperCamelCase  ):







			"""simple docstring"""


			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]    ,						_snake_case  ):
				raise ValueError(f'''Column {self.label_column} is not a ClassLabel.'''  )
			lowerCamelCase_  				=						copy.deepcopy(self  )
			lowerCamelCase_  				=						self.label_schema.copy()
			lowerCamelCase_  				=						features[self.label_column]
			lowerCamelCase_  				=						label_schema
			return task_template







		@property
		def 						snake_case	(					self  ):







			"""simple docstring"""
			return {
			    self.audio_column: "audio",
			    self.label_column: "labels",
			}







'''simple docstring'''

import numpy as np
from matplotlib import pyplot as plt
from sklearn.datasets import load_iris
from sklearn.metrics import ConfusionMatrixDisplay
from sklearn.model_selection import train_test_split
from xgboost import XGBClassifier





def __snake_case      (   UpperCAmelCase_		:		dict	):
 return (data["data"], data["target"])





def __snake_case      (   UpperCAmelCase_		:		np.ndarray      ,       UpperCAmelCase_		:		np.ndarray	):
 lowerCamelCase_  				=						XGBClassifier()
 classifier.fit(UpperCAmelCase_      ,       UpperCAmelCase_	)
 return classifier





def __snake_case      (   ):
 lowerCamelCase_  				=						load_iris()
 lowerCamelCase_				,lowerCamelCase_  				=						data_handling(UpperCAmelCase_	)
 lowerCamelCase_				,lowerCamelCase_				,lowerCamelCase_				,lowerCamelCase_  				=						train_test_split(
     UpperCAmelCase_      ,       UpperCAmelCase_      ,       test_size=0.25	)

 lowerCamelCase_  				=						iris["target_names"]

 # Create an XGBoost Classifier from the training data
 lowerCamelCase_  				=						xgboost(UpperCAmelCase_      ,       UpperCAmelCase_	)

 # Display the confusion matrix of the classifier with both training and test sets
 ConfusionMatrixDisplay.from_estimator(
     UpperCAmelCase_      ,       UpperCAmelCase_      ,       UpperCAmelCase_      ,       display_labels=UpperCAmelCase_      ,       cmap="Blues"      ,       normalize="true"      ,       )
 plt.title("Normalized Confusion Matrix - IRIS Dataset"	)
 plt.show()


if __name__ == "__main__":
     import doctest

     doctest.testmod(verbose=True)
     main()



