考虑这样的csv
文件:
number,weigth,length,depth,diameter
1,100,202,314,455
2,1040,2062,3314,4585
3,1200,2502,3134,4557
4,1500,2052,3143,4655
...
和这样的代码
let csvFile = Bundle.main.url(forResource: "myData", withExtension: "csv")!
let dataTable = try! MLDataTable(contentsOf: csvFile)
// 打印(数据表)
let regressorColumns = ["weigth", "length", "depth", "diameter"]
let regressorTable = dataTable[regressorColumns]
let (regressorEvaluationTable, regressorTrainingTable) = regressorTable.randomSplit(by: 0.20, seed: 5)
let regressor = try! MLLinearRegressor(trainingData: regressorTrainingTable,
targetColumn: "weigth")
let prediction = try! regressor.predictions(from: dataTable)
print (prediction)
prediction
csv
是一个与文件本身元素数量相同的浮点数组。
四个问题:
- 为什么它是一个数组?
- 为什么漂浮?
- 为什么数组具有与输入相同数量的元素
csv
? - 这个数组到底代表什么?