0

MLTextClassifierテキストに慣れているクラスの問題に直面しCreateMLています。

以下はコード スニペットです。

import CreateML
import Foundation

let objURL = URL(fileURLWithPath: "/Users/jayprakashdubey/Desktop/headlines.json")

// 1. Load data from a JSON file
guard let newsJsonFileContent = try? MLDataTable(contentsOf: objURL) else {
    exit(0)
}

// 2. Make a train-test split
let (training, testing) = newsJsonFileContent.randomSplit(by: 0.8, seed: 5)

print("training: \(training.description)")

// 3. Create the model
if let objNewsClassifier = try? MLTextClassifier(trainingData: training, textColumn: "title", labelColumn: "category") {

   . . . 
}  else {
    print("Failed while classifying News - MLTextClassifier")
}

上記のコード スニペットで条件が常に失敗する場合。

以下は のコンソール ログですplayground

コンソール ログのスクリーンショット

Stackoverflow に投稿されたすべてのソリューションを試してみましたが、どれも機能しませんでした。

注: Xcode v11.3.1 を使用しています。

以下は JSON ファイル構造です。

[
  {
    "text":"New 13-inch MacBook Pro comes with 6K monitor support, Dolby Atmos playback",
    "category":"Technology"
  },
     . . .
  {
    "text":"Apple Watch ECG detects signs of coronary ischemia missed by hospital ECG",
    "category":"Technology"
  }
]

修正はありますか?

4

1 に答える 1