Swift 创建ML文本分类器概率

Swift 创建ML文本分类器概率,swift,text-classification,coreml,createml,Swift,Text Classification,Coreml,Createml,我正在使用createml创建模型。我正在使用一个JSON文件 let data = try MLDataTable(contentsOf: URL(fileURLWithPath: "poems.json")) let (trainingData , testingData) = data.randomSplit(by: 0.8, seed: 0) let classifier = try MLRegressor(trainingData: data, targetColumn: "auth

我正在使用createml创建模型。我正在使用一个JSON文件

let data = try MLDataTable(contentsOf: URL(fileURLWithPath: "poems.json"))
let (trainingData , testingData) = data.randomSplit(by: 0.8, seed: 0)

let classifier = try MLRegressor(trainingData: data, targetColumn: "author", featureColumns: ["text"])
let metadata = MLModelMetadata(author: "ffffff", shortDescription: "sdhkgfjhsgdjfhgs", license: nil, version: "1.0", additional: nil)

try classifier.write(to: URL(fileURLWithPath: "poems.mlmodel"), metadata: metadata)
JSON文件如下所示

{"title":"When You Are Old",
 "author":"William Butler Yeats",
 "text":"When you are old and grey and full of sleep,\nAnd nodding by the   fire, take down this book,\nAnd slowly read, and dream of the soft look\nYour eyes had once, and of their shadows deep;\nHow many loved your moments of glad grace,\nAnd loved your beauty with love false or true,\nBut one man loved the pilgrim Soul in you,\nAnd loved the sorrows of your changing face;\nAnd bending down beside the glowing bars,\nMurmur, a little sadly, how Love fled\nAnd paced upon the mountains overhead\nAnd hid his face amid a crowd of stars."}
在一个教程之后,我试图对“文本”进行文本检测,并返回可能的“作者”

我可以做到,但我也希望得到概率

使用createml创建模型,作为文本分类器,我只得到一个标签:Author。有没有一种方法可以让createml在文本分类中也具有概率


谢谢

当前的MLTextClassifier API似乎无法实现这一点


如果您在Netron中打开mlmodel文件,它将显示模型生成的输出。我的猜测是,它只是给出了类,而不是概率。

我想
MLTextClassifier
API还不支持它。但是,您可以通过在创建模型时使用更通用(且总体精度较低)的MLClassifier从模型中获取概率。

在XCode游乐场中创建的MLModel是一个只返回标签(字符串)的文本分类器。
Apple在Github()上的示例使用turicreate python库创建模型,它是一个管道分类器,它返回一个标签及其概率(String->Double)。

我也遇到同样的问题,你找到解决方案了吗?