SMOTE Data Preprocessing for Defect Prediction in Sand Casting Foundry

In the sand casting foundry industry, the production of complex castings such as steering bridge components for forklift trucks involves numerous process parameters and a highly variable manufacturing environment. These factors frequently lead to various casting defects, including cold shut, blowhole, sand inclusion, and shrinkage. Data-driven defect prediction methods have emerged as powerful tools to enhance quality control and reduce defect rates in sand casting foundry operations. However, a significant challenge arises from the severe imbalance in production data collected from real-world sand casting foundry environments, where the vast majority of samples represent defect-free castings, while defective samples are scarce. This imbalance severely degrades the performance of machine learning models trained on such datasets.

To address this critical issue, we introduce the Synthetic Minority Oversampling Technique (SMOTE) as a data preprocessing strategy specifically tailored for defect prediction in sand casting foundry. This paper presents a comprehensive investigation into the application of SMOTE within the context of sand casting foundry production, demonstrating its effectiveness in mitigating data imbalance and significantly improving prediction accuracy. We collected a substantial dataset from an operational sand casting foundry, comprising 5,848 defect-free casting records and approximately 1,180 defective records distributed across four defect categories. By applying the SMOTE algorithm, we generated a balanced dataset and subsequently developed a neural network-based defect prediction model. The experimental results reveal a remarkable improvement in prediction accuracy, rising from 86.50% on the imbalanced dataset to 97.91% after SMOTE preprocessing.

This study underscores the critical role of advanced data preprocessing techniques in enabling reliable defect prediction for complex castings in sand casting foundry. Our findings provide a robust methodological framework that can be adopted by other researchers and practitioners in the field to enhance quality assurance and process optimization in sand casting foundry operations.

The sand casting foundry sector is a cornerstone of the global manufacturing industry, producing a vast array of structural and mechanical components. Among these, complex castings such as steering bridges for forklift trucks are subjected to rigorous performance requirements due to their role in bearing vertical loads, longitudinal forces, and lateral forces. These components must exhibit high strength, fatigue resistance, and dimensional precision, making defect prevention a top priority. Despite advancements in process control, defects such as cold shut, blowhole, sand inclusion, and shrinkage remain prevalent in sand casting foundry production, often resulting from intricate interactions among chemical composition, pouring parameters, and sand treatment variables.

Traditional quality control methods in sand casting foundry rely heavily on post-production inspection and manual expertise, which are both time-consuming and limited in predictive capability. In recent years, data-driven approaches, particularly machine learning and deep learning, have demonstrated great potential for predicting casting defects based on historical production data. These methods can identify hidden patterns and correlations among process parameters, enabling proactive defect mitigation. However, the practical deployment of such models in sand casting foundry is hindered by the inherent data imbalance problem: the vast majority of castings produced are defect-free, while defective castings constitute only a small fraction of the total output. This imbalance causes models to become biased toward the majority class (defect-free), resulting in poor sensitivity and low accuracy for minority defect classes.

To overcome the data imbalance challenge in sand casting foundry, various data preprocessing techniques have been explored. Undersampling methods, such as the Edited Nearest Neighbor (ENN) algorithm, attempt to balance the dataset by removing samples from the majority class. While effective in some cases, undersampling risks discarding valuable information that could be critical for model generalization. Conversely, oversampling methods generate synthetic samples for the minority classes to achieve class balance. Among these, SMOTE has gained widespread adoption due to its ability to create realistic synthetic samples by interpolating between existing minority class instances, thereby preserving the underlying data distribution without introducing excessive noise.

In this study, we focus on the application of SMOTE for defect prediction in sand casting foundry, specifically targeting the production of complex steering bridge castings made from ductile iron (grade QT450-10). The dataset collected from an operational sand casting foundry includes 17 process parameters spanning three categories: chemical composition (carbon, manganese, magnesium, silicon, sulfur, phosphorus, aluminum), pouring parameters (inoculation rate, pouring weight, pouring temperature, pouring time), and sand treatment parameters (new sand percentage, bentonite percentage, compactability, mixed soil percentage, shear strength, old sand temperature, old sand moisture). The defect categories include cold shut, blowhole, sand inclusion, and shrinkage. Our objective is to systematically evaluate the impact of SMOTE-based data preprocessing on the performance of a neural network-based defect prediction model, providing a detailed comparison of model accuracy and loss before and after balancing.

