consider a csv
file like this:
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
...
and a code like this
let csvFile = Bundle.main.url(forResource: "myData", withExtension: "csv")!
let dataTable = try! MLDataTable(contentsOf: csvFile)
// print(dataTable)
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
is an array of floats with the same number of elements of the csv
file itself.
Four questions:
- why is it an array?
- why floats?
- why the array has the same number of elements as the input
csv
? - what exactly this array represents?