## 5 Modelling
### Model and Interpretation of Results  
For the creation of the optimization model, the Python programming language was used due to its flexibility and extensive support for machine learning and data analysis, along with the application of appropriate libraries and algorithms to enable precise modelling and process optimization (Figure A1).  
The following libraries were used:  
* Pandas (import pandas as pd) for loading data from a CSV file (pd.read_csv) and managing data using the DataFrame structure. A DataFrame represents a tabular data format that allows for easy access and analysis (Figure 6).  
Additionally, RandomForestRegressor was used to create and train a Random Forest model with 100 estimators using the training dataset (Figure 8). This approach helps to capture complex patterns in the data and provides reliable predictions for the outcome variable.  
Figure 5: Random Forest Regression Flowchart with Bootstrap Sampling.  
Figure 6: Data loading using Pandas library for easy data manipulation and analysis.  
from sklearn.ensemble import RandonForestRegressor model = RandomForestRegressor(n_estimators=100, random_state=42) model.fit(X_train, y_train)  
Finally, Mean_squared_error (MSE) was also used to evaluate the model's quality. MSE measures the average squared difference between the actual values and the predicted values. A lower MSE indicates more accurate predictions by the model (Figure 9).  
After running the Python code for training the Random Forest regression model, the obtained Mean Squared Error (MSE) was 0.000063. The Mean Squared Error (MSE) is a metric that estimates the average squared error between the actual values and the values predicted by the model. Specifically, the obtained value of 0.000063 indicates that the predicted values are very close to the actual values, with a minimal difference, which suggests a high accuracy of the model. This is an extremely low MSE value, implying that the model has learned the pattern in the data well and can accurately predict the output values, meaning the errors between actual and predicted values are insignificant. The predicted sigma level of 3.6947 indicates the expected process quality for the new combination of input parameters. Specifically, a sigma level of 3.6947 suggests that the process is of very good quality but still has room for improvement to reach a higher sigma level (for example, a 6\(\sigma\) level, which represents near-flawless production with a very low defect rate). Based on this predicted value, it can be concluded that, with the new combination of input parameters, the production process is expected to maintain stable quality, but it does not yet reach the highest Six Sigma standard. The Random Forest model uses the available data and, based on learned patterns, predicts the output sigma level (\(\gamma\)) for a new combination of input values (\(W_{1}\), \(W_{2}\), \(W_{3}\)). The results indicate relatively good stability, but with its limitations compared to higher sigma levels.  
Additionally, a data visualization was created using available Python libraries to further analyse the model's accuracy and to display the correlation between the actual and predicted values (Figure 10). The following libraries were used for this purpose:  
The following libraries were used:  
* Pandas (import pandas as pd) for loading the CSV file and manipulating tabular data (Figure 10).  
* NumPy (import numpy as np) for working with numerical data and performing mathematical operations (Figure 11).  
* matplotlib (import matplotlib.pyplot as plt) for visualizing the data and displaying the prediction results relative to the actual values. matplotlib allows for plotting graphs  
Figure 8: Creating and training Random Forest Regressor to predict output variables.  
Figure 10: Feature selection and preprocessing using Pandas library.  
Figure 9: Calculating Mean Squared Error (MSE) to evaluate the Accuracy of the Model.