The remainder of this paper is organized as follows. Section 2 describes the data acquisition and preprocessing procedures. Section 3 discusses the data imbalance problem and introduces the SMOTE algorithm. Section 4 presents the implementation details and effectiveness analysis of SMOTE. Section 5 evaluates the impact of data preprocessing on defect prediction model performance. Finally, Section 6 concludes the study with key findings and future research directions.

Data Acquisition and Preprocessing

The data used in this study were collected from a real-world sand casting foundry producing steering bridge castings for forklift trucks. The casting material is ductile iron grade QT450-10, which is characterized by its high strength and good ductility. The steering bridge is a complex structural component that experiences significant mechanical loads during operation, making it essential to achieve high casting quality free from defects. The production process in this sand casting foundry involves a series of well-defined steps, including sand preparation, molding, pouring, cooling, and shakeout, each of which contributes to the final casting quality.

We obtained a raw dataset comprising 7,247 records, each corresponding to an individual casting production event. Among these records, 5,848 are defect-free castings, while the remaining 1,399 records exhibit one of four defect types: cold shut (274 samples), blowhole (399 samples), sand inclusion (359 samples), and shrinkage (148 samples). This distribution clearly illustrates the severe data imbalance inherent in sand casting foundry production, where defect-free samples outnumber each defect class by a factor ranging from 15 to 40. Such imbalance poses a substantial challenge for training reliable defect prediction models.

The raw dataset includes not only process-relevant parameters but also auxiliary information unrelated to casting quality, such as operator IDs, shift numbers, and machine identifiers. To ensure data quality and relevance, we performed a series of preprocessing steps. First, we removed all columns that do not directly influence casting quality, retaining only the process parameters that are known to affect defect formation. The final set of features includes three categories: chemical composition (C, Mn, Mg, Si, S, P, Al), pouring parameters (inoculation rate, pouring weight, pouring temperature, pouring time), and sand treatment parameters (new sand percentage, bentonite percentage, compactability, mixed soil percentage, shear strength, old sand temperature, old sand moisture). A sample of the preprocessed data is illustrated in the table below.

Record ID C (%) Mn (%) Mg (%) Si (%) S (%) P (%) Al (%) Inoculation Rate (%)
1 3.71 0.62 0.042 2.68 0.010 0.022 0.022 30
2 3.85 0.52 0.042 2.70 0.009 0.020 0.027 61
3 3.74 0.56 0.040 2.68 0.010 0.022 0.023 76
4 3.68 0.51 0.043 2.82 0.011 0.022 0.026 39
5 3.72 0.52 0.054 2.69 0.014 0.033 0.024 51

Record ID New Sand (%) Bentonite (%) Compactability (%) Mixed Soil (%) Shear Strength (MPa) Pouring Weight (kg) Pouring Temp (°C) Pouring Time (s) Old Sand Temp (°C) Old Sand Moisture (%) Defect
1 0 23.9 36.88 11.4 5.07 138.2 1407 15.2 33.4 1.78 None
2 26 24.4 40.06 11.4 5.51 134.1 1388 15.9 39.2 2.19 Cold Shut
3 15 21.7 41.41 12.1 5.38 133.8 1410 20.5 36.5 2.00 Blowhole
4 0 21.5 47.43 12.3 2.00 139.7 1399 15.6 37.6 2.11 Sand Inclusion
5 0 23.8 40.90 12.0 5.66 132.0 1406 16.1 41.2 2.05 Shrinkage

After preprocessing, the dataset contains 17 numerical features and one categorical target variable with five classes: no defect, cold shut, blowhole, sand inclusion, and shrinkage. The features are normalized to zero mean and unit variance to ensure that all variables contribute equally during model training. This normalization step is particularly important in sand casting foundry data, where the scales of different process parameters vary widely, from percentages (e.g., carbon content around 3.7%) to temperatures (e.g., pouring temperature around 1400 °C).

Imbalanced Data Problem and Solutions

Most classification learning algorithms operate under the fundamental assumption that the number of training samples across different classes is approximately equal. When this assumption holds, models can effectively learn decision boundaries that separate the classes with high accuracy. However, in many real-world applications, including defect prediction in sand casting foundry, the class distribution is often highly skewed, with one class (usually the normal or defect-free class) dominating the dataset. This phenomenon, known as class imbalance, can severely degrade the performance of standard classifiers, as they tend to become biased toward the majority class while neglecting the minority classes.

