\documentclass[12pt]{article}

% --- pacchetti standard ---
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{listings}
\geometry{margin=2.5cm}

% --- pacchetti per autori/affiliazioni ---
\usepackage{authblk}
\usepackage{hyperref}
\usepackage{orcidlink}

% �� Riduce il font delle affiliazioni
\renewcommand\Authfont{\large}     % nome autore leggermente grande
\renewcommand\Affilfont{\small}    % affiliazioni più piccole
\setlength{\affilsep}{0.5em}       % distanza tra autore e affiliazione

% --- titolo e autori ---
\title{\textbf{Supplementary Material}\\[0.4em]
\large Data-Driven Process Maps for Foam Additive Manufacturing:\\
Accuracy and Interpretability Across Six Models}
% Anonymous submission for peer review
\author[]{Anonymous}


\begin{document}
\maketitle



\section{Dataset Description}

\subsection{Parameters and Output Variables}

The dataset used in this study was derived from 528 experimental trials of Foam Additive Manufacturing (FAM), using PLA loaded with CO\textsubscript{2} as physical blowing agent. Each row corresponds to a single manufacturing condition, defined by six independent process parameters and their associated output values.

The input variables are:
\begin{itemize}
    \item Absorption pressure, $P_a$ (\si{\bar})
    \item Absorption time, $t_a$ (\si{\hour})
    \item Desorption time, $t_d$ (\si{\hour})
    \item Extrusion temperature, $T_e$ (\si{\degreeCelsius})
    \item Extrusion speed, $S_e$ (\si{\milli\meter\per\minute})
    \item Nozzle diameter, $D_n$ (\si{\milli\meter})
\end{itemize}

The target output variables considered for model training are:
\begin{itemize}
    \item Strand density (\si{\gram\per\centi\meter\cubed})
\end{itemize}

\begin{figure*}[h]
    \centering
        \includegraphics[width=\textwidth]{Parameter_Distributions.pdf}
        \caption{The figure shows the distribution of the six controllable process parameters across the 528 experimental trials.}
    \label{fig:Distribution}
\end{figure*}

The dataset covers a broad and approximately uniform range for each variable, ensuring that no single parameter dominates the regression training.



For the scope of this work, only the density output was used to train the regression models and generate density maps. The influence on diameter and bubble size is addressed in future works.

\subsection{Data Preprocessing and Cleaning}

The dataset was loaded from a structured Excel file, where numeric entries were cleaned and converted to appropriate types. Missing or non-numeric entries in the density column were dropped:
\begin{verbatim}
df["DENSITA' [g/cm^3]"] = pd.to_numeric(df["DENSITA' [g/cm^3]"], errors='coerce')
df_cleaned = df.dropna(subset=["DENSITA' [g/cm^3]"])
\end{verbatim}

All six process parameters were normalized and standardized when needed (e.g., in PCA and neural networks) using the \texttt{StandardScaler} from \texttt{scikit-learn}. No synthetic data generation or imputation was performed. The cleaned dataset was then split into training (80\%) and testing (20\%) subsets using a fixed random seed for reproducibility:
\begin{verbatim}
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2
\end{verbatim}
\begin{verbatim}
, random_state=42)
\end{verbatim}

All regression models were trained on the same split to allow for direct metric comparison.


\section{Model 1: Polynomial Regression}

\subsection{Feature Expansion and Degree Selection}

Polynomial regression was employed to capture nonlinear interactions among the six process parameters of the FAM dataset. 
Feature expansion was performed using the \texttt{PolynomialFeatures} transformer from \texttt{scikit-learn}, which generates all linear, quadratic, and pairwise interaction terms up to a specified degree.

A second-degree expansion (\texttt{degree=2}) was selected, representing a trade-off between model flexibility and overfitting risk. 
This transformation produced 28 terms in total, including the intercept, six linear terms, fifteen pairwise interactions, and six squared terms:
\[
\text{Features: } \{1, x_1, x_2, \dots, x_6, x_1^2, x_1x_2, \dots, x_6^2\}.
\]
This configuration was considered sufficient to represent the principal nonlinearities observed experimentally without introducing excessive collinearity.

\subsection{Model Fitting and Test Definition}

The model was implemented in \texttt{Python 3.12} using the \texttt{LinearRegression()} class from \texttt{scikit-learn}. 
Training and testing subsets were defined based on the original Excel spreadsheet indexing: rows 73–90 (inclusive) were reserved for testing, while all remaining valid entries formed the training set. 
Because missing values were removed before training, the split was performed using index masks to preserve exact correspondence with spreadsheet row numbers. 
This ensures traceability and consistency across models trained on the same dataset.

After feature expansion, the linear regression model was fitted exclusively on the training data:
\begin{align*}
\rho &= \beta_0 + \sum_i \beta_i x_i + \sum_{i<j}\beta_{ij} x_i x_j + \sum_k \beta_{kk} x_k^2.
\end{align*}
An example excerpt of the fitted coefficients is shown below:
\begin{align*}
\rho &= 0.9861 - 0.0031 P_a - 0.0237 t_a + 0.0016 t_d + 0.0053 T_e - 0.0004 S_e - 1.3560 D_n \\
&\quad - 0.0002 P_a^2 + 0.0001 P_a t_a - 0.0025 P_a D_n + \cdots + 0.5249 D_n^2.
\end{align*}
This explicit closed-form relation enables continuous evaluation of density as a function of the six parameters and serves as the analytical foundation for the process maps presented in this work.


\subsection{Prediction and Evaluation}

The model was evaluated on the testing subset defined by Excel rows 73–90.  
The resulting regression metrics are summarized below:

\begin{itemize}
    \item MAE: 0.1074
    \item RMSE: 0.1481
    \item $R^2$: 0.3494
    \item MAPE: 21.05\%
\end{itemize}

Although the polynomial model exhibits moderate accuracy compared to more complex ensemble and neural models, it remains the only one providing an explicit analytical expression for continuous mapping across the process space. This makes it particularly suitable for interpretation, process visualization, and analytical optimization.


\subsection{Process Map Generation}

\begin{figure*}[h]
    \centering
        \includegraphics[width=\textwidth]{1_Polin_Punti.pdf}
        \caption{Predicted density maps obtained via polynomial regression for different nozzle diameters ($D_\text{n}$). The solubilization parameters are fixed at $P_\text{a}=40$~bar, $t_\text{a}=65$~h, and $t_\text{d}=26$~h.}
    \label{fig:Polynomial}
\end{figure*}

To visualize the predicted density response in the $(T_e, S_e)$ domain, the solubilization parameters were fixed to constant values:
\[
P_a = 40~\text{bar}, \quad t_a = 65~\text{h}, \quad t_d = 26~\text{h}.
\]
Predictions were generated over a mesh grid defined by 
\(T_e \in [130, 270]~^\circ\mathrm{C}\) and 
\(S_e \in [100, 1500]~\mathrm{mm\,min^{-1}}\), 
for three nozzle diameters \(D_n = \{0.4,\, 0.6,\, 0.8\}~\mathrm{mm}\).
Contour maps were plotted using a fixed color normalization range 
(\(v_\text{min}=0.15\), \(v_\text{max}=1.26~\mathrm{g/cm^3}\)) 
and overlaid with experimental data points that matched the same fixed solubilization parameters within a numerical tolerance of $10^{-9}$.


\subsection{Prediction and Evaluation}

The model was evaluated on the testing set using standard regression metrics: Mean Absolute Error (MAE), Mean Squared Error (MSE), Root Mean Squared Error (RMSE), and the coefficient of determination ($R^2$). The results are summarized below:

\begin{itemize}
    \item MAE: 0.1237
    \item MSE: 0.0353
    \item RMSE: 0.1878
    \item $R^2$: 0.6322
\end{itemize}

Although the polynomial model showed lower accuracy compared to ensemble-based methods, it remains the only one that provides an explicit analytical form and a continuous output surface. This makes it a valuable reference for understanding the structure of the parameter space and for applications requiring interpretable expressions.

\section{Model 2: Support Vector Regression (SVR)}

\subsection{Feature Expansion and Kernel Selection}

Support Vector Regression (SVR) was employed to model nonlinear relationships between the six process parameters and the resulting foam density. 
The \texttt{SVR} implementation from \texttt{scikit-learn} was used, combined with standardized preprocessing to ensure balanced feature scaling.

