Which Algorithm Do I Use For My New Application !?

Muhammad Ali Hafeez
deMISTify
Published in
5 min readJan 19, 2024

Introduction

Making apps gained popularity when people realized that they could provide additional utility on the go and generate substantial revenue for the developers. As a result, app development has become a hot topic since the advent of smartphones. The aim of this paper is to explore a popular question: what are the potential pros and cons of introducing machine learning capabilities in mobile applications? This article is a synopsis of the paper ‘What can Android mobile app developers do about the energy consumption of machine learning?”.

Important Note

The authors in this paper choose to use Android devices. The rationale is unmentioned, however, this may still provide a significant amount of valuable insight since according to Statista, Android has a global market share of 70.5% while iOS has a market share of 28.8%.

The Main Question

People may wonder why it may not be possible to ensure that all machine learning training and evaluation are done non-locally. The benefit of this approach would be that the device itself would not consume as much energy, increasing ease of scalability and performance. However, there are disadvantages. The potential disadvantages are the high amounts of bandwidth, latency, and network traffic that would be incurred when using web services. The article states that the popularity of machine learning rose with the investments that took place in cloud computing like Amazon. This allowed mobile applications to perform the training and evaluation on the cloud. This brings us to the main topic of this article: which algorithms should I choose to use for my application using energy consumption as a key consideration?

Is Caring about Energy Consumption Worth it

According to the article, Sahin et al. conducted research that found that optimizations that take energy consumption into account are important for “benchmarking”, but do not have much value in real-world applications because they are not used enough to make a real impact. This raises the question of whether the field is worth exploring for real-world applications. However, the paper goes on to state that most developers are not very experienced in dealing with energy consumption issues. The main reason for researching energy consumption is to help developers who are unsure how to tackle the problem.

Machine Learning Algorithms and Implements Used in the Paper

The algorithms used were chosen because they are popular machine learners that implement a variety of classification strategies. Naive Bayes (NB) is a probabilistic model that uses Bayes’ Theorem. J48 (Weka’s implementation of C4.5) builds decision trees using recursive splits with information gain as a priority. Sequential Minimal Optimization (SMO) selects two examples and optimizes the SVM objective function. Logistic Regression (LogReg) models relationships between binary dependent variables and one or more independent variables. Random Forest (RF) constructs multiple decision trees and outputs the best one (best depending on the preference method). k-Nearest Neighbor (IBk) classifies based on the majority class of its k-nearest neighbors in a feature map. ZeroR is a simple baseline algorithm that predicts the most common class in training data for all instances. MultiLayer Perceptron (MLP) is a multi-layer feedforward neural net that uses backpropagation. For more details visit - https://www.geeksforgeeks.org/machine-learning-algorithms/

Datasets

Methods use to Quantify Energy Consumptions- GreenMiner’s Configuration

GreenMiner’s Framework uses hardware-instrumented Android smartphones to physically measure energy consumption and power use of apps running on the phones. The measurements are collected using an INA219 current sensor that measures both voltage and current. The sensor uses a shunt to measure the current via a mild voltage drop across the shunt. Before each test is run, the application APK is installed on the phone, required data is uploaded onto the SD card, and phone settings such as screen brightness and screen timeout are set as required. After each test, the application is uninstalled, the data is deleted from the SD card, settings are restored to previous values and data generated during the tests such as log files are pulled from the phones to be uploaded to the web service and then deleted from the phone, so that the next test can begin with a clean environment.

Energy Usage based on Algorithms Results

Regarding why energy consumption was higher or lower in specific places, the article states that energy use was positively correlated with runtime complexity, user and idle CPU time, number of methods called, and garbage collection frequency.

Conclusions

J48, Logistic Regression, and MLP are recommended for pre-trained models with low classification costs and errors, with SMO serving as a viable alternative. In the context of mobile applications requiring frequent updates, Naive Bayes emerges as the most energy-efficient option, while IBk offers easy updates at the expense of higher classification costs. Prioritizing energy efficiency, Naive Bayes and J48 stand out, particularly when dealing with datasets featuring numerous attributes. For maximum accuracy, Random Forest and SMO excel, though Random Forest tends to consume more energy than SMO, and caution is warranted with MLP due to potential overfitting, necessitating parameter tuning.

Sources

McIntosh, A., Hassan, S., & Hindle, A. (2018). What can Android mobile app developers do about the energy consumption of machine learning? Empirical Software Engineering, 24(2), 562–601. https://doi.org/10.1007/s10664-018-9629-2

--

--