# A Machine Learning Approach to Predict Fluid Viscosity Based on Droplet Dynamics Features
## 3 Results and Discussion
### Viscosity Prediction from Liquid Neck Data  
Droplet dynamics was investigated in Section 1. The reduction process of the neck thickness \(h_{min}\)/\(R\) is mainly affected by viscosity, inertia, and surface tension, and the contraction regime during neck contraction changes when the viscosity of glycerol aqueous solution varies. In this section, random forest, neural network, and multiple linear regression are used to predict the viscosity based on the contraction curve data of the neck thickness \(h_{min}\)/\(R\) for the variation in the neck contraction curve with viscosity. Eleven different percentages of aqueous glycerol solutions were used in the experiments, and due to errors, 18 sets of data for the viscosity-droplet neck contraction curves were finally obtained, and the data can be seen in Figure 5. Each shrinkage curve has about 400 data points, totaling 18 \(\times\) 400 total data. The raw dataset was obtained by measuring the variation of liquid neck thickness frame by frame using a self-programmed program  
Figure 4: Scaling law of liquid neck contraction. (**a**) Thickness of liquid neck \(h_{min}\) with time _tau_ change. (**b**) Regime V (viscous contraction regime) \(h_{min}\)/\(R\) = \((0.0709/Oh)\tau\)[9] comparison of theoretical viscous contraction curves (solid line) with experimental data (data points), the dashed line indicates the critical threshold at the beginning of the vicious contraction in the theoretical regime V \(h_{min}\)/\(R\) values. Each viscosity corresponds to a theoretical critical change value from regime I to regime V, and the dashed line is coloured the same as the corresponding viscosity. The theoretical critical value \((h_{min}\)/\(R)\) of \(Oh\) = 3.12 is much larger than 1, indicating that the droplet is initially in the viscous contraction region at the very beginning of the drop, with viscosity playing a major role. (**c**) The extent to which the viscous–inertial regime plays a major role in the contraction process. (**d**) The regime division of the whole process of contraction of the liquid neck. We used \(R^{2}\), MAE, RMSE, and plots of true versus predicted values to assess the accuracies of the models [36]. The values for the three models can be seen in Table 5. The coefficient of determination (\(R^{2}\)) is an important parameter in assessing the performance of a regression model. Its definition is shown in Equation (4). \[R^{2}=1-\frac{\left(\text{Actual}_{i}-\text{ Predicted}_{i}\right)^{2}}{\left( \text{Actual}_{i}-\text{mean of the observer data}^{2}\right)} \tag{4}\]  
It determines how close the predicted data values are to the regression line. If the \(R^{2}\) value tends to 1, it means that the regression model is perfect, and if \(R^{2}\) is 0, it means that the regression model is a complete failure, i.e., no variance is explained by the regression. The multiple linear regression model has the best coefficient of determination with \(R^{2}\) = 0.98, followed by the neural network with \(R^{2}\) = 0.97, and the random forest performs relatively well with \(R^{2}\) = 0.95. For the regression model, MAE is used to measure the average absolute difference between predicted and actual values. Equation (5) is used to calculate the MAE value, where \(Actual_{i}\) is the actual value, \(Predicted_{i}\) is the predicted value, and N is the total number of instances. The average error of the regression model is measured by RMSE. Equation (5) is used to calculate the RMSE. The magnitudes of both the MAE and RMSE values depend on the size of the predicted outcome and are used for comparison between multiple models of a dataset. \[MAE=\frac{\sum_{i=1}^{N}\mid\text{Actual}_{i}-\text{Predicted}_{i}\mid}{N} \tag{5}\]  
\[RMSE=\sqrt{\frac{\sum_{i=1}^{N}\left(\text{Actual}_{i}-\text{Predicted}_{i} \right)^{2}}{N}} \tag{6}\]  
The \(R^{2}\), \(MAE\), and \(RMSE\) results for random forest, multiple linear regression, and neural networks are recorded in Table 5 for comparison.