Я создаю модель с помощью 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, в качестве текстового классификатора я получаю только вывод метки: Author. Есть ли способ создать ML, чтобы иметь вероятность в текстовой классификации?
Спасибо