nowinitialize the weights as followsself theta np zeros( shape[ ]for in range(self num_iter) np dot(xself thetah self __sigmoid(zgradient np dot( ( ) size self theta -self lr gradient np dot(xself thetah self __sigmoid(zloss self __loss(hyif(self verbose ==true and = )print( 'loss{loss\ 'with the help of the following scriptwe can predict the output probabilitiesdef predict_prob(selfx)if self fit_interceptx self __add_intercept(xreturn self __sigmoid(np dot(xself theta)def predict(selfx)return self predict_prob(xround(nextwe can evaluate the model and plot it as followsmodel logisticregression(lr= num_iter= preds model predict( (preds =ymean(plt figure(figsize=( )plt scatter( [ = ][: ] [ = ][: ]color=' 'label=' 'plt scatter( [ = ][: ] [ = ][: ]color=' 'label=' 'plt legend( _minx _max [:, min() [:, max() _minx _max [:, min() [:, max()