【发布时间】:2020-03-23 02:43:24
【问题描述】:
我正在尝试从 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 文件:developer.apple.com/documentation/createml/…
-
使用游乐场我没有捆绑
-
您可以在 Playground 中使用 Bundle,请参阅链接。
标签: ios swift machine-learning createml