


from collections import Counter

import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split

__UpperCamelCase    		=       datasets.load_iris()

__UpperCamelCase    		=       np.array(data['data'])
__UpperCamelCase    		=       np.array(data['target'])
__UpperCamelCase    		=       data['target_names']

__UpperCamelCase		,  __UpperCamelCase		,  __UpperCamelCase		,  __UpperCamelCase    		=       train_test_split(X, y)
def        UpperCamelCase_(				_A   :Any				,     _A   :Any  )->		str:
			return np.linalg.norm(np.array(_A  ) - np.array(_A  )  )
def        UpperCamelCase_(				_A   :Tuple				,     _A   :Any				,     _A   :List[str]				,     _A   :str				,     _A   :Tuple=5  )->		List[Any]:
			UpperCamelCase__					=       zip(_A				,     _A  )
			# List of distances of all points from the point to be classified
			UpperCamelCase__					=       []
			for data_point in data:
						UpperCamelCase__					=       euclidean_distance(data_point[0]				,     _A  )
						distances.append((distance, data_point[1])  )
			# Choosing 'k' points with the least distances.
			UpperCamelCase__					=       [i[1] for i in sorted(_A  )[:k]]
			# Most commonly occurring class among them
			# is the class into which the point is classified
			UpperCamelCase__					=       Counter(_A  ).most_common(1  )[0][0]
			return classes[result]


if __name__ == "__main__":
						print(classifier(X_train, y_train, classes, [4.4, 3.1, 1.3, 1.4]))






from collections import deque
def        UpperCamelCase_(				_A   :Union[str, Any]  )->		List[Any]:
			UpperCamelCase__					=       len(_A  )
			UpperCamelCase__					=       deque()
			UpperCamelCase__					=       [False for _ in range(_A  )]
			UpperCamelCase__					=       [-1 for _ in range(_A  )]
			UpperCamelCase__					=       index_of[:]

			def strong_connect(_A   :Optional[int]				,     _A   :Optional[int]				,     _A   :List[Any]  ):
						UpperCamelCase__					=       index  # the number when this node is seen
						UpperCamelCase__					=       index  # lowest rank node reachable from here
						index += 1
						stack.append(_A  )
						UpperCamelCase__					=       True

						for w in g[v]:
									if index_of[w] == -1:
												UpperCamelCase__					=       strong_connect(_A				,     _A				,     _A  )
												UpperCamelCase__					=       (
												    lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
												)
									elif on_stack[w]:
												UpperCamelCase__					=       (
												    lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
												)

						if lowlink_of[v] == index_of[v]:
									UpperCamelCase__					=       []
									UpperCamelCase__					=       stack.pop()
									UpperCamelCase__					=       False
									component.append(_A  )
									while w != v:
												UpperCamelCase__					=       stack.pop()
												UpperCamelCase__					=       False
												component.append(_A  )
									components.append(_A  )
						return index

			UpperCamelCase__					=       []
			for v in range(_A  ):
						if index_of[v] == -1:
									strong_connect(_A				,     0				,     _A  )

			return components
def        UpperCamelCase_(				_A   :Optional[Any]				,     _A   :Any  )->		Union[str, Any]:
			UpperCamelCase__					=       [[] for _ in range(_A  )]
			for u, v in edges:
						g[u].append(_A  )
			return g


if __name__ == "__main__":
						# Test
						__UpperCamelCase    		=       7
						__UpperCamelCase    		=       [0, 0, 1, 2, 3, 3, 4, 4, 6]
						__UpperCamelCase    		=       [1, 3, 2, 0, 1, 4, 5, 6, 5]
						__UpperCamelCase    		=       [(u, v) for u, v in zip(source, target)]
						__UpperCamelCase    		=       create_graph(n_vertices, edges)

						assert [[5], [6], [4], [3, 2, 1, 0]] == tarjan(g)


