The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Anybody can ask a question
Anybody can answer
The best answers are voted up and moderated by our team

Logistic Regression

Logistic Regression


I know it may be a more advanced topic, but please provide an explanation or a link to where myself and others may go to understand the linear algebra and operations of the following code: 
from sklearn import linear_model
import scipy.stats as stat
class LogisticRegression_with_p_values:

def __init__(self,*args,**kwargs):
self.model = linear_model.Logisticregression(*args,**kwargs)

def fit(self,X,y):,y)
denom = (2.0 * (1.0 + np.cosh(self.model.decision_function(X))))
denom = np.tile(denom,(X.shape[1],1)).T
F_ij = / denom).T,X)
Cramer_Rao = np.linalg.inv(F_ij)
sigma_estimates = np.sqrt(np.diagonal(Cramer_Rao))
z_scores = self.model.coef_[0] / sigma_estimates
p_values = [stat.norm.sf(abs(x)) * 2 for x in z_scores]
self.coef_ = self.model.coef_
self.intercept_ = self.model.intercept_
self.p_values = p_values
(taken from a video by 365 Data Science about Logistic Regression and how to add p_values to the coefficient (beta estimates) once you fit a model using Sklearn).

1 Answer

365 Team

Hi John,
We haven’t really been into this, because you don’t need explanation, but rather a whole book on econometrics, to be honest.
I suggest using “Econometric Analysis” by William H. Greene. Unfortunately, I don’t think any single explanation can help, unless you’ve been through a thorough journey through econometrics (and the actual formulas, so you can turn them in code).
The 365 Team

Complete Data Science Education
Get 50% OFF