'''simple docstring'''

UpperCamelCase__     :	Optional[Any]				=			'ABCDEFGHIJKLMNOPQRSTUVWXYZ'







def __UpperCamelCase(   ):
   '''simple docstring'''
   UpperCAmelCase__							:				Any   				=  input('''Enter message: '''    )
   UpperCAmelCase__							:				Optional[Any]   				=  input('''Enter key [alphanumeric]: '''    )
   UpperCAmelCase__							:				str   				=  input('''Encrypt/Decrypt [e/d]: '''    )

   if mode.lower().startswith('''e'''    ):
      UpperCAmelCase__							:				List[Any]   				=  '''encrypt'''
      UpperCAmelCase__							:				List[str]   				=  encrypt_message(_A  ,			_A    )
   elif mode.lower().startswith('''d'''    ):
      UpperCAmelCase__							:				List[Any]   				=  '''decrypt'''
      UpperCAmelCase__							:				str   				=  decrypt_message(_A  ,			_A    )

   print(F'''\n{mode.title()}ed message:'''    )
   print(_A    )







def __UpperCamelCase(   _A					:				str  ,			_A					:				str    ):
   '''simple docstring'''
   return translate_message(_A  ,			_A  ,			'''encrypt'''    )







def __UpperCamelCase(   _A					:				str  ,			_A					:				str    ):
   '''simple docstring'''
   return translate_message(_A  ,			_A  ,			'''decrypt'''    )







def __UpperCamelCase(   _A					:				str  ,			_A					:				str  ,			_A					:				str    ):
   '''simple docstring'''
   UpperCAmelCase__							:				List[str]   				=  []
   UpperCAmelCase__							:				Dict   				=  0
   UpperCAmelCase__							:				List[str]   				=  key.upper()

   for symbol in message:
      UpperCAmelCase__							:				Union[str, Any]   				=  LETTERS.find(symbol.upper()    )
      if num != -1:
         if mode == "encrypt":
            num += LETTERS.find(key[key_index]    )
         elif mode == "decrypt":
            num -= LETTERS.find(key[key_index]    )

         num %= len(_A    )

         if symbol.isupper():
            translated.append(LETTERS[num]    )
         elif symbol.islower():
            translated.append(LETTERS[num].lower()    )

         key_index += 1
         if key_index == len(_A    ):
            UpperCAmelCase__							:				Optional[Any]   				=  0
      else:
         translated.append(_A    )
   return "".join(_A    )


if __name__ == "__main__":
  main()





'''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 __UpperCamelCase(   _A					:				str    ):
   '''simple docstring'''
   return 1 / (1 + np.exp(-z    ))







def __UpperCamelCase(   _A					:				int  ,			_A					:				str    ):
   '''simple docstring'''
   return (-y * np.log(_A    ) - (1 - y) * np.log(1 - h    )).mean()







def __UpperCamelCase(   _A					:				Optional[Any]  ,			_A					:				Tuple  ,			_A					:				Any    ):
   '''simple docstring'''
   UpperCAmelCase__							:				Union[str, Any]   				=  np.dot(_A  ,			_A    )
   return np.sum(y * scores - np.log(1 + np.exp(_A    )    )    )







def __UpperCamelCase(   _A					:				Dict  ,			_A					:				Optional[int]  ,			_A					:				List[Any]  ,			_A					:				str=7_00_00    ):
   '''simple docstring'''
   UpperCAmelCase__							:				List[Any]   				=  np.zeros(x.shape[1]    )

   for iterations in range(_A    ):
      UpperCAmelCase__							:				Tuple   				=  np.dot(_A  ,			_A    )
      UpperCAmelCase__							:				Optional[Any]   				=  sigmoid_function(_A    )
      UpperCAmelCase__							:				Optional[int]   				=  np.dot(x.T  ,			h - y    ) / y.size
      UpperCAmelCase__							:				List[Any]   				=  theta - alpha * gradient  # updating the weights
      UpperCAmelCase__							:				Tuple   				=  np.dot(_A  ,			_A    )
      UpperCAmelCase__							:				Tuple   				=  sigmoid_function(_A    )
      UpperCAmelCase__							:				Optional[int]   				=  cost_function(_A  ,			_A    )
      if iterations % 1_00 == 0:
         print(F'''loss: {j} \t'''    )  # printing the loss after every 100 iterations
   return theta


# In[68]:

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

  UpperCamelCase__     :	Any				=			0.1
  UpperCamelCase__     :	List[str]				=			logistic_reg(alpha, x, y, max_iterations=70_000)
  print('theta: ', theta)  # printing the theta i.e our weights vector







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

  plt.legend()
  plt.show()




