Skip to content

Instantly share code, notes, and snippets.

@tbass134
Created July 11, 2018 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbass134/599031e6525473e2f02fd66a174fb3ec to your computer and use it in GitHub Desktop.
Save tbass134/599031e6525473e2f02fd66a174fb3ec to your computer and use it in GitHub Desktop.
Predict
let input = coffee_predictionInput(input: mlMultiArray)
guard let prediction = try? model.prediction(input: input) else {
return
}
let result = prediction
print("classLabel \(result.classLabel)")
if result.classLabel == 1 {
self.class_image.image = UIImage.init(named: "coffee_hot")
self.predict_label.text = "Hot Coffee"
} else {
self.class_image.image = UIImage.init(named: "coffee_iced")
self.predict_label.text = "Iced Coffee"
}
let percent = Int(round(result.classProbability[result.classLabel]! * 100))
self.predict_label.text = self.predict_label.text! + "\n(\(percent)% probability)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment