codekarim is just a bunch of reminders for fenuapps.com
# -*- coding: utf-8 -*- ''' Created on Wed Jan 16 10:23:46 2019 @author: K https://pythonfordatascience.org/logistic-regression-python/ ''' # module imports from patsy import dmatrices import pandas as pd from sklearn.linear_model import LogisticRegression import statsmodels.discrete.discrete_model as sm # read in the data & create matrices df = pd.read_csv(r"C:\Users\K\Desktop\AI\Modèles\RegressionsLogistique\binary.csv", engine='python') y, X = dmatrices('admit ~ gre + gpa + rank', df, return_type = 'dataframe') # sklearn output #model = LogisticRegression(fit_intercept = False,C=1e9) #C=1/λ. où λ est le paramètre de régularisation #model = LogisticRegression(fit_intercept=False, C=1e9, solver='newton-cg') model = LogisticRegression(fit_intercept=False,C=1e9, solver='newton-cg') mdl = model.fit(X, y) print(model.coef_) Xnew = [[1,800,4,1]] ynew = mdl.predict(Xnew) print(ynew) print("*****************") # sm logit = sm.Logit(y, X) print(logit.fit().params)