Created
July 11, 2018 01:24
-
-
Save tbass134/599031e6525473e2f02fd66a174fb3ec to your computer and use it in GitHub Desktop.
Predict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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