Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Python sm.logit() - getting LinAlgError: Singular matrix when using model.fit() function

$
0
0

@gaurav984 wrote:

Hi Team,

I am trying to build and run a logistic regression model (with a very large dataset). After data cleaning, dummy creation and vif check when tried to run the model i am getting below error:

Build logistic regression model (using statsmodels package/library)

import statsmodels.api as sm
M1 = sm.Logit(Train_Y, Train_X) # (Dep_Var, Indep_Vars) # This is model definition
M1_Model = M1.fit() # This is model building

Error:
File “C:\Users\Gaurav Rai\Anaconda3\lib\site-packages\numpy\linalg\linalg.py”, line 528, in inv
ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)

File “C:\Users\Gaurav Rai\Anaconda3\lib\site-packages\numpy\linalg\linalg.py”, line 89, in _raise_linalgerror_singular
raise LinAlgError(“Singular matrix”)

LinAlgError: Singular matrix

Complete code is attached. Along with below links to datasets:

Initial Dataset: https://drive.google.com/drive/folders/1aclWn4EVlk8LYQxBfNDbDM697GeaddkK?usp=sharing

Code Attachment:
final_project1.zip (3.3 KB)

Kindly help me in resolving this issue.

Thanks & Regards,
Gaurav Rai

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles