5
$\begingroup$

If I have to use scikit-learn (sklearn) library for classification and the feature matrix is a sparse matrix, then which of the classification algorithms of this library can be used by me?

$\endgroup$

2 Answers 2

5
+50
$\begingroup$

From this kaggle discussion, the classification algorithms from scikit-learn that support sparse matrices are at least:

  • linear_model.LogisticRegression()
  • svm.SVR()
  • svm.NuSVR()
  • naive_bayes.MultinomialNB()
  • naive_bayes.BernoulliNB()
  • linear_model.PassiveAggressiveClassifier()
  • linear_model.Perceptron()
  • linear_model.Ridge()
  • linear_model.Lasso()
  • linear_model.ElasticNet()
  • linear_model.SGDClassifier()

Also, from this quora question, you can check in the implementation of the algorithm if they import scipy.sparse.csr_matrix .

$\endgroup$
4
$\begingroup$

In addition to @ncasas 's links, Here is the full list of classification/regression/feature selection and few more by David Ziganto's blog. Which I referred last week-

https://dziganto.github.io/Sparse-Matrices-For-Efficient-Machine-Learning/

Also, from sk-learn documentation, they have example code for text classification which is using few of models.

https://scikit-learn.org/0.15/auto_examples/document_classification_20newsgroups.html

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.