我正在尝试从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)
请帮忙!
谢谢
最佳答案
将csv文件移动到“文档”而不是“桌面”可以正常工作。
关于ios - Swift无法从CSV读取,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59071960/