logistic-regression

Using SGD without using sklearn (LogLoss increasing with every epoch)

荒凉一梦 提交于 2020-08-08 05:16:08
问题 def train(X_train,y_train,X_test,y_test,epochs,alpha,eta0): w,b = initialize_weights(X_train[0]) loss_test=[] N=len(X_train) for i in range(0,epochs): print(i) for j in range(N-1): grad_dw=gradient_dw(X_train[j],y_train[j],w,b,alpha,N) grad_db=gradient_db(X_train[j],y_train[j],w,b) w=np.array(w)+(alpha*(np.array(grad_dw))) b=b+(alpha*(grad_db)) predict2 = [] for m in range(len(y_test)): z=np.dot(w[0],X_test[m])+b if sigmoid(z) == 0: # sigmoid(w,x,b) returns 1/(1+exp(-(dot(x,w)+b))) predict2

How to fix Statsmodel warning: “Maximum no. of iterations has exceeded”

空扰寡人 提交于 2020-08-02 07:28:46
问题 I am using Anaconda and I am trying logistic regression. After loading training data set and performed the regression. Then I got the following warning message. train_cols = data.columns[1:] logit = sm.Logit(data['harmful'], data[train_cols]) result = logit.fit() Warning: Maximum number of iterations has been exceeded. Current function value: 0.000004 Iterations: 35 C:\Users\dell\Anaconda\lib\site-packages\statsmodels\base\model.py:466: ConvergenceWarning: Maximum Likelihood optimization

What does sklearn “RidgeClassifier” do?

筅森魡賤 提交于 2020-08-01 12:23:58
问题 I'm trying to understand the difference between RidgeClassifier and LogisticRegression in sklearn.linear_model . I couldn't find it in the documentation. I think I understand quite well what the LogisticRegression does.It computes the coefficients and intercept to minimise half of sum of squares of the coefficients + C times the binary cross-entropy loss , where C is the regularisation parameter. I checked against a naive implementation from scratch, and results coincide. Results of