In the context of sand casting foundry defect prediction, the imbalance is particularly pronounced. Our dataset contains 5,848 defect-free samples (80.7% of the total) and only 1,399 defective samples (19.3%), distributed across four defect categories. The smallest class, shrinkage, contains only 148 samples, which is less than 2.5% of the defect-free class size. A naive classifier that simply predicts every new sample as defect-free would achieve an accuracy of 80.7%, which appears reasonable at first glance. However, such a model would be completely useless for practical applications in sand casting foundry, as it would fail to identify any defective castings, thereby missing the very objective of defect prediction.

The fundamental issue is that standard training objectives, such as minimizing overall error rate, are insensitive to the needs of imbalanced data. A model trained on imbalanced data learns decision boundaries that heavily favor the majority class, resulting in high precision for the majority class but extremely low recall for minority classes. In sand casting foundry, where the cost of missing a defective casting can be substantial in terms of rework, scrap, and potential field failures, achieving high recall for defect classes is of paramount importance.

To address the data imbalance problem in sand casting foundry, two primary categories of methods exist: data-level methods and algorithm-level methods. Data-level methods modify the training dataset to achieve a more balanced class distribution, while algorithm-level methods adjust the learning algorithm itself to be more sensitive to minority classes. Among data-level methods, two main approaches are undersampling and oversampling.

Undersampling methods aim to balance the dataset by removing samples from the majority class. The most representative algorithm in this category is the Edited Nearest Neighbor (ENN) algorithm. ENN operates by examining each majority class sample and its k nearest neighbors. If the majority of the neighbors (or all neighbors, depending on the strategy) belong to the majority class, the sample is considered redundant and is removed. The rationale is that such samples carry information that is already well-represented by their neighbors, so their removal should not significantly affect the model’s ability to generalize. ENN offers two strategies: the mode strategy, which removes a sample if the majority of its neighbors belong to the majority class, and the all strategy, which removes a sample only if all its neighbors belong to the majority class.

While undersampling methods like ENN can effectively balance the dataset, they suffer from a critical drawback: potentially valuable information may be lost when samples are discarded. In sand casting foundry, where data collection is expensive and time-consuming, every production record represents a unique combination of process conditions. Discarding samples, even those from the majority class, risks losing subtle patterns that could be important for distinguishing between defect types.

Oversampling methods take the opposite approach by generating synthetic samples for the minority classes to increase their representation in the dataset. The simplest form of oversampling is random oversampling, which duplicates existing minority class samples. However, this naive approach can lead to severe overfitting, as the model simply memorizes the duplicated samples rather than learning generalizable patterns. To overcome this limitation, more sophisticated oversampling techniques have been developed, with SMOTE being the most widely adopted.

SMOTE addresses the limitations of random oversampling by creating synthetic samples through interpolation between existing minority class instances. Instead of replicating samples, SMOTE generates new, plausible samples that lie on the line segments connecting a minority sample to one of its k nearest neighbors within the minority class. This approach enriches the dataset with diverse yet realistic samples that expand the decision region of the minority class, thereby improving the model’s ability to generalize.

In this study, we choose SMOTE over undersampling methods for several reasons. First, the total number of defective samples in our sand casting foundry dataset is already very limited, and any reduction through undersampling would further diminish the already scarce minority class information. Second, SMOTE has been shown to be particularly effective for high-dimensional data, which is characteristic of our dataset with 17 process parameters. Third, SMOTE maintains the original data distribution by generating samples within the convex hull of the minority class, preserving the intrinsic relationships among the features.

SMOTE Algorithm Implementation and Analysis

The SMOTE algorithm operates by generating synthetic samples for each minority class instance based on its nearest neighbors in the feature space. The core idea is to create new samples that are not mere copies but rather plausible interpolations between existing minority class samples. This section provides a detailed description of the SMOTE algorithm, its implementation, and the analysis of its effectiveness in the context of sand casting foundry defect prediction.

The SMOTE algorithm consists of three main steps. First, for each sample X_i in the minority class, we compute the Euclidean distances to all other samples in the same class to identify its k nearest neighbors. The Euclidean distance between two samples X_i and X_j with n features is calculated as:

$$d(X_i, X_j) = \sqrt{\sum_{p=1}^{n} (x_{ip} – x_{jp})^2}$$

where x_{ip} and x_{jp} are the p-th feature values of samples X_i and X_j, respectively. In our implementation, we set k = 5 as the default number of nearest neighbors, which is a commonly used value in SMOTE-based applications.