An RBF (Radial Basis Function) kernel was selected due to its flexibility in capturing smooth nonlinear patterns without explicit feature expansion. 
The kernel is defined as:
\[
K(x, x') = \exp(-\gamma \|x - x'\|^2),
\]
where $\gamma$ controls the width of the Gaussian kernel and hence the smoothness of the regression surface.

\subsection{Model Fitting and Test Definition}

The model was trained using an 80/20 random split of the available dataset, with reproducibility ensured by a fixed random seed (\texttt{random\_state=42}). 
Unlike the polynomial model, which used a fixed Excel-row split, this approach allows a more statistically representative partition of the available data. 
Each feature was normalized using the \texttt{StandardScaler} within a \texttt{Pipeline} to prevent data leakage across folds.

Hyperparameter optimization was performed via a 5-fold cross-validation grid search (\texttt{GridSearchCV}) over the following parameter grid:
\[
C \in \{10, 30, 100, 300\}, \quad 
\epsilon \in \{0.05, 0.1, 0.2\}, \quad
\gamma \in \{0.01, 0.05, 0.1\}.
\]
The search was performed using the negative mean squared error as scoring metric.  
The optimal parameters were found to be approximately $C=100$, $\epsilon=0.1$, and $\gamma=0.1$.  
The final model was retrained on the entire training set using the best parameters identified by the grid search.

\subsection{Prediction and Evaluation}

The model was evaluated on the 20\% test subset, and the resulting regression metrics are summarized below:

\begin{itemize}
    \item MAE: 0.1145
    \item RMSE: 0.1722
    \item $R^2$: 0.6910
    \item MAPE: 30.68\%
\end{itemize}

These results demonstrate a clear improvement over the baseline polynomial regression in terms of both accuracy and generalization, confirming the benefit of kernel-based nonlinear mapping combined with optimized hyperparameters.

\subsection{Process Map Generation}

\begin{figure*}[h]
    \centering
        \includegraphics[width=\textwidth]{2_SVR_Punti.pdf}
        \caption{Predicted density maps obtained via optimized SVR (RBF kernel) for different nozzle diameters ($D_\text{n}$). 
        The solubilization parameters are fixed at $P_\text{a}=40$~bar, $t_\text{a}=65$~h, and $t_\text{d}=26$~h.}
    \label{fig:SVR}
\end{figure*}

To visualize the model predictions, density maps were generated over a mesh grid defined by 
\(T_e \in [130, 270]~^\circ\mathrm{C}\) and 
\(S_e \in [100, 1500]~\mathrm{mm\,min^{-1}}\), 
for three nozzle diameters \(D_n = \{0.4,\, 0.6,\, 0.8\}~\mathrm{mm}\).  
The solubilization parameters were fixed at 
\(P_a = 40~\mathrm{bar},\; t_a = 65~\mathrm{h},\; t_d = 26~\mathrm{h}\).
A consistent color normalization range (\(v_\text{min}=0.15\), \(v_\text{max}=1.26~\mathrm{g/cm^3}\)) was applied for comparability across all maps. 
Experimental points matching the fixed solubilization conditions were overlaid with a numerical tolerance of $10^{-9}$.


\subsection{Prediction and Evaluation}

The optimized SVR model achieved the following test-set performance metrics:
\begin{itemize}
    \item MAE: 0.1145
    \item RMSE: 0.1722
    \item $R^2$: 0.6910
    \item MAPE: 30.68\%
\end{itemize}

While the model is not directly interpretable in analytical form, it provides a smooth and continuous nonlinear approximation of the parameter space, outperforming the polynomial regression baseline and effectively capturing local nonlinearities in the experimental dataset.


\section{Model 3: PCA + Polynomial Regression (degree = 2)}

\subsection{Polynomial Expansion on Principal Components}

To decorrelate the inputs and capture nonlinear interactions in a compact space, we applied a second-degree polynomial regression on the principal components (PCs) obtained from a standardized feature space.
Features were first scaled with \texttt{StandardScaler}, then transformed via \texttt{PCA} (up to 6 components, i.e., the number of original inputs).
A \texttt{PolynomialFeatures(degree=2)} expansion was then constructed on the PCs, producing linear, quadratic, and pairwise interaction terms among the principal directions.
This strategy aims to retain interpretability (closed-form linear model on expanded PCs) while mitigating collinearity in the original variables.

