【问题标题】:Giving less weight to data coming from another dataset that is noisy对来自另一个嘈杂数据集的数据给予较少的权重
【发布时间】:2022-11-05 04:58:51
【问题描述】:
我有两个数据集,一个是干净数据,一个是脏数据。我在干净的数据集上训练一个 Roberta 模型,然后对脏数据集进行预测。那些概率大于 0.9 的预测进入干净的数据集。然后,我使用这个新数据集重新训练 Roberta 模型(干净 + 脏移动到干净)。
对于再训练,我使用 MAE 损失函数(对嘈杂的标签更稳健),并且我使用权重为从脏数据集传递到干净数据集的数据赋予较少的价值,如下所示:
loss = torch.mean(torch.abs(y_true - y_pred) * weights)
最初,我对传递到干净数据集中的所有脏数据使用 0.5 的任意权重。但是,我想以更学术的方式给他们分配权重,而不是那么武断。
我怎样才能做到这一点?
【问题讨论】:
标签:
tensorflow
keras
deep-learning
nlp
pytorch
【解决方案2】:
出于好奇,为什么不直接使用 cleanlab 为您查找数据集中的标签错误和其他数据问题? https://github.com/cleanlab/cleanlab
它在几行代码中处理了 ML 的大多数数据问题,一些示例:
在 1 行代码中查找标签问题
from cleanlab.classification import CleanLearning
from cleanlab.filter import find_label_issues
# Option 1 - works with sklearn-compatible models - just input the data and labels ツ
label_issues_info = CleanLearning(clf=sklearn_compatible_model).find_label_issues(data, labels)
# Option 2 - works with ANY ML model - just input the model's predicted probabilities
ordered_label_issues = find_label_issues(
labels=labels,
pred_probs=pred_probs, # out-of-sample predicted probabilities from any model
return_indices_ranked_by='self_confidence',
)
像数据集没有错误一样训练模型——3行代码
from sklearn.linear_model import LogisticRegression
from cleanlab.classification import CleanLearning
cl = CleanLearning(clf=LogisticRegression()) # any sklearn-compatible classifier
cl.fit(train_data, labels)
# Estimate the predictions you would have gotten if you trained without mislabeled data.
predictions = cl.predict(test_data)