title: logistic regression using statsmodels error in python
body: <p>I am trying to implement a logistic regression using statsmodels (I need the summary) and I get this error:</p>
  
  <pre><code>LinAlgError: Singular matrix
  </code></pre>
  
  <p>My df is numeric and correlated, I deleted the non-numeric and constant features.
  I tried to implement regular regression as well as one with l1 penalty (l2 isn't available) because of the correlated features.</p>
  
  <p>I tried to check the matrix rank and got this print:</p>
  
  <pre><code>print(len(df.columns)) -&gt; 156
  
  print(np.linalg.matrix_rank(df.values)) -&gt; 151
  </code></pre>
  
  <p>How do I know which features are a problem and why?</p>
  
  <p>my code:</p>
  
  <pre><code>logit = sm.Logit(y,X)
  
  result = logit.fit_regularized(trim_mode='auto', alpha=0,maxiter=150)
  
  print(result.summary())
  </code></pre>
  
  <p>Update:</p>
  
  <p>after removing highly correlated features I get:</p>
  
  <pre><code>  len(df.columns) =  np.linalg.matrix_rank(df.values)
  </code></pre>
  
  <p>but still the same error. (even if I set a low correlation threshold).</p>
  
  <p>I tried to change the solver as well.</p>