I am working on a multiclass classificiation problem for text , where I have a lot of different classes (15+). I have trained a Linearsvc svm method(method is just and example). But it outputs just single class with highest probability, Is there a way that algorithm outputs two classes at the same time
sample code i am using:
from sklearn.svm import LinearSVC
import matplotlib.pyplot as plt
from sklearn.feature_extraction.text import TfidfVectorizer,CountVectorizer
count_vect = CountVectorizer(max_df=.9,min_df=.002,
encoding='latin-1',
ngram_range=(1, 3))
X_train_counts = count_vect.fit_transform(df_upsampled['text'])
tfidf_transformer = TfidfTransformer(sublinear_tf=True,norm='l2')
X_train_tfidf = tfidf_transformer.fit_transform(X_train_counts)
clf = LinearSVC().fit(X_train_tfidf, df_upsampled['reason'])
y_pred = model.predict(X_test)
current output :
source user time text reason
0 hi neha 0 0:neha:hi 1
1 there ram 1 1:ram:there 1
2 ball neha 2 2:neha:ball 3
3 item neha 3 3:neha:item 6
4 go there ram 4 4:ram:go there 7
5 kk ram 5 5:ram:kk 1
6 hshs neha 6 6:neha:hshs 2
7 ggsgs neha 7 7:neha:ggsgs 15
desired output:
source user time text reason reason2
0 hi neha 0 0:neha:hi 1 2
1 there ram 1 1:ram:there 1 6
2 ball neha 2 2:neha:ball 3 7
3 item neha 3 3:neha:item 6 4
4 go there ram 4 4:ram:go there 7 9
5 kk ram 5 5:ram:kk 1 2
6 hshs neha 6 6:neha:hshs 2 3
7 ggsgs neha 7 7:neha:ggsgs 15 1
Its is okay if i get output in just one column as i can split and make two columns from it.