Integrating Models
ML models only become useful when you integrate them seamlessly into your Java applications. This chapter covers the following objectives:
- PDF / 1,713,716 Bytes
- 86 Pages / 504 x 720 pts Page_size
- 15 Downloads / 231 Views
Integrating Models ML models only become useful when you integrate them seamlessly into your Java applications. This chapter covers the following objectives: •
Manage ML models.
•
Perform sensitivity analysis to make the best tradeoff between model accuracy and model size.
•
Review the key aspects of the Weka Java API. The API allows you to open pretrained models and make predictions within Java.
•
Use an Eclipse project to create a Weka API library you can use for both Java and Android applications.
•
Present an overview of integration techniques for pretrained ML models with Android and the Raspberry Pi.
•
Review Java code to handle sensor data on popular device platforms.
•
Implement the Old Faithful ML app for Raspberry Pi.
•
Implement the Activity Tracker ML Classification app for Android.
6.1 Introduction It is amazing how many apps are available on the app stores today. In fact, there are so many, it has become difficult to cut through the noise and establish a presence. A small percentage of apps on the app stores today use ML, but this is changing. Machine learning is the future of app development. Just as we have learned to design network performance into our apps, we must now learn to design ML performance into the app, including considerations for model size, model accuracy, and prediction latency. © Mark Wickham 2018 M. Wickham, Practical Java Machine Learning, https://doi.org/10.1007/978-1-4842-3951-3_6
297
Chapter 6
Integrating Models
In this final chapter, you will learn about model integration and deployment. Figure 6-1 shows the ML-Gates 1 and 0 steps for this critical phase.
Figure 6-1. ML-Gate 1/0, Model Integration/Deployment These final two ML-Gates represent the “business end” of the ML development pipeline. They represent the final steps in the pipeline where you realize the benefit of all the hard work performed in the earlier phases when you were working with data, algorithms, and models. Model integration and deployment are the most visible stages, the stages that enable you to monetize your applications.
6.2 Managing Models In ML application development, the model is one of your key assets. You must carefully consider how to handle the model, including
298
•
Model sizing considerations
•
Model version control
•
Updating models
Chapter 6
Integrating Models
Models can grow to be very large, and you need to start by making sure the models you create can physically reside on your target device.
Device Constraints When you use ML models from the cloud providers, you simply rely on network connectivity and a cloud provider API to access models and make predictions. Storing prebuilt models on devices is a different approach, requiring you to understand the limitations of the target device. Table 6-1 shows the typical hardware storage specifications for two Java devices, Android and Raspberry Pi.
Table 6-1. Device Processing/Storage Summary Specification
Android
Raspberry Pi
Device Category
Mid-tier device, such as Moto X4 (2018)
Pi 3B+
Data Loading...