






"""simple docstring"""







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

def _a					(						_snake_case				):







      """simple docstring"""






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

def _a					(						_snake_case ,			_snake_case				):







      """simple docstring"""






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

def _a					(						_snake_case ,			_snake_case ,			_snake_case				):







      """simple docstring"""






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

def _a					(						_snake_case ,			_snake_case ,			_snake_case ,			_snake_case=7_0000				):







      """simple docstring"""






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

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


# In[68]:

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

  _UpperCamelCase	     =    0.1
  _UpperCamelCase	     =    logistic_reg(alpha, x, y, max_iterations=70000)
  print("""theta: """, theta)  # printing the theta i.e our weights vector

  def _a					(						_snake_case				):







        """simple docstring"""






        return sigmoid_function(
            np.dot(lowercase__ ,			lowercase__				)				)  # 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))	     =    (x[:, 0].min(), x[:, 0].max())
  ((_UpperCamelCase)     ,    (_UpperCamelCase))	     =    (x[:, 1].min(), x[:, 1].max())
  ((_UpperCamelCase)     ,    (_UpperCamelCase))	     =    np.meshgrid(np.linspace(xa_min, xa_max), np.linspace(xa_min, xa_max))
  _UpperCamelCase	     =    np.c_[xxa.ravel(), xxa.ravel()]
  _UpperCamelCase	     =    predict_prob(grid).reshape(xxa.shape)
  plt.contour(xxa, xxa, probs, [0.5], linewidths=1, colors="""black""")

  plt.legend()






  plt.show()





'''simple docstring'''





def snake_case_     (					lowercase__		):
  return sum(i for i in range(1   ,       number // 2 + 1		) if number % i == 0		) == number


if __name__ == "__main__":
      print("""Program to check whether a number is a Perfect number or not...""")
      SCREAMING_SNAKE_CASE     =       int(input("""Enter number: """).strip())
      print(F'{number} is {"" if perfect(number) else "not "}a Perfect Number.')