\subsection{Model Fitting and Test Definition}

The training/testing split mirrors the fixed spreadsheet partition used elsewhere in this study:
Excel rows 73–90 (inclusive) define the test subset, while all remaining valid rows constitute the training set.
After scaling and projecting the inputs with PCA, the expanded design matrix (degree 2 on PCs) was fitted with \texttt{LinearRegression()} (no regularization), exclusively on the training set:
\[
\hat{\rho} = \beta_0 + \sum_i \beta_i \, PC_i + \sum_{i<j} \beta_{ij} \, PC_i PC_j + \sum_k \beta_{kk} \, PC_k^2 .
\]
The number of retained components was bounded by the minimum among \(\{6,\) number of features, training samples\(\}\), ensuring numerical stability.

\subsection{Prediction and Evaluation}

Evaluation on the held-out test subset (Excel rows 73–90) yielded the following metrics:
\begin{itemize}
    \item MAE: 0.1074
    \item RMSE: 0.1481
    \item $R^2$: 0.3494
    \item MAPE: 21.05\%
\end{itemize}
Under this fixed split, the PCA+Polynomial configuration did not improve over the baseline polynomial regression, indicating that the decorrelation introduced by PCA did not translate into higher predictive performance with a degree-2 expansion.

\subsection{Process Map Generation}

\begin{figure*}[h]
    \centering
        \includegraphics[width=\textwidth]{3_PCA_POLY_Punti.pdf}
        \caption{Predicted density maps obtained via PCA + polynomial regression (degree 2) for different nozzle diameters ($D_\text{n}$).
        Solubilization parameters are fixed at $P_\text{a}=40$~bar, $t_\text{a}=65$~h, and $t_\text{d}=26$~h.}
    \label{fig:PCA_POLY}
\end{figure*}

To visualize the model response, we fixed
\(P_a = 40~\mathrm{bar},\; t_a = 65~\mathrm{h},\; t_d = 26~\mathrm{h}\)
and evaluated \(\hat{\rho}\) over a meshgrid with
\(T_e \in [130, 270]~^\circ\mathrm{C}\) and
\(S_e \in [100, 1500]~\mathrm{mm\,min^{-1}}\),
for \(D_n \in \{0.4,\,0.6,\,0.8\}~\mathrm{mm}\).
A fixed color normalization \((v_\text{min}=0.15,\; v_\text{max}=1.26~\mathrm{g/cm^3})\) was used for comparability across panels, and experimental points matching the fixed solubilization conditions (within a numerical tolerance of \(10^{-9}\)) were overlaid.

\subsection{Prediction and Evaluation}

Consistent with the metrics above, the PCA+Polynomial model provided smooth and interpretable surfaces in the PC space but did not surpass the direct polynomial regression in the original variables under the same degree constraint. This suggests that, for this dataset and split, the dominant nonlinearities are already captured adequately by the baseline polynomial mapping without the need for PCA decorrelation.

\section{Model 4: Random Forest (optimized)}

\subsection{Model Description}

Random Forest (RF) is an ensemble of decision trees trained on bootstrapped samples with randomized feature splits. 
It captures nonlinear interactions and higher-order effects without requiring feature scaling or explicit basis expansion, and it provides robustness to outliers and heterogeneous feature ranges. 
In this study we used \texttt{RandomForestRegressor} with a moderately deep ensemble to balance bias and variance.

\subsection{Model Fitting and Test Definition}

Consistent with other fixed-index experiments, the training/testing split is defined by spreadsheet rows: Excel rows 73–90 (inclusive) form the \emph{test} subset, with all remaining valid rows used for \emph{training}. 
The RF model was fitted exclusively on the training data with the following configuration:
\[
n\_\text{estimators}=300, \text{max\_depth}=10, \text{min\_samples\_leaf}=2, \text{min\_samples\_split}=2, \text{random\_state}=42.
\]
No explicit preprocessing or scaling was applied. Feature importances were computed via mean decrease in impurity.

\subsection{Prediction and Evaluation}

Performance on the held-out test subset (Excel rows 73–90) is:

