我目前正在尝试运行一个程序,该程序使用 Swift 的 Core 和 Create ML 框架进行机器学习。我的模型已经设置好,但是我很难设置一个计算我想要的输出的函数。如果有帮助,我正在使用一个教程,链接在这里。大约 4 点 50 分,他开始编写给出错误的代码段“预测”。我已经尝试过查看类似的案例,但我仍然不确定我做错了什么,而且我几乎是 Swift 和 Swift ML 的完整初学者,一个简单的解决方案将不胜感激!我已附加代码段以准确显示给我错误的原因,希望对您有所帮助!
func calculateSpoilageDay() {
do {
let model: BananaSpoilageCalc = try BananaSpoilageCalc(configuration: .init())
let prediction = try model.prediction(percentbrown: Int(percentbrown), liquidleaking: Int(liquidleaking), nummoldspot: Int(nummoldspots)) //error No exact matches in call to instance method 'prediction' here
} catch {
alertTitle = "Error"
alertMessage = "Sorry, there was a problem calculating the number of days until your bananas spoiled."
}
showingAlert = true
}
代码开头(实例数据):
import SwiftUI
import CoreML
...
@State private var percentbrown = Int()
@State private var liquidleaking = Int()
@State private var nummoldspots = Int()
@State private var alertTitle = ""
@State private var alertMessage = ""
@State private var showingAlert = false