Second, based on the desired sampling ratio, which is determined by the degree of imbalance between the minority class and the majority class, we select a subset of the k nearest neighbors for each minority sample. The sampling ratio R is calculated as:

$$R = \frac{N_{majority}}{N_{minority}} \times \alpha$$

where N_majority is the number of samples in the majority class (defect-free castings), N_minority is the number of samples in the minority class (a specific defect type), and α is a scaling factor that controls the final class balance. In our experiments, we set α = 1.0 to achieve a fully balanced dataset where each defect class has approximately the same number of samples as the defect-free class.

Third, for each selected neighbor X_{zi}, a new synthetic sample X_new is generated by linear interpolation between the original sample X_i and the selected neighbor X_{zi}:

$$X_{new} = X_i + \text{rand}(0, 1) \times (X_{zi} – X_i)$$

where rand(0, 1) is a random number uniformly distributed in the interval [0, 1]. This formula ensures that the new sample lies on the line segment connecting X_i and X_{zi}, at a random point between them. The randomness introduced by the uniform random number ensures diversity among the generated samples while maintaining the local characteristics of the minority class.

The implementation of SMOTE was carried out in Python using a combination of standard libraries. The specific libraries used include TensorFlow for deep learning infrastructure, NumPy for numerical computations, Xlrd and Xlwt for reading and writing Excel files, the Random standard library for random number generation, and Scikit-learn for machine learning utilities. The implementation steps are as follows:

Step 1: Import all required libraries, including TensorFlow, NumPy, Xlrd, Xlwt, Random, and Scikit-learn.

Step 2: Load the preprocessed data from the Excel file using the Xlrd library. The data is normalized to zero mean and unit variance and then loaded into a NumPy array for efficient processing.

Step 3: Create a custom SMOTE class that includes a constructor for initialization, a function to find the k nearest neighbors for each sample in the dataset X, and a function to generate new samples based on the k nearest neighbors and the sampling factor.

Step 4: Apply the SMOTE class to the imbalanced dataset to generate synthetic samples for each minority defect class, exporting the resulting balanced dataset to a new Excel file using the Xlwt library.

The pseudo-code for the SMOTE algorithm implementation is presented below:

Algorithm 1: SMOTE Data Preprocessing for Sand Casting Foundry Defect Prediction

Input: Imbalanced dataset D with N samples, M features, and C classes; oversampling ratio R; number of nearest neighbors k

Output: Balanced dataset D’

1: For each minority class c in C:

2: Let S_c be the set of samples in class c

3: Let N_synthetic = R × |S_c| be the number of synthetic samples to generate

4: For each sample X_i in S_c:

5: Find the k nearest neighbors of X_i within S_c based on Euclidean distance

6: Select N_neighbors = ceil(N_synthetic / |S_c|) neighbors randomly from the k nearest neighbors

7: For each selected neighbor X_zi:

8: λ = random(0, 1)

9: X_new = X_i + λ × (X_zi – X_i)

10: Add X_new to the synthetic sample set

11: Combine original samples and synthetic samples to form the balanced dataset for class c

12: Return D’ as the union of all balanced class datasets

The effectiveness of SMOTE can be visualized by examining the distribution of samples in a two-dimensional feature space. To illustrate, we select two representative features from our sand casting foundry dataset: pouring temperature and mixed soil percentage. These features are chosen because they exhibit relatively high variance across different defect classes. The original imbalanced dataset shows a clear dominance of the defect-free class, with the four defect classes appearing as sparse and isolated clusters. After applying SMOTE, the synthetic samples fill in the gaps between existing minority class samples, creating more densely populated and contiguous clusters for each defect class.

The quantitative analysis of the SMOTE preprocessing effect is summarized in the table below, which compares the sample counts for each class before and after preprocessing.

Class Original Sample Count After SMOTE Sample Count Increase Factor
No Defect 5,848 5,848 1.00
Cold Shut 274 6,006 21.92
Blowhole 399 6,384 16.00
Sand Inclusion 359 6,408 17.85
Shrinkage 148 6,215 41.99
Total 6,998 30,862 4.41

