






'''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(					UpperCamelCase__			:  Union[str, Any]							):




      '''simple docstring'''






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





def 	_a(					UpperCamelCase__			:  str,		UpperCamelCase__			:  Tuple							):




      '''simple docstring'''






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





def 	_a(					UpperCamelCase__			:  Dict,		UpperCamelCase__			:  Tuple,		UpperCamelCase__			:  str							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=np.dot(SCREAMING_SNAKE_CASE_,		SCREAMING_SNAKE_CASE_							)
      return np.sum(y * scores - np.log(1 + np.exp(SCREAMING_SNAKE_CASE_							)							)							)





def 	_a(					UpperCamelCase__			:  Optional[int],		UpperCamelCase__			:  Any,		UpperCamelCase__			:  Optional[int],		UpperCamelCase__			:  List[Any]=7_0_0_0_0							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__       :			str													=np.zeros(x.shape[1]							)

      for iterations in range(SCREAMING_SNAKE_CASE_							):
            SCREAMING_SNAKE_CASE__       :			Optional[int]													=np.dot(SCREAMING_SNAKE_CASE_,		SCREAMING_SNAKE_CASE_							)
            SCREAMING_SNAKE_CASE__       :			List[str]													=sigmoid_function(SCREAMING_SNAKE_CASE_							)
            SCREAMING_SNAKE_CASE__       :			Any													=np.dot(x.T,		h - y							) / y.size
            SCREAMING_SNAKE_CASE__       :			List[Any]													=theta - alpha * gradient  # updating the weights
            SCREAMING_SNAKE_CASE__       :			List[str]													=np.dot(SCREAMING_SNAKE_CASE_,		SCREAMING_SNAKE_CASE_							)
            SCREAMING_SNAKE_CASE__       :			Dict													=sigmoid_function(SCREAMING_SNAKE_CASE_							)
            SCREAMING_SNAKE_CASE__       :			List[Any]													=cost_function(SCREAMING_SNAKE_CASE_,		SCREAMING_SNAKE_CASE_							)
            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__":
     a_					=	datasets.load_iris()
     a_					=	iris.data[:, :2]
     a_					=	(iris.target != 0) * 1

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





     def 	_a(					UpperCamelCase__			:  List[Any]							):




           '''simple docstring'''






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

     plt.figure(figsize=(1_0, 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')
     (a_)					=	(x[:, 0].min(), x[:, 0].max())
     (a_)					=	(x[:, 1].min(), x[:, 1].max())
     (a_)					=	np.meshgrid(np.linspace(xa_min, xa_max), np.linspace(xa_min, xa_max))
     a_					=	np.c_[xxa.ravel(), xxa.ravel()]
     a_					=	predict_prob(grid).reshape(xxa.shape)
     plt.contour(xxa, xxa, probs, [0.5], linewidths=1, colors='black')

     plt.legend()







     plt.show()







'''simple docstring'''
def 	_a(					UpperCamelCase__			:  Optional[Any]=2_8_1_2_3							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__       :			List[Any]													=[1] * (limit + 1)

      for i in range(2,		int(limit**0.5							) + 1							):
            sum_divs[i * i] += i
            for k in range(i + 1,		limit // i + 1							):
                  sum_divs[k * i] += k + i

      SCREAMING_SNAKE_CASE__       :			List[str]													=set()
      SCREAMING_SNAKE_CASE__       :			str													=0

      for n in range(1,		limit + 1							):
            if sum_divs[n] > n:
                  abundants.add(UpperCamelCase__							)

            if not any((n - a in abundants) for a in abundants							):
                  res += n

      return res


if __name__ == "__main__":
  print(solution())