我必须对下面的代码进行分类。我的准确率在55%到60%之间。
我想把我的准确率提高到85%-90%。我分为8个不同的类别。我应该采取什么措施来提高准确性。在import pandas as pd
import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.linear_model import SGDClassifier
from sklearn.pipeline import Pipeline
from nltk import word_tokenize
from textblob import TextBlob
cov = pd.read_csv("F:/kipro/ml/dataset.csv",
names = ["Complaint", "target"])
cov.dropna()
s=pd.factorize(cov['target'])
cov['tarname']=s[0]
msk = np.random.rand(len(cov)) < 0.8
train = cov[msk]
test = cov[~msk]
train.dropna()
test.dropna()
y_train, y_test = train.tarname, test.tarname
def tokens(message):
return TextBlob(message).words
def lemmas(message):
message=message.lower()
words = TextBlob(message).words
return [word.lemma for word in words]
text_clf = Pipeline([('vect', CountVectorizer(analyzer=lemmas)),
('tfidf', TfidfTransformer()),
('clf-svm', SGDClassifier())
,])
text_clf = text_clf.fit(train['Complaint'].values.astype('U'),train['tarname'])
predicted = text_clf.predict(test['Complaint'].values.astype('U'))
x=np.mean(( y_test==predicted))*100
print(x)