我正在建立一个电子邮件分类模型。目前,我正在使用NLTK的停止词和柠檬化在数据的预处理.以下是我正在使用的TF-下手向量器的参数:
from sklearn.feature_extraction.text import TfidfVectorizer
tfidf = TfidfVectorizer(sublinear_tf= True,
min_df = 5,
norm= 'l2',
ngram_range= (1,2),
stop_words ='english')我正在使用LogisticRegression进行分类。
from sklearn.linear_model import LogisticRegression # Logistic Regression - (Best Performance Till Now)
X_train, X_test, y_train, y_test = train_test_split(df['Rejoined_Lemmatize'], df['Product'], random_state = 0, test_size = 0.2)
X_train_counts = tfidf.fit_transform(X_train)
clf = LogisticRegression(random_state=0).fit(X_train_counts, y_train)
y_pred = clf.predict(tfidf.transform(X_test)) # Predicting using our Model
print(metrics.classification_report(y_test,y_pred, labels= df.Product, target_names=df['Product'].unique())) # Print Results我从上面的代码中得到了以下结果:
precision recall f1-score support
Bank account or service 0.45 0.52 0.48 46
Checking or savings account 0.60 0.52 0.56 56
Money transfers 0.60 0.52 0.56 56
Student loan 0.60 0.52 0.56 56
Consumer Loan 0.86 0.86 0.86 64
Payday loan 0.91 0.96 0.94 55
Debt collection 0.88 0.71 0.79 62
Mortgage 0.88 0.71 0.79 62
Credit reporting 0.86 0.86 0.86 64
Prepaid card 0.81 0.80 0.81 65
Credit card 0.60 0.52 0.56 56
accuracy 0.79 198000
macro avg 0.79 0.79 0.78 198000
weighted avg 0.80 0.79 0.79 198000我怎样才能提高这种准确性?
注-我正在编写“消费者投诉数据集”。我只使用来自该数据库的3300行,并且平衡了我的数据库,即每个类别的300封电子邮件。
11类* 300封电子邮件= 3300行。
发布于 2020-06-11 22:56:03
如果提供样本数据,可以改进对这个问题的答复。然而,在给定的信息下,以下几点将有助于更好地探索问题。
。
https://stackoverflow.com/questions/62299010
复制相似问题