Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: A sparse matrix was passed, but dense data is required. Use X.toarray() to convert to a dense numpy array. #1

Open
maxim5522 opened this issue Apr 19, 2018 · 1 comment

Comments

@maxim5522
Copy link

Hey Sathvik,
Thank you for this code! I was trying to follow it and apply it to some data I have, but I stumbled upon one error I receive. When running the line basicmodel2 = basicmodel2.fit(basictrain2, train["Label"]) I receive the error:

TypeError: A sparse matrix was passed, but dense data is required. Use X.toarray() to convert to a dense numpy array.

I'm using Python 3. Could you please help me to overcome this? Thank you!

@sheddyranking
Copy link

Use .todense() to convert to a dense numpy array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants