


snake_case    :   Tuple	    =					2_56
# Modulus to hash a string
snake_case    :   Union[str, Any]	    =					1_00_00_03
def     __lowerCamelCase						(			UpperCAmelCase_						:		str			,  UpperCAmelCase_						:		str						):




      """simple docstring"""





      a						:List[str]										=	len(UpperCAmelCase_						)
      a						:Tuple										=	len(UpperCAmelCase_						)
      if p_len > t_len:
            return False

      a						:str										=	0
      a						:Union[str, Any]										=	0
      a						:Optional[int]										=	1

      # Calculating the hash of pattern and substring of text
      for i in range(UpperCAmelCase_						):
            a						:List[Any]										=	(ord(pattern[i]						) + p_hash * alphabet_size) % modulus
            a						:int										=	(ord(text[i]						) + text_hash * alphabet_size) % modulus
            if i == p_len - 1:
                  continue
            a						:int										=	(modulus_power * alphabet_size) % modulus

      for i in range(0			,  t_len - p_len + 1						):
            if text_hash == p_hash and text[i : i + p_len] == pattern:
                  return True
            if i == t_len - p_len:
                  continue
            # Calculate the https://en.wikipedia.org/wiki/Rolling_hash
            a						:List[Any]										=	(
                (text_hash - ord(text[i]						) * modulus_power) * alphabet_size
                + ord(text[i + p_len]						)
            ) % modulus
      return False
def     __lowerCamelCase						(			):




      """simple docstring"""





      a						:Tuple										=	'''abc1abc12'''
      a						:str										=	'''alskfjaldsabc1abc1abc12k23adsfabcabc'''
      a						:List[str]										=	'''alskfjaldsk23adsfabcabc'''
      assert rabin_karp(UpperCAmelCase_			,  UpperCAmelCase_						) and not rabin_karp(UpperCAmelCase_			,  UpperCAmelCase_						)

      # Test 2)
      a						:List[str]										=	'''ABABX'''
      a						:str										=	'''ABABZABABYABABX'''
      assert rabin_karp(UpperCAmelCase_			,  UpperCAmelCase_						)

      # Test 3)
      a						:Dict										=	'''AAAB'''
      a						:Optional[int]										=	'''ABAAAAAB'''
      assert rabin_karp(UpperCAmelCase_			,  UpperCAmelCase_						)

      # Test 4)
      a						:List[str]										=	'''abcdabcy'''
      a						:Optional[int]										=	'''abcxabcdabxabcdabcdabcy'''
      assert rabin_karp(UpperCAmelCase_			,  UpperCAmelCase_						)

      # Test 5)
      a						:Optional[int]										=	'''Lü'''
      a						:Union[str, Any]										=	'''Lüsai'''
      assert rabin_karp(UpperCAmelCase_			,  UpperCAmelCase_						)
      a						:Optional[int]										=	'''Lue'''
      assert not rabin_karp(UpperCAmelCase_			,  UpperCAmelCase_						)
      print('''Success.'''						)


if __name__ == "__main__":
   test_rabin_karp()









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





