【问题标题】:Swift can't read from csvSwift 无法读取 csv
【发布时间】: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)

请帮忙! 谢谢

【问题讨论】:

标签: ios swift machine-learning createml


【解决方案1】:

将 csv 文件移动到 Documents 而不是桌面工作。

【讨论】:

    猜你喜欢
    • 2018-11-17
    • 1970-01-01
    • 1970-01-01
    • 2015-02-15
    • 2019-11-13
    • 2021-10-11
    • 1970-01-01
    • 1970-01-01
    • 2017-11-24
    相关资源
    最近更新 更多