# Artificial Neural Network Framework for Hybrid Control and Monitoring in Turning Operations
## 4 Discussion  
### Inference Models and Results  
The inference model is the trained neural network that takes input machining parameters, such as force F [daN] and spindle speed \(n\) [rpm] and predicts output values like current I [A] and power P [kW] (forward model) or estimates the required force based on a given current, power, and spindle speed (inverse model). It may enable real-time predictions using the learned relationships from training data, allowing for adaptive control and monitoring in machining operations. The inference codes for both models, forward and inverse, were designed to load a trained feedforward neural network model for forward/inverse prediction in a machining process. The codes developed perform the following key tasks:  
* Model selection--This automatically selects the best-trained model based on validation loss. It scans the \"models\" directory for the best-trained model, identifies files following the given forward/inverse pattern, and selects the model with the lowest validation. * Data preprocessing--This loads input data from JSON input file and applies feature scaling. * Inference execution--This uses the trained model to generate predictions. * Error monitoring and trend analysis--This maintains an inference log to detect model drift by saving all runs with parameters. * Performance evaluation--This computes the MAE, weighted MSE, and R\({}^{2}\) scores. It continuously evaluates whether model performance degrades over time by comparing recent predictions to expected trends. * Logging and display--This saves the inference log for trend monitoring and displays predictions. The forward model takes F [daN] and spindle speed n [rpm] as inputs and predicts electrical parameters I [A] and P [kW], as shown in Figure 9.  
High R\({}^{2}\) scores (0.9911 for I [A] and 0.9980 for P [kW]) indicate that the coefficient of determination (R\({}^{2}\)) values are very close to one, indicating that the model explains almost all of the variability in the data. This suggests that the model captures the underlying relationships between inputs (force, F, and rotational speed, n) and outputs (current and power) with high fidelity. Figure 8: Inverse model training and validation loss for 3->13->23->1. For inverse model loads, the optimal inverse model reads the input JSON containing measured I [A], P [kW], and n [rpm], and uses the trained model to predict the corresponding cutting force F [daN], as shown in Figure 10.  
The high R\({}^{2}\) score (0.997541 for F [daN] indicates that the coefficient of determination (R\({}^{2}\)) is very close to one, which means that the model explains nearly all of the variability in the target variable \(F\), confirming strong predictive capabilities. The current inference implementation incorporates periodic monitoring of prediction accuracy to detect deviations. Inference scripts continuously track errors over time by calculating mean absolute error (MAE) and the coefficient of determination for ongoing validation. If performance degrades beyond a predefined threshold, such as when MAE exceeds 0.2 or drops below 0.9, the system flags the need for recalibration. The developed inference models have already incorporated a foundational mechanism to support adaptive recalibration through continuous performance monitoring. Specifically, the inference code integrates a routine for calculating critical performance metrics, such as mean absolute error (MAE) and the coefficient of determination (R\({}^{2}\)), during operational use. If performance degrades beyond a predefined threshold, such as when MAE exceeds 0.2 or drops below 0.9, the system flags the need for recalibration. These metrics serve as predefined trigger conditions, enabling the automatic detection of deviations in predictive  
Figure 10: Coefficient of determination for F [daN]. Figure 9: Coefficient of determination for I [A] and P [kW]. performance.