As shown in the table, the original dataset contains a total of 6,998 samples, with the defect-free class accounting for 83.5% of the total. After SMOTE preprocessing, each defect class is expanded to approximately 6,000 samples, resulting in a total dataset of 30,862 samples. The most severely imbalanced class, shrinkage, experienced the largest increase factor of approximately 42 times, while the blowhole class increased by a factor of 16. This balanced distribution ensures that the subsequent defect prediction model will not be biased toward any particular class, thereby enabling more accurate and reliable predictions for all defect types.

Impact of Data Preprocessing on Defect Prediction Model Performance

To evaluate the impact of SMOTE-based data preprocessing on defect prediction performance, we designed a neural network-based classification model and trained it on both the original imbalanced dataset and the SMOTE-balanced dataset. The model architecture, training procedure, and evaluation metrics are described in detail below, followed by a comprehensive comparison of the results.

Model Architecture

The defect prediction model is a feedforward neural network consisting of an input layer, multiple hidden layers, and an output layer. The input layer accepts 17 features corresponding to the process parameters in the sand casting foundry dataset. The hidden layers use the Rectified Linear Unit (ReLU) activation function, defined as:

$$f(x) = \max(0, x)$$

where x is the input to the neuron. ReLU is chosen for its computational efficiency and its ability to mitigate the vanishing gradient problem, which is particularly beneficial for deep networks. The output of a ReLU neuron given an input vector x and weight matrix w with bias b is:

$$\text{output} = \max(0, w^T x + b)$$

The output layer uses the Softmax activation function to produce a probability distribution over the five classes (no defect, cold shut, blowhole, sand inclusion, shrinkage). The Softmax function is defined as:

$$\text{Softmax}(z_i) = \frac{e^{z_i}}{\sum_{j=1}^{C} e^{z_j}}$$

where z_i is the logit (raw output) for class i, C is the total number of classes (C = 5 in our case), and the denominator normalizes the outputs to sum to 1. The Softmax function ensures that the model outputs are interpretable as probabilities, with the predicted class being the one with the highest probability.

Training Procedure

The model is trained using the cross-entropy loss function, which measures the dissimilarity between the predicted probability distribution and the true distribution (one-hot encoded labels). For a single sample with true label y and predicted probability distribution p, the cross-entropy loss is defined as:

$$L = -\sum_{i=1}^{C} y_i \log(p_i)$$

In the multi-class case with N samples, the average cross-entropy loss is:

$$\mathcal{L} = -\frac{1}{N} \sum_{j=1}^{N} \sum_{i=1}^{C} y_{ji} \log(p_{ji})$$

where y_{ji} is 1 if sample j belongs to class i and 0 otherwise, and p_{ji} is the predicted probability of sample j belonging to class i. The model is optimized using the Adam optimizer with a learning rate of 0.001, and training is conducted for 5,000 iterations with a batch size of 64. The dataset is split into training (80%) and testing (20%) sets, with stratification to preserve the class distribution in both subsets.

Evaluation Metrics

We use two primary metrics to evaluate model performance: accuracy and cross-entropy loss. Accuracy is defined as the proportion of correctly classified samples among all samples:

$$\text{Accuracy} = \frac{\text{Number of correct predictions}}{\text{Total number of samples}} \times 100\%$$

Cross-entropy loss provides a more nuanced view of model performance by penalizing confident misclassifications more heavily. Lower cross-entropy loss indicates that the predicted probability distribution is closer to the true distribution. We monitor both metrics on the training set and the testing set throughout the training process to detect overfitting and assess generalization capability.

Results on Imbalanced Data

When the model is trained on the original imbalanced dataset, the cross-entropy loss exhibits significant instability. The loss decreases initially but shows occasional spikes and oscillations, particularly around the 600th iteration, where the loss value increases sharply. This behavior indicates that the model struggles to learn a stable decision boundary due to the overwhelming presence of defect-free samples. The accuracy curve similarly shows erratic fluctuations, with the testing accuracy oscillating between 84% and 87% without converging to a stable value. The detailed numerical values for cross-entropy loss and accuracy over 5,000 iterations on the imbalanced dataset are presented in the table below.

Iteration Training Accuracy (%) Training Loss Testing Accuracy (%) Testing Loss
0 35.95 1.8711 37.24 1.8786
500 83.71 0.3899 84.57 0.3741
1000 85.44 0.3587 86.50 0.3534
1500 85.65 0.3532 86.62 0.3490
2000 85.65 0.3487 86.67 0.3454
2500 85.74 0.3443 86.90 0.3431
3000 86.01 0.3439 86.33 0.3461
3500 86.26 0.3384 86.79 0.3410
4000 86.28 0.3353 86.56 0.3391
4500 86.43 0.3304 86.50 0.3364
5000 86.39 0.3280 86.50 0.3383

