"""simple docstring"""






# Logistic Regression from scratch

# In[62]:

# In[63]:

# importing all the required libraries

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



def 						a_		(      lowerCamelCase ):
				return 1 / (1 + np.exp(-z ))



def 						a_		(      lowerCamelCase      ,    lowerCamelCase ):
				return (-y * np.log(lowerCamelCase ) - (1 - y) * np.log(1 - h )).mean()



def 						a_		(      lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase ):
				UpperCAmelCase__    =							np.dot(lowerCamelCase      ,    lowerCamelCase )
				return np.sum(y * scores - np.log(1 + np.exp(lowerCamelCase ) ) )



def 						a_		(      lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase=7_0_0_0_0 ):
				UpperCAmelCase__    =							np.zeros(x.shape[1] )

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


# In[68]:

if __name__ == "__main__":
						lowerCAmelCase__						:						str		  =			datasets.load_iris()
						lowerCAmelCase__						:						List[str]		  =			iris.data[:, :2]
						lowerCAmelCase__						:						Optional[int]		  =			(iris.target != 0) * 1

						lowerCAmelCase__						:						str		  =			0.1
						lowerCAmelCase__						:						int		  =			logistic_reg(alpha, x, y, max_iterations=70_000)
						print('theta: ', theta)  # printing the theta i.e our weights vector



						def 						a_		(      lowerCamelCase ):
										return sigmoid_function(
										    np.dot(lowerCamelCase      ,    lowerCamelCase ) )  # 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')
						((lowerCAmelCase__)  ,			(lowerCAmelCase__))						:						Any		  =			(x[:, 0].min(), x[:, 0].max())
						((lowerCAmelCase__)  ,			(lowerCAmelCase__))						:						str		  =			(x[:, 1].min(), x[:, 1].max())
						((lowerCAmelCase__)  ,			(lowerCAmelCase__))						:						List[Any]		  =			np.meshgrid(np.linspace(xa_min, xa_max), np.linspace(xa_min, xa_max))
						lowerCAmelCase__						:						List[str]		  =			np.c_[xxa.ravel(), xxa.ravel()]
						lowerCAmelCase__						:						Dict		  =			predict_prob(grid).reshape(xxa.shape)
						plt.contour(xxa, xxa, probs, [0.5], linewidths=1, colors='black')

						plt.legend()







						plt.show()




"""simple docstring"""






import random
class        snake_case :




					"""simple docstring"""

					@staticmethod
					def 	__lowerCAmelCase		(       lowerCamelCase__     :			str    ):
									UpperCAmelCase__    =							[ord(lowerCamelCase__    ) for i in text]
									UpperCAmelCase__    =							[]
									UpperCAmelCase__    =							[]
									for i in plain:
													UpperCAmelCase__    =							random.randint(1					,300    )
													UpperCAmelCase__    =							(i + k) * k
													cipher.append(lowerCamelCase__    )
													key.append(lowerCamelCase__    )
									return cipher, key







					@staticmethod
					def 	__lowerCAmelCase		(       lowerCamelCase__     :			list[int]					,lowerCamelCase__     :			list[int]    ):
									UpperCAmelCase__    =							[]
									for i in range(len(lowerCamelCase__    )    ):
													UpperCAmelCase__    =							int((cipher[i] - (key[i]) ** 2) / key[i]    )
													plain.append(chr(lowerCamelCase__    )    )
									return "".join(lowerCamelCase__    )


if __name__ == "__main__":
						lowerCAmelCase__  ,			lowerCAmelCase__						:						Dict		  =			Onepad().encrypt('Hello')
						print(c, k)
						print(Onepad().decrypt(c, k))



