我正在尝试从csv文件读取以进行ML表格分类,并得到以下错误:
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"
这是我在操场上使用的代码:
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)
请帮助! 谢谢
答案 0 :(得分:0)
将csv文件移动到Documents而不是Desktop上。