【发布时间】:2020-09-29 14:22:39
【问题描述】:
我正在构建一个电子邮件分类模型。目前,我在数据预处理过程中使用 NLTK 的停用词和词形还原。以下是我正在使用的 TF-IDF 矢量化器的参数:
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 行。
【问题讨论】:
标签: performance nlp logistic-regression text-classification tf-idf