



"""simple docstring"""





import numpy as np
from matplotlib import pyplot as plt
from sklearn import datasets




def 	UpperCAmelCase     (		A	:						List[Any]       ):

		'''simple docstring'''


		return 1 / (1 + np.exp(-z       ))




def 	UpperCAmelCase     (		A	:						List[str]     ,				A	:						int       ):

		'''simple docstring'''


		return (-y * np.log(UpperCamelCase__       ) - (1 - y) * np.log(1 - h       )).mean()




def 	UpperCAmelCase     (		A	:						Dict     ,				A	:						Dict     ,				A	:						str       ):

		'''simple docstring'''


		_UpperCAmelCase							 =		np.dot(UpperCamelCase__     ,				UpperCamelCase__       )
		return np.sum(y * scores - np.log(1 + np.exp(UpperCamelCase__       )       )       )




def 	UpperCAmelCase     (		A	:						List[Any]     ,				A	:						Any     ,				A	:						Optional[int]     ,				A	:						int=7_0000       ):

		'''simple docstring'''


		_UpperCAmelCase							 =		np.zeros(x.shape[1]       )

		for iterations in range(UpperCamelCase__       ):
				_UpperCAmelCase							 =		np.dot(UpperCamelCase__     ,				UpperCamelCase__       )
				_UpperCAmelCase							 =		sigmoid_function(UpperCamelCase__       )
				_UpperCAmelCase							 =		np.dot(x.T     ,				h - y       ) / y.size
				_UpperCAmelCase							 =		theta - alpha * gradient  # updating the weights
				_UpperCAmelCase							 =		np.dot(UpperCamelCase__     ,				UpperCamelCase__       )
				_UpperCAmelCase							 =		sigmoid_function(UpperCamelCase__       )
				_UpperCAmelCase							 =		cost_function(UpperCamelCase__     ,				UpperCamelCase__       )
				if iterations % 100 == 0:
						print(f'loss: {j} \t'       )  # printing the loss after every 100 iterations
		return theta


# In[68]:

if __name__ == "__main__":
							lowercase  							=					datasets.load_iris()
							lowercase  							=					iris.data[:, :2]
							lowercase  							=					(iris.target != 0) * 1

							lowercase  							=					0.1
							lowercase  							=					logistic_reg(alpha, x, y, max_iterations=7_00_00)
							print('''theta: ''', theta)  # printing the theta i.e our weights vector




							def 	UpperCAmelCase     (		A	:						Optional[int]       ):

									'''simple docstring'''


									return sigmoid_function(
									    np.dot(UpperCamelCase__     ,				UpperCamelCase__       )       )  # predicting the value of probability from the logistic regression algorithm

							plt.figure(figsize=(10, 6))
							plt.scatter(x[y == 0][:, 0], x[y == 0][:, 1], color='''b''', label='''0''')
							plt.scatter(x[y == 1][:, 0], x[y == 1][:, 1], color='''r''', label='''1''')
							(lowercase)  							=					(x[:, 0].min(), x[:, 0].max())
							(lowercase)  							=					(x[:, 1].min(), x[:, 1].max())
							(lowercase)  							=					np.meshgrid(np.linspace(xa_min, xa_max), np.linspace(xa_min, xa_max))
							lowercase  							=					np.c_[xxa.ravel(), xxa.ravel()]
							lowercase  							=					predict_prob(grid).reshape(xxa.shape)
							plt.contour(xxa, xxa, probs, [0.5], linewidths=1, colors='''black''')

							plt.legend()






							plt.show()







"""simple docstring"""





from itertools import permutations




def 	UpperCAmelCase     (		A	:						tuple       ):

		'''simple docstring'''


		if num[3] % 2 != 0:
				return False

		if (num[2] + num[3] + num[4]) % 3 != 0:
				return False

		if num[5] % 5 != 0:
				return False

		_UpperCAmelCase							 =		[7, 11, 13, 17]
		for i, test in enumerate(A       ):
				if (num[i + 4] * 100 + num[i + 5] * 10 + num[i + 6]) % test != 0:
						return False
		return True




def 	UpperCAmelCase     (		A	:						int = 10       ):

		'''simple docstring'''


		return sum(
		    int(''.join(map(A     ,				A       )       )       )
		    for num in permutations(range(A       )       )
		    if is_substring_divisible(A       )       )


if __name__ == "__main__":
					print(F'''{solution() = }''')


