0

I am trying to read from a csv file to do ML tabular classification and get the following error:

Playground execution terminated: An error was thrown and was not caught:
▿ MLCreateError
  ▿ generic : 1 element
    - reason : "Cannot open /Users/.../Desktop/HouseData.csv for read. Cannot open /Users/.../Desktop/HouseData.csv for reading"

Here is the code in the playground I use:

import CreateML
import Foundation

let houseData = try MLDataTable(contentsOf: URL(fileURLWithPath: "/Users/.../Desktop/HouseData.csv"))
let (trainingCSVData, testCSVData) = houseData.randomSplit(by: 0.8, seed: 0)
let pricer = try MLRegressor(trainingData: houseData, targetColumn: "MEDV")
let csvMetadata = MLModelMetadata(author: "aaa bbb", shortDescription: "A model used to determine the price of a house based on some features.", version: "1.0")
try pricer.write(to: URL(fileURLWithPath: "/Users/.../Desktop/HousePricer.mlmodel"), metadata: csvMetadata)

Please help! Thank you

User123335511231
  • 11,654
  • 4
  • 18
  • 22

1 Answers1

0

Moving the csv file to Documents instead of Desktop worked.

User123335511231
  • 11,654
  • 4
  • 18
  • 22