
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_ (				lowerCamelCase__    ):
				return (data["data"], data["target"])





def 			lowerCamelCase_ (				lowerCamelCase__	, lowerCamelCase__    ):
				lowerCamelCase_						=			XGBClassifier()
				classifier.fit(lowerCamelCase__	, lowerCamelCase__    )
				return classifier





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

				lowerCamelCase_						=			iris["target_names"]

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

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


if __name__ == "__main__":
			import doctest

			doctest.testmod(verbose=True)
			main()









'''simple docstring'''







import math
class 				__SCREAMING_SNAKE_CASE  :






				"""simple docstring"""







				def   UpperCamelCase__   (  self     :					List[str]					,				__a     :					list[list[float]]					,				__a     :					list[int]					):
								_a								= 0.0
								_a								= 0.0
								for i in range(len(__a					)					):
												da += math.pow((sample[i] - weights[0][i])					,				2					)
												da += math.pow((sample[i] - weights[1][i])					,				2					)
												return 0 if da > da else 1
								return 0




				def   UpperCamelCase__   (  self     :					List[Any]					,				__a     :					list[list[int | float]]					,				__a     :					list[int]					,				__a     :					int					,				__a     :					float					):
								for i in range(len(__a					)					):
												weights[j][i] += alpha * (sample[i] - weights[j][i])
								return weights






def  _lowerCamelCase				( )	->	None:
				# Training Examples ( m, n )
				_a								= [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

				# weight initialization ( n, C )
				_a								= [[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

				# training
				_a								= SelfOrganizingMap()
				_a								= 3
				_a								= 0.5

				for _ in range(lowercase						):
								for j in range(len(lowercase						)						):
												# training sample
												_a								= training_samples[j]

												# Compute the winning vector
												_a								= self_organizing_map.get_winner(lowercase    ,							lowercase						)

												# Update the winning vector
												_a								= self_organizing_map.update(lowercase    ,							lowercase    ,							lowercase    ,							lowercase						)

    # classify test sample
				_a								= [0, 0, 0, 1]
				_a								= self_organizing_map.get_winner(lowercase    ,							lowercase						)

				# results
				print(F'Clusters that the test sample belongs to : {winner}'						)
				print(F'Weights that have been trained : {weights}'						)


# running the main() function
if __name__ == "__main__":
					main()
