0
$\begingroup$

I was using SVM for text classification

pipe_lr1 = Pipeline(steps=[('cv',TfidfVectorizer()),
                      ('lr_multi',MultiOutputClassifier(LinearSVC()))])

Will SVM takes data like sparse matrices like this?

(0, 320)    1.0
(1, 106)    0.7418635863640789
(1, 320)    0.6705508326943057
(2, 547)    0.5655985284555338
(2, 1062)   0.556131277628881
(2, 320)    0.6089468832762044

or when I convert these into vectors using todense()

[[0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]
 ...
 [0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]]

Which one of those will considered as inputs to svm In vector form or sparse form?

$\endgroup$
4
  • $\begingroup$ It is hard to see whole picture with one code line. Would you share you code included your text data/dataset loading portion? $\endgroup$
    – Cloud Cho
    Nov 14, 2022 at 19:58
  • $\begingroup$ I cannot upload data, this is all the code I have, after this I will use pipe_lr1.fit(x_train1,y_train1) my question was what does SVM consider as Input data? $\endgroup$
    – User123456
    Nov 14, 2022 at 20:06
  • $\begingroup$ I am sorry for confusion. I didn't ask upload actual data. I want to see what kind text you want to analyze. Do you have any similar example of your data? $\endgroup$
    – Cloud Cho
    Nov 14, 2022 at 21:49
  • 1
    $\begingroup$ the data looks similar to this post datascience.stackexchange.com/questions/113586/… $\endgroup$
    – User123456
    Nov 14, 2022 at 21:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy