




'''simple docstring'''





from collections import Counter

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

_SCREAMING_SNAKE_CASE							:       int						=			datasets.load_iris()

_SCREAMING_SNAKE_CASE							:       Union[str, Any]						=			np.array(data["data"])
_SCREAMING_SNAKE_CASE							:       Dict						=			np.array(data["target"])
_SCREAMING_SNAKE_CASE							:       List[Any]						=			data["target_names"]

_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE							:       int						=			train_test_split(X, y)


def 					UpperCamelCase_(     snake_case							:	Tuple							,    snake_case							:	Tuple					):

							'''simple docstring'''






							return np.linalg.norm(np.array(snake_case					) - np.array(snake_case					)					)


def 					UpperCamelCase_(     snake_case							:	int							,    snake_case							:	List[str]							,    snake_case							:	Tuple							,    snake_case							:	Tuple							,    snake_case							:	List[str]=5					):

							'''simple docstring'''






							snake_case_      =				zip(snake_case							,    snake_case					)
							# List of distances of all points from the point to be classified
							snake_case_      =				[]
							for data_point in data:
														snake_case_      =				euclidean_distance(data_point[0]							,    snake_case					)
														distances.append((distance, data_point[1])					)
							# Choosing 'k' points with the least distances.
							snake_case_      =				[i[1] for i in sorted(snake_case					)[:k]]
							# Most commonly occurring class among them
							# is the class into which the point is classified
							snake_case_      =				Counter(snake_case					).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]))










'''simple docstring'''





from sympy import diff, lambdify, symbols
from sympy.functions import *  # noqa: F403


def 					UpperCamelCase_(     snake_case							:	str							,    snake_case							:	complex							,    snake_case							:	str = "x"							,    snake_case							:	float = 1_0**-1_0							,    snake_case							:	int = 1							,    ):

							'''simple docstring'''






							snake_case_      =				symbols(snake_case					)
							snake_case_      =				lambdify(snake_case							,    snake_case					)
							snake_case_      =				lambdify(snake_case							,    diff(snake_case							,    snake_case					)					)

							snake_case_      =				starting_point

							while True:
														if diff_function(snake_case					) != 0:
																					snake_case_      =				prev_guess - multiplicity * func(snake_case					) / diff_function(
																					    snake_case					)
														else:
																					raise ZeroDivisionError("Could not find root"					) from None

														# Precision is checked by comparing the difference of consecutive guesses
														if abs(next_guess - prev_guess					) < precision:
																					return next_guess

														snake_case_      =				next_guess


# Let's Execute
if __name__ == "__main__":
		# Find root of trigonometric function
		# Find value of pi
		print(F"The root of sin(x) = 0 is {newton_raphson('sin(x)', 2)}")

		# Find root of polynomial
		# Find fourth Root of 5
		print(F"The root of x**4 - 5 = 0 is {newton_raphson('x**4 -5', 0.4 +5j)}")

		# Find value of e
		print(
		    "The root of log(y) - 1 = 0 is ",
		    F"{newton_raphson('log(y) - 1', 2, variable='y')}",
		)

		# Exponential Roots
		print(
		    "The root of exp(x) - 1 = 0 is",
		    F"{newton_raphson('exp(x) - 1', 10, precision=0.0_0_5)}",
		)

		# Find root of cos(x)
		print(F"The root of cos(x) = 0 is {newton_raphson('cos(x)', 0)}")




