


'''simple docstring'''

def __snake_case      (   UpperCAmelCase_		:		Optional[int]	):
 if not head:
  return True
 # split the list to two parts
 lowerCamelCase_				,lowerCamelCase_  				=						head.next, head
 while fast and fast.next:
  lowerCamelCase_  				=						fast.next.next
  lowerCamelCase_  				=						slow.next
 lowerCamelCase_  				=						slow.next
 lowerCamelCase_  				=						None  # Don't forget here! But forget still works!
 # reverse the second part
 lowerCamelCase_  				=						None
 while second:
  lowerCamelCase_  				=						second.next
  lowerCamelCase_  				=						node
  lowerCamelCase_  				=						second
  lowerCamelCase_  				=						nxt
 # compare two parts
 # second part has the same or one less node
 while node:
  if node.val != head.val:
   return False
  lowerCamelCase_  				=						node.next
  lowerCamelCase_  				=						head.next
 return True





def __snake_case      (   UpperCAmelCase_		:		List[Any]	):
 if not head or not head.next:
  return True

 # 1. Get the midpoint (slow)
 lowerCamelCase_  				=						lowerCamelCase_  				=						lowerCamelCase_  				=						head
 while fast and fast.next:
  lowerCamelCase_				,lowerCamelCase_  				=						fast.next.next, slow.next

 # 2. Push the second half into the stack
 lowerCamelCase_  				=						[slow.val]
 while slow.next:
  lowerCamelCase_  				=						slow.next
  stack.append(slow.val	)

 # 3. Comparison
 while stack:
  if stack.pop() != cur.val:
   return False
  lowerCamelCase_  				=						cur.next

 return True







def __snake_case      (   UpperCAmelCase_		:		List[str]	):
 if not head or not head.next:
  return True
 lowerCamelCase_  				=						{}
 lowerCamelCase_  				=						0
 while head:
  if head.val in d:
   d[head.val].append(UpperCAmelCase_	)
  else:
   lowerCamelCase_  				=						[pos]
  lowerCamelCase_  				=						head.next
  pos += 1
 lowerCamelCase_  				=						pos - 1
 lowerCamelCase_  				=						0
 for v in d.values():
  if len(UpperCAmelCase_	) % 2 != 0:
   middle += 1
  else:
   lowerCamelCase_  				=						0
   for i in range(0      ,       len(UpperCAmelCase_	)	):
    if v[i] + v[len(UpperCAmelCase_	) - 1 - step] != checksum:
     return False
    step += 1
  if middle > 1:
   return False
 return True







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