\begin{itemize}
    \item MAE: 0.0959
    \item RMSE: 0.1408
    \item $R^2$: 0.4121
    \item MAPE: 24.71\%
\end{itemize}

Under this fixed split, the optimized RF constitutes the strongest non-neural baseline, improving over polynomial variants while preserving robustness and stability typical of tree ensembles.

\subsection{Process Map Generation}

\begin{figure*}[h]
    \centering
        \includegraphics[width=\textwidth]{4_RandomForest_Punti.pdf}
        \caption{Predicted density maps obtained via Random Forest for different nozzle diameters ($D_\text{n}$). 
        Solubilization parameters are fixed at $P_\text{a}=40$~bar, $t_\text{a}=65$~h, and $t_\text{d}=26$~h.}
    \label{fig:RandomForest}
\end{figure*}

To visualize the learned response surface, predictions were evaluated over 
\(T_e \in [130, 270]~^\circ\mathrm{C}\) and 
\(S_e \in [100, 1500]~\mathrm{mm\,min^{-1}}\),
for \(D_n \in \{0.4,\,0.6,\,0.8\}~\mathrm{mm}\),
while fixing
\(P_a = 40~\mathrm{bar},\; t_a = 65~\mathrm{h},\; t_d = 26~\mathrm{h}\).
A consistent colormap normalization \((v_\text{min}=0.15,\; v_\text{max}=1.26~\mathrm{g/cm^3})\) was used across panels, and experimental points matching the fixed solubilization conditions (tolerance \(10^{-9}\)) were overlaid. 
As expected for tree-based models, the maps exhibit locally piecewise-constant behavior reflecting the partitioning of the input space.

\subsection{Prediction and Evaluation}

In summary, the Random Forest provides competitive accuracy with strong robustness and minimal preprocessing requirements. 
While it does not yield an explicit analytical equation, the model captures key nonlinearities and interactions, offering reliable empirical maps for process exploration and sensitivity analysis.

\section{Model 5: Polynomial Regression Approximation of Random Forest}

\subsection{Feature Expansion and Rationale}

To obtain an interpretable, closed-form surrogate of the Random Forest (RF) while preserving most of its predictive behavior, we distilled the RF into a second-degree polynomial regressor. 
A \texttt{PolynomialFeatures(degree=2)} expansion was applied to the original six inputs to generate linear, quadratic, and pairwise interaction terms; a \texttt{LinearRegression} model was then fitted to reproduce the RF predictions. 
This approach provides a continuous analytical mapping \(\hat{\rho}(P_a,t_a,t_d,T_e,S_e,D_n)\) that approximates the RF (teacher) and is suitable for analytical inspection and downstream optimization.

\subsection{Model Fitting and Test Definition}

The teacher RF was trained exclusively on the training subset defined by spreadsheet indexing (Excel rows 73–90 inclusive held out for testing). 
Its configuration was:
\[
n\_\text{estimators}=300, \text{max\_depth}=10,
\text{min\_samples\_leaf}=2, \text{min\_samples\_split}=2,
\text{random\_state}=42.
\]
The polynomial surrogate (degree 2, with bias term) was then trained on the \emph{training} inputs using the RF predictions \(\hat{y}_\text{RF}\) as targets (knowledge distillation). 
At evaluation time, we report the surrogate’s performance directly against the true test targets to quantify its standalone utility.

\subsection{Prediction and Evaluation}

On the held-out test subset (Excel rows 73–90), the surrogate attained:
\begin{itemize}
    \item MAE: 0.1094
    \item RMSE: 0.1497
    \item $R^2$: 0.3354
    \item MAPE: 21.70\%
\end{itemize}
These results indicate that the distilled polynomial reproduces the overall trends of the RF while offering an explicit analytical form, with accuracy comparable to baseline polynomial models under the same degree constraint.

\subsection{Process Map Generation}

\begin{figure*}[h]
    \centering
        \includegraphics[width=\textwidth]{5_Poly_Forset_Punti.pdf}
        \caption{Predicted density maps obtained via the polynomial surrogate (degree 2) distilled from Random Forest, for different nozzle diameters ($D_\text{n}$). 
        Solubilization parameters are fixed at $P_\text{a}=40$~bar, $t_\text{a}=65$~h, and $t_\text{d}=26$~h.}
    \label{fig:PolyForest}