At the end of 5,000 iterations, the model achieves a testing accuracy of 86.50% with a testing loss of 0.3383. While this accuracy may appear acceptable, the erratic behavior during training and the lack of convergence indicate that the model has not learned a robust decision boundary. More importantly, accuracy alone is misleading in the context of imbalanced data, as a model that predicts the majority class for all samples would achieve an accuracy of 80.7%. The true deficiency of the model becomes apparent when examining class-specific performance: the recall for minority defect classes is extremely low, often below 10%, meaning that most defective castings go undetected. This renders the model impractical for real-world sand casting foundry applications.

Results on SMOTE-Balanced Data

After applying SMOTE data preprocessing to balance the dataset, the model training behavior improves dramatically. The cross-entropy loss decreases monotonically and smoothly over the entire training process, without any spikes or oscillations. The loss value approaches zero asymptotically, indicating that the model is able to fit the data distribution with high fidelity. The accuracy curve shows a strictly increasing trend, converging to a stable value above 97% without fluctuations.

The detailed numerical values for cross-entropy loss and accuracy over 5,000 iterations on the SMOTE-balanced dataset are presented in the table below.

Iteration Training Accuracy (%) Training Loss Testing Accuracy (%) Testing Loss
0 20.81 10.9126 20.46 10.9672
500 94.74 0.2219 94.43 0.2255
1000 96.44 0.1541 96.20 0.1591
1500 97.03 0.1266 96.80 0.1323
2000 97.26 0.1114 97.13 0.1170
2500 97.49 0.1014 97.32 0.1066
3000 97.57 0.0939 97.44 0.0988
3500 97.63 0.0879 97.51 0.0927
4000 97.72 0.0829 97.62 0.0876
4500 97.85 0.0788 97.81 0.0834
5000 97.99 0.0753 97.91 0.0798

At the end of 5,000 iterations on the SMOTE-balanced dataset, the model achieves a training accuracy of 97.99% and a testing accuracy of 97.91%. The testing loss of 0.0798 is substantially lower than the 0.3383 achieved on the imbalanced dataset, representing a 76.4% reduction in loss. The smooth convergence of both accuracy and loss metrics confirms that the model has learned a robust and generalizable decision boundary that effectively distinguishes among all five classes.

Comparative Analysis

The comparison between the models trained on imbalanced and SMOTE-balanced data reveals several key insights. First, the most significant improvement is in the stability of the training process. While the imbalanced data model exhibits oscillatory behavior with occasional loss spikes, the SMOTE-balanced model shows smooth and monotonic convergence. This stability is crucial for practical deployment in sand casting foundry, as it ensures consistent and reliable predictions.

Second, the absolute improvement in testing accuracy from 86.50% to 97.91% represents an 11.41 percentage point increase, which is substantial in the context of quality control in sand casting foundry. This improvement translates to a reduction in misclassification rate from 13.50% to 2.09%, meaning that the SMOTE-balanced model makes approximately 85% fewer errors compared to the imbalanced model.

Third, and perhaps most importantly, the SMOTE-balanced model achieves high accuracy across all classes, not just the majority class. Class-specific analysis reveals that the recall for each defect class exceeds 95%, meaning that the vast majority of defective castings are correctly identified. This is critical for sand casting foundry operations, where undetected defects can lead to costly field failures and safety issues.

The table below summarizes the key performance metrics before and after SMOTE data preprocessing.

Metric Before SMOTE After SMOTE Improvement
Training Accuracy 86.39% 97.99% +11.60%
Testing Accuracy 86.50% 97.91% +11.41%
Training Loss 0.3280 0.0753 −77.04%
Testing Loss 0.3383 0.0798 −76.41%
Loss Convergence Fluctuating Monotonic Stable
Accuracy Convergence Fluctuating Monotonic Stable

The results conclusively demonstrate that SMOTE data preprocessing is highly effective for improving defect prediction performance in sand casting foundry. The balanced data enables the neural network to learn more accurate and generalizable decision boundaries, leading to substantial improvements in both accuracy and stability. The SMOTE-balanced model is well-suited for deployment in real-world sand casting foundry environments, where it can assist quality control engineers in identifying potentially defective castings early in the production process, thereby reducing scrap rates and improving overall productivity.

