Mah*_*esh 1 c# machine-learning multilabel-classification ml.net
我希望使用 ML.NET 实现多标签分类。我读过几篇文章,说这不可能直接实现,而是通过问题转换将其转换为多个二元分类问题。n因此,如果我的数据集有标签,基本上我将需要创建分类器n。我尝试通过明智地拆分数据集标签来做到这一点。但fit方法抛出以下异常。我正在传递标签列的值作为1给定标签的所有条目。
System.ArgumentOutOfRangeException:“必须至少为 2。参数名称:numClasses”
1这可以通过添加具有特定标签 as 的条目和所有其他条目 as来解决0,但由于每个标签的条目数量较少,我认为这会稀释学习并可能导致准确性降低。
有人可以建议使用 ML.NET 实现多标签分类的任何其他方法吗?
小智 5
创建 N 个布尔列。命名模式示例:Label01、Label02、...LabelNN。
训练管道,添加N组:(每个布尔标签一组)
.Append(mlContext.BinaryClassification.Trainers.LightGbm(labelColumnName: "Label01", featureColumnName: "Features"))
.Append(mlContext.Transforms.CopyColumns("Score01", "Score")) // Copy to a unique name so the following models won't shadow (replace) the column. PredictedLabel column can also be saved.
.Append(mlContext.BinaryClassification.Trainers.LightGbm(labelColumnName: "Label02", featureColumnName: "Features"))
.Append(mlContext.Transforms.CopyColumns("Score02", "Score"))
...
.Append(mlContext.BinaryClassification.Trainers.LightGbm(labelColumnName: "LabelNN", featureColumnName: "Features"))
.Append(mlContext.Transforms.CopyColumns("ScoreNN", "Score"))
Run Code Online (Sandbox Code Playgroud)
然后就可以正常打电话了.fit()。管道中的所有模型都将适合。然后,您可以访问每个 ScoreXX 列来获取每个班级的分数。
要评估每个模型的质量,您可以从每个分数列及其输入 LabelXX 列创建指标。
| 归档时间: |
|
| 查看次数: |
1359 次 |
| 最近记录: |