私は以下のコードを使用して分類しました。私は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)
データセット enter image description here
回答が妥当な場合、plsはデータセットのスナップショットを投稿しません。あなたのためにテキストを再現してほしいですか?ここでいくつかの方向を見てみましょう:[良い質問]( – skrubber
)開始するには、tf-idf以外の方法でテキストからフィーチャを抽出することができます。 –
私はgridsearchcvで試していましたが、フィットするのに時間がかかります。どの特徴抽出方法を使うべきですか?@VivekKumar –