我正在使用 Create ML 创建模型。我正在使用 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."}
按照教程,我正在尝试对“文本”进行文本检测并返回可能的“作者”
我可以做到,但我也希望有这个可能性。
使用 Create ML 创建模型,作为文本分类器,我只输出一个标签:作者。Create ML 有没有办法在文本分类中也有概率?
谢谢