Machine Learning with Swift
上QQ阅读APP看书,第一时间看更新

Implementing first machine learning app in Swift

You can transfer your model from Python to Swift in two ways: transfer a trained model, or train a model from the ground up in Swift. The first option is easy in the case of decision trees, as a trained model can be expressed as a set of if-else conditions, which is trivial to code manually. Training the model from the ground up is required only in the situation where you want your app to learn in runtime. We will stick to the first approach in this example, but instead of coding rules manually, we will export the scikit-learn model for iOS using Core ML tools.