def fit(self, X, y):
    self._initialize_parameters(X)
    for i in range(self.n_iters):
        y_pred = self.sigmoid(X.dot(self.param))
        if self.gradient_descent:
            self.param -= (self.lr * (y_pred - y).dot(X))
        else:
            diag_gradient = make_diagonal(self.sigmoid.gradient(X.dot(self.param)))
            self.param = np.linalg.pinv(X.T.dot(diag_gradient).dot(X)).dot(X.T).dot(((diag_gradient.dot(X).dot(self.param) + y) - y_pred))
def fit(self, X, y):
    self._initialize_parameters(X)
    for i in range(self.n_iters):
        y_pred = self.sigmoid(X.dot(self.param))
        if self.gradient_descent:
            self.param -= (self.lr * (y_pred - y).dot(X))
        else:
            diag_gradient = make_diagonal(self.sigmoid.gradient(X.dot(self.param)))
            self.param = np.linalg.pinv(X.T.dot(diag_gradient).dot(X)).dot(X.T).dot(((diag_gradient.dot(X).dot(self.param) + y) - y_pred))