error: cannot find 'MLDataTable' in scope

I have tried multiple playgrounds and consistently get the same error in any playground I create. There is a tabular data playground that does work but I see nothing I am not doing.

Here is the code that fails with Error: cannot find 'MLDataTable' in scope

/* code start */ import CoreML import Foundation import TabularData

let jsonFile = Bundle.main.url(forResource: "sentiment_analysis", withExtension: "json")! let tempTable = try DataTable let dataTable = try MLDataTable(contentsOf: jsonFile) print(dataTable) /* code end */

  • I noticed a partial line left by accident from debugging. Remove that line and all comments and the failure still occurs where MLDataTable is used.

Add a Comment

Replies

I notice I left a partial line in there, but it does not work when that is removed. Here is the actual code that is failing

import CoreML import Foundation import TabularData

//let dataset = try MLDataTable(contentsOf: URL(fileURLWithPath: "/Users/vardhanagrawal/Downloads/sentiment_analysis.json")) //let (trainingData, testingData) = dataset.randomSplit(by: 0.8, seed: 5)

let jsonFile = Bundle.main.url(forResource: "sentiment_analysis", withExtension: "json")! let dataTable = try MLDataTable(contentsOf: jsonFile) /*: Pass your data table to print() to see a pretty-printed sample of its contents in the console. */ print(dataTable)

Here is the actual code that is failing

Can you post your code in a code block? That’ll make it easier to read.

Note For this and other tips, see Quinn’s Top Ten DevForums Tips.

I have tried multiple playgrounds

What sort of playground? A playground in Xcode? Or the Swift Playgrounds app?

If it’s the former, what version of Xcode? And what version of macOS are you running it on? And which playground template did you start with?

If it’s the latter, what version of the app? And on what version of iOS?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"