\end{figure*}

For visualization, we fixed 
\(P_a = 40~\mathrm{bar},\; t_a = 65~\mathrm{h},\; t_d = 26~\mathrm{h}\)
and evaluated \(\hat{\rho}\) on a mesh with
\(T_e \in [130, 270]~^\circ\mathrm{C}\) and
\(S_e \in [100, 1500]~\mathrm{mm\,min^{-1}}\),
for \(D_n \in \{0.4,\,0.6,\,0.8\}~\mathrm{mm}\).
A fixed colormap normalization \((v_\text{min}=0.15,\; v_\text{max}=1.26~\mathrm{g/cm^3})\) ensures comparability across panels, and experimental points consistent with the fixed solubilization settings (tolerance \(10^{-9}\)) are overlaid.

\subsection{Prediction and Evaluation}

In summary, the RF-distilled polynomial surrogate provides a compact, interpretable approximation with performance similar to the baseline polynomial regression, while remaining consistent with the RF’s response surface for process mapping and analytical studies.


\section{Model 6: Multi-Layer Perceptron (MLP)}

\subsection{Architecture and Training Settings}

To evaluate the capability of a fully connected neural network in modeling the nonlinear relationships among the six process parameters, a Multi-Layer Perceptron (MLP) regressor was implemented in \textsc{MATLAB} (R2024a) using the \texttt{fitnet} function from the Deep Learning Toolbox. 
The network configuration was designed to balance model capacity and generalization:

\begin{itemize}
    \item Hidden layers: \textbf{(6, 12)}
    \item Activation functions: hyperbolic tangent sigmoid (\texttt{tansig}) in hidden layers; linear (\texttt{purelin}) at the output
    \item Training algorithm: \textbf{Bayesian Regularization} (\texttt{trainbr})
    \item Epochs: run to convergence under \texttt{trainbr} (no early stopping)
\end{itemize}

Inputs and targets were normalized to $[0,1]$ using \texttt{mapminmax}. 
All models, including the MLP, were trained and evaluated under the same fixed \textbf{80/20} train/test split (\texttt{random\_state=42}) used throughout the study. 
No dropout was applied; model complexity is controlled by the Bayesian regularization term rather than early stopping.

\begin{figure*}[h]
    \centering
        \includegraphics[width=\textwidth]{6_MLP.pdf}
        \caption{Predicted density maps obtained via the Multi-Layer Perceptron (MLP) model for different nozzle diameters ($D_\text{n}$). 
        Solubilization parameters are fixed at $P_\text{a}=40$~bar, $t_\text{a}=65$~h, and $t_\text{d}=26$~h.}
    \label{fig:MLP}
\end{figure*}

\subsection{Prediction and Evaluation}

The trained MLP was assessed on the held-out test subset using the same regression metrics employed across the study:

\begin{itemize}
    \item MAE: \textbf{0.0925}~\(\mathrm{g\,cm^{-3}}\)
    \item RMSE: \textbf{0.1216}~\(\mathrm{g\,cm^{-3}}\)
    \item $R^2$: \textbf{0.832}
    \item MAPE: \textbf{16.85}\%
\end{itemize}

This Bayesian-regularized configuration delivered the best nominal accuracy among all tested models while maintaining smooth predictive surfaces and stable generalization under the common 80/20 protocol.

\subsection{Process Map Generation}



To visualize the learned relationships, model predictions were evaluated over a grid defined by 
\(T_e \in [130, 270]~^\circ\mathrm{C}\) and 
\(S_e \in [100, 1500]~\mathrm{mm\,min^{-1}}\),
for three nozzle diameters \(D_n = \{0.4,\, 0.6,\, 0.8\}~\mathrm{mm}\).
The solubilization parameters were fixed at 
\(P_a = 40~\mathrm{bar},\; t_a = 65~\mathrm{h},\; t_d = 26~\mathrm{h}\).
A uniform color normalization \((v_\text{min}=0.15,\; v_\text{max}=1.26~\mathrm{g\,cm^{-3}})\) was adopted for consistency with previous figures, and experimental points matching the fixed solubilization conditions (within a tolerance of $10^{-9}$) were overlaid.




\end{document}
