'''simple docstring'''





SCREAMING_SNAKE_CASE_:     str  =2_56
# Modulus to hash a string
SCREAMING_SNAKE_CASE_:     int  =1_00_00_03





def 	lowerCAmelCase_				(					snake_case_       : str					,    snake_case_       : str			)    ->      bool:


     '''simple docstring'''




     UpperCAmelCase_           =   len(snake_case_			)
     UpperCAmelCase_           =   len(snake_case_			)
     if p_len > t_len:
          return False

     UpperCAmelCase_           =   0
     UpperCAmelCase_           =   0
     UpperCAmelCase_           =   1

     # Calculating the hash of pattern and substring of text
     for i in range(snake_case_			):
          UpperCAmelCase_           =   (ord(pattern[i]			) + p_hash * alphabet_size) % modulus
          UpperCAmelCase_           =   (ord(text[i]			) + text_hash * alphabet_size) % modulus
          if i == p_len - 1:
               continue
          UpperCAmelCase_           =   (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
          UpperCAmelCase_           =   (
              (text_hash - ord(text[i]			) * modulus_power) * alphabet_size
              + ord(text[i + p_len]			)
          ) % modulus
     return False





def 	lowerCAmelCase_				(					)    ->      None:


     '''simple docstring'''




     UpperCAmelCase_           =   "abc1abc12"
     UpperCAmelCase_           =   "alskfjaldsabc1abc1abc12k23adsfabcabc"
     UpperCAmelCase_           =   "alskfjaldsk23adsfabcabc"
     assert rabin_karp(snake_case_					,    snake_case_			) and not rabin_karp(snake_case_					,    snake_case_			)

     # Test 2)
     UpperCAmelCase_           =   "ABABX"
     UpperCAmelCase_           =   "ABABZABABYABABX"
     assert rabin_karp(snake_case_					,    snake_case_			)

     # Test 3)
     UpperCAmelCase_           =   "AAAB"
     UpperCAmelCase_           =   "ABAAAAAB"
     assert rabin_karp(snake_case_					,    snake_case_			)

     # Test 4)
     UpperCAmelCase_           =   "abcdabcy"
     UpperCAmelCase_           =   "abcxabcdabxabcdabcdabcy"
     assert rabin_karp(snake_case_					,    snake_case_			)

     # Test 5)
     UpperCAmelCase_           =   "Lü"
     UpperCAmelCase_           =   "Lüsai"
     assert rabin_karp(snake_case_					,    snake_case_			)
     UpperCAmelCase_           =   "Lue"
     assert not rabin_karp(snake_case_					,    snake_case_			)
     print("Success."			)


if __name__ == "__main__":
    test_rabin_karp()





'''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 	UpperCamelCase_							(					_UpperCAmelCase  :      dict    )    ->    tuple:


       """simple docstring"""







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

def 	UpperCamelCase_							(					_UpperCAmelCase  :      np.ndarray			,	_UpperCAmelCase  :      np.ndarray    )    ->    XGBClassifier:


       """simple docstring"""







       _UpperCAmelCase     :  Any							      =    XGBClassifier()
       classifier.fit(_UpperCAmelCase			,	_UpperCAmelCase    )
       return classifier

def 	UpperCamelCase_							(					)    ->    None:


       """simple docstring"""







       _UpperCAmelCase     :  List[str]							      =    load_iris()
       _UpperCAmelCase      ,  _UpperCAmelCase     :  Dict							      =    data_handling(_UpperCAmelCase    )
       _UpperCAmelCase      ,  _UpperCAmelCase      ,  _UpperCAmelCase      ,  _UpperCAmelCase     :  str							      =    train_test_split(
           _UpperCAmelCase			,	_UpperCAmelCase			,	test_size=0.2_5    )

       _UpperCAmelCase     :  Optional[Any]							      =    iris["target_names"]

       # Create an XGBoost Classifier from the training data
       _UpperCAmelCase     :  Tuple							      =    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()

