ios - Swift 无法读取 csv

标签 ios swift machine-learning createml

我尝试读取 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"

这是我在 Playground 上使用的代码:

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/

相关文章:

ios - 没有Retain Cycle,但是为什么还是有retain cycle warning?

javascript - 当嵌入推文时,iOS WKWebView 不正确地计算高度

ios - Swift 3 中的递归字典

Swift 4 在完成处理程序中访问 textView

带保留评估的 RMOA Hoeffding 树

ios - UICollectionView 捕捉到 0,0 - 滚动超过边界

swift 3 (SpriteKit) : Changing the alpha value of the parent which affects all children

python - 带有掩蔽和直觉的 LSTM 回归问题 (keras)

python - 预期为二维数组,但在尝试反转缩放数据时却得到一维数组

iphone - 如何对单击的 ImageView 执行一些操作?