# A Machine Learning Approach to Predict Fluid Viscosity Based on Droplet Dynamics Features
## 2 Materials and Methods
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Property** & \(\rho\)**/(kg/m\({}^{3}\))** & \(\sigma\)**/(mN/m)** & \(\mu\)**/(mPa-s)** & \(l_{\mu}\)**/(\(\mu\)m)** \\ \hline
50\%glycerol–water & 1200 & 70.5 & 6.1 & 0.44 \\
55\% glycerol–water & 1200 & 70.4 & 8.5 & 0.86 \\
60\% glycerol–water & 1205 & 70.1 & 10.5 & 1.31 \\
65\% glycerol–water & 1210 & 70.1 & 15.2 & 2.72 \\
70\% glycerol–water & 1215 & 70.0 & 41.2 & 19.96 \\
75\% glycerol–water & 1220 & 69.9 & 67.1 & 52.79 \\
80\% glycerol–water & 1230 & 69.7 & 97.1 & 109.98 \\
85\% glycerol–water & 1240 & 69.5 & 126.3 & 185.10 \\
90\% glycerol–water & 1250 & 69.3 & 208.5 & 501.84 \\
95\% glycerol–water & 1255 & 69.3 & 394.8 & 1792.16 \\
99\% glycerol–water & 1265 & 69.1 & 824.2 & 7802.19 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Physical properties of glycerol aqueous solution 25 \({}^{\circ}\)C.  
Figure 1: Scheme of the experimental setup. The device was made using an aluminum stand surrounded by a transparent 0.1 mm PMMA sheet, with the needle fixed in the centre of the device and levelled using a spirit level for generating stable droplets. Three machine learning models based on multivariate linear regression, random forest, and neural network were used in this study to model the obtained fluid neck contraction dataset. A homebrew program was written in Python using scikit-learn, a widely used open-source machine learning library for Python, often abbreviated to learn [31]. Scikit-learn provides various preprocessing methods including data scaling, normalisation, categorical variable coding, dealing with missing values, and feature extraction. These methods play an important role before using the data in machine learning models [32]. Multiple linear regression is a statistical technique used to predict the relationship between a dependent variable and one or more independent variables, based on the assumption of a linear relationship between the independent and dependent variables. The algorithm used in this paper is the least squares method, which fits the model parameters by minimising the sum of squared residuals (RSS), which also serves as the loss function of this model. Here, \(y_{i}\) represents the true value of sample i, and \(\hat{y}_{i}\) is the predicted result. The sum of squared residuals is given by Equation (1). \[RSS=\sum_{i=1}^{m}(y_{i}-\hat{y}_{i})^{2} \tag{1}\]  
Random forest is an integrated learning method consisting of multiple decision trees. Each decision tree is constructed based on a randomly selected subset of features and training samples with put-back sampling. This introduction of randomness makes random forest highly diverse and generalisable. In the random forest algorithm, the generalisation error is given and the formula is given by Equation (2) [33], where the subscripts (X) and (Y) are random vectors indicating that the probability is on the space (X), (Y), and (mg) is the bounding function. \[PE=P_{X,Y}(mg(X,Y)<0) \tag{2}\]  
A neural network is a model of a machine learning algorithm that is inspired by the network of neurons in the human brain. A neural network consists of multiple layers of neurons, each of which receives inputs from the previous layer of neurons and processes these inputs with weights and activation functions to finally produce an output. The basic computational formula can be expressed as Equation (3) [34]. \[y=f(x,\{W_{i}\})+x, \tag{3}\]  
where y denotes the output of the neuron; \(f\) is the activation function, which introduces non-linear characteristics; \(W_{i}\) denotes the weight, which indicates the importance of the input; and x is the input vector.