


import unittest

import numpy as np
def     __lowerCamelCase						(			UpperCAmelCase_						:		np.ndarray			,  UpperCAmelCase_						:		np.ndarray			,  UpperCAmelCase_						:		np.ndarray			,  UpperCAmelCase_						:		np.ndarray | None = None			,  ):




      """simple docstring"""





      a						:Dict										=	np.shape(UpperCAmelCase_						)
      a						:Optional[Any]										=	np.shape(UpperCAmelCase_						)
      a						:Optional[int]										=	np.shape(UpperCAmelCase_						)

      if shape_a[0] != shape_b[0]:
            a						:Dict										=	(
                '''Expected the same number of rows for A and B. '''
                F'''Instead found A of size {shape_a} and B of size {shape_b}'''
            )
            raise ValueError(UpperCAmelCase_						)

      if shape_b[1] != shape_c[1]:
            a						:List[Any]										=	(
                '''Expected the same number of columns for B and C. '''
                F'''Instead found B of size {shape_b} and C of size {shape_c}'''
            )
            raise ValueError(UpperCAmelCase_						)

      a						:Tuple										=	pseudo_inv
      if a_inv is None:
            try:
                  a						:int										=	np.linalg.inv(UpperCAmelCase_						)
            except np.linalg.LinAlgError:
                  raise ValueError(
                      '''Input matrix A is not invertible. Cannot compute Schur complement.'''						)

      return mat_c - mat_b.T @ a_inv @ mat_b







class 		_snake_case  (				unittest.TestCase							):




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       a						:int										=	np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]   )
       a						:int										=	np.array([[0, 3], [3, 0], [2, 3]]   )
       a						:List[Any]										=	np.array([[2, 1], [6, 3]]   )

       a						:List[str]										=	schur_complement(_lowerCamelCase ,  _lowerCamelCase ,  _lowerCamelCase   )

       a						:Dict										=	np.block([[a, b], [b.T, c]]   )

       a						:Optional[Any]										=	np.linalg.det(_lowerCamelCase   )
       a						:str										=	np.linalg.det(_lowerCamelCase   )
       a						:int										=	np.linalg.det(_lowerCamelCase   )

       self.assertAlmostEqual(_lowerCamelCase ,  det_a * det_s   )




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       a						:Optional[Any]										=	np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]   )
       a						:Optional[int]										=	np.array([[0, 3], [3, 0], [2, 3]]   )
       a						:Optional[int]										=	np.array([[2, 1], [6, 3]]   )

       with self.assertRaises(_lowerCamelCase   ):
             schur_complement(_lowerCamelCase ,  _lowerCamelCase ,  _lowerCamelCase   )




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       a						:Union[str, Any]										=	np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]   )
       a						:Optional[Any]										=	np.array([[0, 3], [3, 0], [2, 3]]   )
       a						:List[Any]										=	np.array([[2, 1, 3], [6, 3, 5]]   )

       with self.assertRaises(_lowerCamelCase   ):
             schur_complement(_lowerCamelCase ,  _lowerCamelCase ,  _lowerCamelCase   )


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     unittest.main()









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     __lowerCamelCase						(			UpperCAmelCase_						:		dict						):




      """simple docstring"""





      return (data["data"], data["target"])
def     __lowerCamelCase						(			UpperCAmelCase_						:		np.ndarray			,  UpperCAmelCase_						:		np.ndarray						):




      """simple docstring"""





      a						:Optional[Any]										=	XGBClassifier()
      classifier.fit(UpperCAmelCase_			,  UpperCAmelCase_						)
      return classifier
def     __lowerCamelCase						(			):




      """simple docstring"""





      a						:List[Any]										=	load_iris()
      a							,    a						:Any										=	data_handling(UpperCAmelCase_						)
      a							,    a							,    a							,    a						:Tuple										=	train_test_split(
          UpperCAmelCase_			,  UpperCAmelCase_			,  test_size=0.25						)

      a						:List[Any]										=	iris['''target_names''']

      # Create an XGBoost Classifier from the training data
      a						:Optional[int]										=	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()