Conclusion

In this study, we addressed the critical challenge of data imbalance in defect prediction for complex castings produced in sand casting foundry environments. Using a real-world dataset collected from an operational sand casting foundry producing steering bridge castings from ductile iron grade QT450-10, we demonstrated that severe class imbalance—where defect-free samples outnumber defective samples by a factor of up to 40—significantly degrades the performance of neural network-based defect prediction models. The model trained on imbalanced data exhibited unstable training behavior with oscillating accuracy and loss, achieving a testing accuracy of only 86.50% with poor recall for minority defect classes.

The application of the Synthetic Minority Oversampling Technique (SMOTE) as a data preprocessing strategy proved highly effective in mitigating this imbalance. By generating synthetic samples for each minority defect class through interpolation between existing samples, SMOTE created a balanced dataset with approximately 6,000 samples per class, resulting in a total of 30,862 samples. The SMOTE-balanced dataset preserved the intrinsic distribution of the original data while enriching the representation of the minority classes, enabling the neural network model to learn more robust and accurate decision boundaries.

The experimental results demonstrated a substantial improvement in model performance after SMOTE preprocessing. The testing accuracy increased from 86.50% to 97.91%, representing an 11.41 percentage point improvement. The cross-entropy loss decreased from 0.3383 to 0.0798, a reduction of 76.41%, indicating that the model’s predictions are much closer to the true distribution. Furthermore, the training process became stable and monotonic, with smooth convergence of both accuracy and loss metrics. These improvements are particularly significant for practical applications in sand casting foundry, where high recall for defect classes is essential for effective quality control.

Key findings from this study include:

First, class imbalance is a pervasive issue in sand casting foundry defect prediction datasets due to the inherent rarity of defective castings in well-controlled production environments. Without appropriate preprocessing, this imbalance renders standard machine learning models unreliable, as they tend to bias toward the majority class and fail to detect the minority defect classes.

Second, SMOTE is an effective data-level solution for addressing class imbalance in sand casting foundry data. Unlike random oversampling, which duplicates existing samples and risks overfitting, SMOTE generates diverse yet plausible synthetic samples that expand the decision region of minority classes. The interpolation-based generation mechanism ensures that synthetic samples maintain the local characteristics of the original minority class distribution.

Third, the impact of SMOTE preprocessing on model performance is substantial and quantifiable. The 11.41 percentage point improvement in accuracy and the 76.41% reduction in cross-entropy loss demonstrate the critical role of data preprocessing in enabling reliable defect prediction for complex castings in sand casting foundry.

This study also provides a practical framework for implementing SMOTE data preprocessing in sand casting foundry settings. The methodology includes data acquisition and cleaning, feature selection, normalization, SMOTE-based synthetic sample generation, and neural network model training and evaluation. The framework can be adapted to other types of castings and defect categories, making it a versatile tool for quality improvement in sand casting foundry.

The implications for sand casting foundry operations are significant. By enabling accurate prediction of casting defects before final inspection, the proposed approach can help reduce scrap rates, minimize rework costs, and improve overall production efficiency. Early detection of defects also allows for timely adjustments to process parameters, preventing the recurrence of similar defects in subsequent production runs. This proactive approach to quality control aligns with the broader Industry 4.0 paradigm of data-driven manufacturing optimization.

Several promising directions for future research emerge from this study. First, exploring hybrid data preprocessing methods that combine SMOTE with other techniques, such as undersampling or feature selection, could further enhance model performance. Second, investigating the applicability of more advanced oversampling methods, such as Adaptive Synthetic Sampling (ADASYN) or Borderline-SMOTE, may yield additional improvements for complex datasets with overlapping class boundaries. Third, extending the analysis to other types of castings and foundry processes beyond sand casting would help validate the generalizability of the findings. Fourth, incorporating process knowledge and physical constraints into the data generation process could improve the realism of synthetic samples and further enhance model robustness.

In conclusion, this study provides compelling evidence that SMOTE data preprocessing is a powerful tool for improving defect prediction in sand casting foundry. The substantial improvements in accuracy, loss, and training stability demonstrate that addressing data imbalance is not merely a technical detail but a fundamental requirement for building reliable predictive models in manufacturing environments. We hope that the insights and methodology presented in this paper will encourage wider adoption of data preprocessing techniques in sand casting foundry and contribute to the ongoing digital transformation of the global foundry industry.

Scroll to Top