Open-access A Comparative Study of Recurrent Architectures for Imbalanced Dry Bean Classification

Abstract

The classification of dry bean varieties is vital for agricultural productivity and food quality control. However, the inherent class imbalance in datasets poses challenges for machine learning (ML) and deep learning (DL) models. This study evaluates the performance of three DL models-Long Short-Term Memory (LSTM), Gated Recurrent Unit (GRU), and One-Dimensional Convolutional LSTM (ConvLSTM1D)-in classifying 13,611 samples of seven dry bean varieties from the publicly available Dry Bean Dataset. The ConvLSTM1D model’s novelty lies in its hybrid architecture, which integrates 1D convolutional layers to extract complex local patterns from the morphological features before recurrent processing. This structural advantage allows it to create more discriminative feature representations, effectively addressing the class imbalance by better identifying minority classes without explicit resampling techniques. Experimental results show that ConvLSTM1D achieves the highest performance, with an accuracy of 93.78% and macro-averaged precision, recall, and F1-scores of 93.65%, 93.78%, and 93.70%, respectively. This model also demonstrates a significant reduction in misclassifications and maintains robust performance despite dataset imbalance. In contrast, LSTM and GRU models exhibit comparable but slightly lower classification accuracy and are less effective in differentiating visually similar bean types. This research highlights the potential of ConvLSTM1D as a reliable and accurate method for automated dry bean classification, contributing to improved efficiency and precision in agricultural practices.

Keywords:
classification; deep learning; dry beans; imbalanced dataset; ConvLSTM1D.

HIGHLIGHTS

A hybrid ConvLSTM1D architecture is evaluated for handling imbalanced tabular data.

ConvLSTM1D achieved the highest accuracy of 93.78% and outperformed LSTM and GRU models.

The model’s architecture inherently mitigates class imbalance without data resampling.

A robust and highly accurate method for automated agricultural classification is validated.

INTRODUCTION

The world faces significant nutrition and hunger problems driven by a rapid increase in population. Since inadequate and unbalanced nutrition reduces the body’s resistance, the probability of contracting and severely progressing through diseases increases. More than half of the world’s population lacks adequate protein and relies on grain-based diets. In such cases, legumes are the most important source of protein, with dry beans (Phaseolus vulgaris L.) being the richest in variety and the most consumed. Beans, rich in protein, carbohydrates, vitamins, and minerals, have an important place in human nutrition [1-4]. They are also rich in unsaturated fatty acids such as linoleic and oleic acids [5,6]. With a gene center in Central and South America [7,8], the dry bean is an edible legume with the widest cultivation area in the world. Although Türkiye is not their homeland, as of September 2024, there are three production-licensed and 52 registered dry bean varieties in Türkiye [9]. According to the TS 141 standard, the Turkish Standards Institute has divided the dry beans grown in Türkiye into varieties such as Barbunya, Battal, Bombay, Calı, Dermason, Horoz, Tombul, Selanik, Seker, and Sira, considering their botanical characteristics [10].

According to the Food and Agriculture Organization (FAO) database for 2022, dry beans rank first among edible legumes globally [11]. Expanding cultivation and increasing yield per unit area are crucial for increasing production, and a universal objective of bean breeding programs is to improve stress tolerance and seed yield potential [12-14]. A key component of achieving this is the accurate classification of agricultural products, especially dry beans. Traditional classification methods based on visual features are prone to human error and are time-consuming, necessitating automated systems powered by machine learning (ML) and deep learning (DL). However, challenges such as class imbalance, where some categories are overrepresented while others are underrepresented, can significantly affect model performance and lead to biased predictions.

To address the need for automated classification, various studies have explored both traditional ML and modern DL approaches. Initial research successfully applied traditional ML algorithms. Kılıç and coauthors [15] used a computer vision system with artificial neural networks (ANNs) to classify beans based on size and color, achieving 90.6% accuracy. Similarly, Chen and coauthors [16] used ANNs for corn variety identification. Subsequent studies confirmed the effectiveness of ML, with Mollazade and coauthors [17] finding ANNs superior for raisin classification and Teimouri and coauthors [18] achieving 97.84% accuracy in classifying almonds. This trend is also evident in the classification of other staple grains. In a comprehensive study on rice species, Çifci and Kırbaş [19] evaluated ten different ML models and found that a Logistic Regression model achieved the highest accuracy at 93.1%, identifying morphological features like Major Axis Length and Perimeter as the most discriminative factors. On the Dry Bean Dataset used in this study, Koklu and Ozkan [20] achieved 93.13% accuracy with models like Support Vector Machine (SVM), while Salauddin Khan and coauthors [21] reached 93% accuracy using Extreme Gradient Boosting (XGBoost). While effective, these models often showcase the limits of traditional ML when compared directly with deep learning. This superiority of DL is clearly demonstrated in the context of fruit disease classification; for instance, Gündüz and coauthors [22] compared SVM, Decision Trees, and CNNs for detecting pomegranate diseases and found that a two-layer CNN model significantly outperformed the traditional ML methods, achieving 88% accuracy. This trend holds true for other crops as well. Zhang and coauthors [23] found DL methods more adaptable than traditional ML for maize seed classification, and Dogan and coauthors [24] advanced the field by combining CNNs with optimization algorithms to classify dry bean varieties.

In recent years, the trend has shifted decisively toward sophisticated, image-based DL models, often leveraging transfer learning. This approach has been successfully applied across a wide variety of agricultural products. Gulzar [25] enhanced soybean classification by modifying the InceptionV3 architecture, achieving 98.73% accuracy, while Alkanan and Gulzar [26] developed an enhanced MobileNetV2 model for corn seed disease classification, reaching ~96% accuracy through feature augmentation and transfer learning. This strategy of pairing a lightweight architecture with comprehensive data augmentation was also employed by Huong and coauthors [27], who achieved near-perfect accuracy (99.53%) in classifying the quality of oranges. The application extends to high-value commodities as well; Korkmaz and coauthors [28] conducted a comparative analysis of five CNN models for classifying coffee bean species, identifying InceptionV3 as the most effective with 93% accuracy. Addressing the significant challenge of high intra-species diversity, Mengstu and Taner [29] successfully classified 124 wheat varieties, demonstrating that a custom-built CNN could even outperform popular pre-trained models. The power of transfer learning is further highlighted in studies by Gulzar and coauthors [30], who used a pre-trained Xception model for seed classification, and Gulzar and Ünal [31], who introduced a novel PL-DenseNet to optimize pear leaf disease detection with 99.18% accuracy. Collectively, these state-of-the-art studies confirm the dominance of CNN-based architectures for image analysis. They also underscore a common strategy: leveraging transfer learning and extensive data augmentation to overcome challenges like limited data and class imbalance, which is a key departure point for our own study’s focus on architectural robustness.

Despite significant progress, a research gap remains. The vast majority of recent, high-performing studies focus on applying CNN-based architectures to raw image data. The performance of recurrent-based architectures (LSTM, GRU) on pre-extracted, tabular morphological data, such as that found in the Dry Bean Dataset, is comparatively underexplored. Furthermore, while class imbalance is a well-recognized challenge, it is typically addressed at the data level through augmentation or resampling. There is limited investigation into whether a model’s architecture itself can inherently handle natural class imbalance without such external data manipulation. The potential of a hybrid model like the One-Dimensional Convolutional LSTM (ConvLSTM1D)-which combines convolutional feature extraction with recurrent sequence processing-to analyze patterns within a vector of morphological features presents a novel and promising research direction.

This study aims to fill this gap by conducting a comprehensive comparative analysis of three DL models: LSTM, GRU, and ConvLSTM1D. Our central hypothesis is that the ConvLSTM1D model, by integrating 1D convolutional layers to capture localized patterns among the 16 input features before recurrent processing, will demonstrate superior robustness and classification accuracy, particularly for the underrepresented classes within the imbalanced Dry Bean Dataset. The primary contributions of this work are as follows:

  • We present the first comprehensive comparative study of LSTM, GRU, and ConvLSTM1D models for the classification of dry bean varieties using a tabular morphological dataset.

  • We investigate the inherent architectural ability of ConvLSTM1D to mitigate the effects of class imbalance without relying on external data resampling or augmentation techniques.

  • We provide a detailed performance analysis that highlights the specific strengths and weaknesses of each model, offering insights into their suitability for similar agricultural classification tasks with imbalanced data.

The remainder of this paper is organized into four sections. Section 2 explains the dry bean dataset used, the DL models employed, and the performance metrics for evaluation. Section 3 details each model’s training processes and provides a comprehensive analysis of the results. A detailed discussion is provided in Section 4, and finally, Section 5 presents the conclusions from the study.

MATERIAL AND METHODS

Figure 1 illustrates the overall workflow of the classification process for dry beans, detailing the steps involved in data preparation, feature extraction, model training, and evaluation. The process begins with collecting data from the Dry Bean Dataset, which includes 16 distinct features representing various physical characteristics of dry beans. These features provide crucial information on the shape, size, and structure of the beans. The next step in the process involves dividing the dataset into training and testing sets, followed by applying min-max scaling to normalize the features. This ensures that the varying ranges of feature values do not adversely affect the model’s performance. The workflow then proceeds to the model training phase, where three DL models-LSTM, GRU, and ConvLSTM1D-are trained on the dataset. After training, the models’ performance is evaluated using various performance metrics. The final stage of the workflow involves a comparative analysis of the models, with the aim of identifying the optimal architecture based on its classification performance. The more detailed information will be discussed in the following subsections.

Figure 1
Overall workflow of the classification process

Dry Bean Dataset

The dataset used in this study was previously released by Koklu and Ozkan [20] and is publicly available online at: https://archive.ics.uci.edu/ml/datasets/Dry+Bean+Dataset. The dataset comprises 16 distinct features, namely area, perimeter, major axis length, minor axis length, aspect ratio, eccentricity, convex area, equivalent diameter, extent, solidity, roundness, compactness, shape factor 1, shape factor 2, shape factor 3, and shape factor 4. These features provide information on the form, shape, type, and structure of the data. There are 13,611 dry bean samples in the dataset. More detailed information about dataset preparation can be found in Koklu and Ozkan [20]. Figure 2 illustrates the seven dry bean varieties employed in the study, for which Table 1 provides detailed characteristics and sample distribution information.

Table 1
Characteristics and sample distribution of dry bean varieties

Figure 2
Dry bean varieties used in the study

Classification Models

This study evaluates the performance of three deep learning models for the classification of dry bean varieties: LSTM, GRU, and ConvLSTM1D. LSTM and GRU are two types of Recurrent Neural Networks (RNNs) designed to learn from sequential data. They were chosen to assess how standard recurrent architectures process the 16 morphological features when treated as a sequence. ConvLSTM1D is a hybrid model that integrates 1D convolutional layers with an LSTM architecture. The key novelty of its application here is its ability to first perform feature extraction across the 16-feature vector to learn localized inter-feature relationships. This creates a more abstract and powerful feature representation before the temporal processing by the LSTM component. Our hypothesis is that this architectural design provides an inherent advantage in handling the dataset’s class imbalance without requiring explicit loss function modifications (e.g., focal loss) or class weighting. Therefore, no such techniques were used, allowing for a direct assessment of the model’s architectural merit. All models in this study were trained from scratch. The use of pre-trained weights was not applicable, as such weights are typically derived from large image or text corpora and are unsuited for the tabular, morphological feature data used in this research.

Classic feed-forward neural networks (FFNN) consider only the momentarily given data among the given input examples. But RNN consider not only momentarily given data but also all examples given on a timeline. This situation allows RNN’s to use all the experiences gained along the timeline. This network structure, which was given in Figure 3, is often preferred, especially for sequential data inputs [32]. For a time step, each node takes input from the previous node and utilizes this input as feedback. Each node generates a hidden situation and utilizes the hidden situation of the previous node during this stage. Those networks have been successfully trained with time series and non-time series data.

Figure 3
General structure of RNNs

CNNs are also popular DL models, especially with image data. However, they can process every piece of data that has a grid-like topology [33]. CNNs use kernels to extract hidden features from the input data. Their feature extraction capability can be used with many other models by using a CNN’s output as the input of another model. CNNs are designed to work with 2D data; however, ConvLSTM1D is a network that is designed to work with 1-dimensional data by combining the feature extraction capabilities of CNNs and the prediction capabilities of RNNs.

Long Short-Term Memory (LSTM)

The biggest disadvantage of RNN’s is its prolonged processing time. In this way, networks start to be ineffective at generating context with much earlier inputs. This situation is known as the “long-term dependency phenomenon”. Exploding and vanishing gradient problems are also seen in these types of networks. LSTM networks were developed by inserting memory neurons between layers to overcome these kinds of problems. The general structure of the LTSM network is shown in Figure 4.

Figure 4
LSTM cell model

Eqs. (1-8) show the long-term and short-term states and outputs of the structure given in Figure 4. The hidden state and output are “ht” and “ot”, respectively. “ht” is the hidden state for each “t” time, “W” refers to weight matrices (here, “Wxf”, “Wxi”, “Wxo”, and “Wxg” form the weight matrix of the input vector, and “WhF”, “Wh”, “Who”, and “Whg” are the weight matrices of the previous state), and “b” symbolizes bias. “F” is the activation function applied to each node along the neural network. Forgetting gate “ft” determines the part to be forgotten within long-term input data. Input gate “it” controls which part of “ct” should be added to long-term output. Also, the output gate “gt” determines which part of “ct” should be read and given to “ht” and “ot” output.

(1) h t = f W h h t - 1 + V h X t + b h
(2) o t = f W o h t + b o
(3) f t = σ W xf T . x t + W xf T . h t - 1 + b f
(4) i t = σ W x T i . x t + W h T i . h t - 1 + b i
(5) o t = σ W x T o . x t + W h T o . h t - 1 + b i
(6) g t = tanh W x T g . x t + W h T g . h t - 1 + b i
(7) c t = f t ⊗ c t - 1 + i t ⊗ c ˜ i t
(8) o t , h t = g t ⊗ tanh c t

Gated Recurrent Unit (GRU)

GRU has a similar structure to LSTM; however, it has a gating mechanism to forget some features. It also has fever parameters and a simpler structure than LSTM. Its equations are given in Eqs. (9-12). When Zt output is “1”, input gates are closed, and the forget gate is opened. The opposite happens when Zt is “0”. In this way, “t-1” data of previous time is always saved. The reset gate determines how to combine present and previous data intuitively, unlike LSTM, as explained before. The general structure of GRU is shown in Figure 5.

Figure 5
GRU cell model

(9) r t = σ W xr T . x t + W or T . o t - 1 + b r
(10) z t = σ W xz T . x t + W o T z . o t - 1 + b z
(11) o ˜ t = tanh W x o ˜ T . x t + W o o ˜ T . r t ⊗ o t - 1 + b o ˜
(12) o t = z t ⊗ o t - 1 + 1 - z t ⊗ o ˜ t

One-Dimensional Convolutional LSTM (ConvLSTM1D)

The ConvLSTM structure represents a variation of the traditional LSTM architecture. As an RNN-based model, it incorporates various components, such as gates and memory units, to capture time-dependent or sequential features within data. What sets ConvLSTM apart is its integration of convolutional layers, allowing it to leverage both temporal and spatial features simultaneously. This unique combination enhances its capability to discern intricate relationships within the data [34]. The convolutional operations embedded in ConvLSTM facilitate the extraction of spatial information, a characteristic inherent to CNNs. This integration enables the model to identify complex patterns and dependencies in both the temporal and spatial dimensions. Despite these convolutional elements, ConvLSTM maintains structural similarities with traditional LSTM, as illustrated in Figure 6.

Figure 6
ConvLSTM cell model

The functioning of the ConvLSTM structure closely parallels that of the LSTM, featuring a minor adjustment to its internal architecture. A lot of the processes that come in from cells are changed into convolutions (for example, 1D convolutions; this is why these layers are called ConvLSTM1D), and the different gates include both the current and previous output cell values. ConvLSTMs offer flexibility for various applications through variants tailored to different data structures: ConvLSTM1D, ConvLSTM2D, and ConvLSTM3D. These variants leverage distinct filter types to initiate operations, enabling them to effectively model spatial and temporal dependencies within their respective data domains [35]. The ConvLSTM operation can be mathematically expressed through Eqs. (13-17), where the symbol “*” signifies a convolution operation and “·” denotes the element-wise product.

(13) f t = logsig W f *x t *W hf * + h t - 1 + W cf . c t - 1 + b f
(14) i t = logsig ( W f *x t *W hi * + h t - 1 + W ci . c t - 1 + b i
(15) o t = logsig W o *x t *W ho U o * + h t - 1 + W co . c t - 1 + b o
(16) c t = f t . c t - 1 + i t . tanh W c *x t + W hc *h t - 1 + b c
(17) h t = o t . tanh c t

It is crucial to emphasize that while the LSTM and ConvLSTM equations share notable similarities, ConvLSTMs boast a significant advantage in terms of processing speed when put into practice [34]. Furthermore, in contrast to LSTM, the operations of the three gate mechanisms have been expanded from one-dimensional to multidimensional convolution [35].

Performance Evaluation

The dataset used in this study consists of 16 features, each with a distinct range. To address potential discrepancies arising from these varying feature scales, a min-max scaling technique was applied. This normalization process ensures that the different ranges of features do not adversely affect the performance of DL models. To evaluate the generalization ability of the proposed models, a 10-fold cross-validation approach was employed. Crucially, a stratified splitting strategy was used during this process. Stratification ensures that for each of the 10 folds, the distribution of the seven bean classes in the training and testing subsets is preserved, mirroring the natural class imbalance of the original dataset. This approach provides a robust and comprehensive reflection of the model’s performance across the entire dataset by preventing any single fold from being biased by an unrepresentative class distribution. The final confusion matrix for each model was created by aggregating the predictions from the test set of all 10 folds.

It is important to note that no data augmentation techniques were applied in this study. This was a deliberate methodological choice. The dataset consists of 16 pre-extracted morphological features (i.e., tabular data), which renders standard image augmentation techniques inapplicable. While tabular augmentation methods such as the Synthetic Minority Over-sampling Technique (SMOTE) were considered, they were intentionally excluded. The primary objective of this research was to assess the inherent architectural capabilities of the DL models-particularly the hybrid ConvLSTM1D-to handle the natural, unaltered class imbalance present in the dataset without any data-level manipulation. This approach allows for a direct evaluation of the model’s robustness and architectural design in a realistic scenario.

The success of the classification systems is measured by calculating the correct prediction rate, which is known as accuracy. However, it is not an accurate metric alone for multiclass classification because it disregards the effect of class balance and the model performance on each different class. Dominant and easily predictable classes may increase the accuracy of models. In this case, precision and recall metrics for each class are useful to identify model performance in each class. Precision measures the rate of true positive predictions among positive predictions. Recall measures the ability to identify all samples of a specific class. The macro-average of precision and recall for multi-class classification is also a good metric to evaluate the overall model performance. It gives equal weight to all classes. Another useful metric to consider recall and precision together is the f-score, which is the harmonic mean of precision and recall. The following equations were employed to calculate accuracy, precision, recall, and f-score.

(18) Accuracy = TP + TN TP + TN + FP + FN
(19) Precision = TP TP + FP
(20) Recall = TP TP + FN
(21) F - score = 2 x Precision x Recall Precision + Recall

For a detailed analysis, a graphical analysis method named receiver operating characteristic (ROC) is also used. It is especially essential for multi-class classification studies. ROC curves are created using true positive rates and false positive rates, and they summarize the behavior of the model. The area under the ROC curve (AUC) can be calculated, and a unique score can be obtained to compare model performances. Ideally, an AUC of 1 indicates perfect classifier performance. Nonetheless, any score above 0.5 signifies good performance, with 0.5 denoting a lack of skill and a score below 0.5 indicating unacceptable performance.

All experiments were conducted on a unified hardware and software platform. The system was equipped with an Intel Core i5-13620H processor, 24 GB of RAM, and an NVIDIA GeForce GTX 1650 GPU. The models were developed within a software environment consisting of the Ubuntu 20.04 LTS operating system, Python version 3.12, and the Keras framework (version 2.12) with its TensorFlow backend. The average training duration for a single model across the complete 10-fold cross-validation process was approximately 8 hours.

RESULTS

This section presents an experimental procedure conducted to assess the classification accuracy of three DL models, such as LSTM, GRU, and ConvLSTM1D. The evaluation of DL models was analyzed in terms of performance metrics, including accuracy, recall, precision, f-score, and ROC curves. Additionally, a comparative discussion with relevant literature is presented towards the conclusion of this section.

To ensure a fair and direct comparison, a consistent set of hyperparameters and a standardized architecture were applied across all three models. Each model was constructed with two main layers, followed by a final SoftMax output layer for multi-class classification. A configuration of 200 neurons per layer was selected. This choice was based on a series of preliminary empirical evaluations which determined that this architecture provided the optimal balance between model complexity and generalization. Simpler models tended to underfit, while more complex ones were prone to overfitting, even with regularization. All models were trained for 500 epochs with a batch size of 50. The Adam optimizer was used with a learning rate of 0.01. A dropout layer with a rate of 0.2 was applied after each of the two main layers in every model to mitigate overfitting. Early stopping was not utilized, as the dropout regularization proved sufficient for model convergence without significant overfitting, as demonstrated in the training and validation performance curves.

The confusion matrices for each model are given in Tables 2-4. Each table displays the number of correctly and incorrectly classified instances for each bean type. The rows represent the actual classes of the beans, while the columns represent the classes predicted by the model. The diagonal elements represent the number of correctly classified instances, while the off-diagonal elements represent the number of misclassifications. The confusion matrix in Table 2 illustrates the performance of the LSTM model. It is observed that the LSTM model achieves perfect accuracy for the Bombay class, with zero misclassifications. However, some misclassifications are evident for other varieties. For instance, Barbunya shows a significant number of misclassifications into Cali (66 instances) and Sira (24 instances), indicating potential confusion between these visually similar bean types. Similarly, Dermason displays a considerable number of misclassifications into Sira (196 instances), suggesting a challenge in distinguishing these two varieties for the LSTM model. The relatively high off-diagonal values for several classes highlight areas where the LSTM model struggles with accurate classification.

Table 2
Confusion matrix of LSTM
Table 3
Confusion matrix of GRU

Table 3 presents the confusion matrix for the GRU model. The GRU model also shows perfect prediction for the BOMBAY class, with zero misclassifications. Compared to LSTM, the GRU model has a slightly higher number of misclassifications for the Cali and Dermason classes. For example, 72 samples of Barbunya are misclassified as Cali, and 30 samples of Dermason are misclassified as Barbunya. The performance of GRU on the Sira variety remains low, with 243 samples misclassified as Dermason. This indicates that GRU struggles similarly to LSTM in distinguishing these classes, due to shared morphological features in the dataset. The GRU model demonstrates comparable accuracy to the LSTM but with a few more misclassifications, suggesting that LSTM may have a slight edge in terms of robustness.

Table 4
Confusion matrix of ConvLSTM1D

Table 4 depicts the confusion matrix for the ConvLSTM1D model. The ConvLSTM1D model’s confusion matrix reveals a generally improved performance compared to the LSTM and GRU models. While Bombay again shows perfect classification, the number of misclassifications for other varieties is lower than in the previous two tables. Although some misclassifications remain (e.g., Barbunya into Cali and Sira, Dermason into Sira), the overall pattern indicates a more accurate classification capability. The lower off-diagonal values suggest that the ConvLSTM1D model is better at distinguishing between the visually similar bean types. The reduction in misclassifications across several classes demonstrates the effectiveness of the ConvLSTM1D architecture in this specific classification task.

The accuracies for each model are given in Table 5. As seen, the prediction accuracy of Bombay for three models is 1, which means it is predicted to be 100% correct. Sira has the lowest accuracy of all models; it is 95.04% for LSTM, 95.06% for GRU, and 95.26% for ConvLSTM1D. The accuracy of Dermason and Sira is low based on confusion matrices and accuracy metrics, while other classes predict with a high accuracy of about 98%. All models have successful prediction rates based on accuracy. However, for an imbalanced dataset, class accuracy may be misleading, and macro-average accuracy must be examined. The macro-averages of all used metrics for each model are given on the avg. row in Table 5. The best accuracy score belongs to ConvLSTM1D with a rate of 93.78%, and the lowest accuracy score belongs to GRU with a rate of 93.48%.

Table 5
Accuracy scores of the models

However, because the data set is imbalanced and has multiple classes, evaluation with accuracy is not enough. Therefore, precision, recall, and f-score metrics are used for comparison. Table 6 provides precision scores for each model and class, along with macro-averages for each model. Bombay was predicted to be 100% successful by all models. Barbunya and Sira exhibited precision scores below 90%, while all other classes demonstrated higher precision scores. In terms of macro-averages for precision scores, ConvLSMT1D achieved the highest rate at 93.65%, while the GRU model recorded the lowest score at 93.32%.

Table 6
Precision scores of the models

According to recall values (Table 7), the best success rate for classification belongs to the Bombay type bean classification, with a 100% success rate for all three models. The recall value of Sira is 87.06%, and the recall value for all other classes is above 90%. The macro-average of recall values shows that the best model is ConvLSTM1D, with a 93.78% score. LSTM and GRU models have 93.48% and 93.56% recall rates, respectively.

Table 7
Recall scores of the models

The f-score given in Table 8 helps us evaluate precision and recall together. The most successfully classified class is Bombay, with a 100% f-score for all three models. ConvLSTM1D has the best f-scores; only the score of Sira is below 90% with 87.65%. The rest of the classes have a score higher than 90%. The macro-average f-score of ConvLSTM1D is 93.70%, and it is the best score among models. LSTM has similar performance but a lower f-score of 93.36%. The GRU model has two classes, Barbunya and Sira, with a f-score below 90%. Its average is also the lowest, at 93.36%.

Table 8
F-scores of the models

To visualize the learning dynamics and confirm model convergence across the 10-fold cross-validation process, the training and validation accuracy and loss curves for each fold are presented in Figure 7. As shown in the plots, all models demonstrate successful convergence. For each fold, the accuracy curves steadily increase and then plateau, while the loss curves consistently decrease towards a minimal value. The close proximity between the training curves for each respective fold is a key finding; it indicates that the dropout regularization was effective in mitigating overfitting and ensuring good generalization across the dataset.

Figure 7
Training accuracy and loss curves for (a) ConvLSTM1D, (b) GRU, and (c) LSTM models over 500 epochs

The ROC curves given in Figure 8 represent the model performance for each class of the proposed models. As seen, the best predicted class is Bombay, with a 1 AUC value for all models. Also, it is obvious that all models have good AUC values and good prediction performances. Macro-average AUC values are calculated and given in Table 9 for overall comparison. The best AUC score is 0.9953 for ConvLSTM1D. The LSTM and GRU models have the same score of 0.9947. According to ROC curves and AUC scores, the best model is ConvLSTM1D.

Table 9
Macro-averages of AUC values of ROC curves

Figure 8
Class-based ROC curves of (a) ConLSTM1D, (b) GRU, and (c) LSTM

As a last comparison, boxplots are used to compare the results of all folds for all metrics. Although we examined the whole set of metrics based on classes and macro-averages, boxplots represent some valuable statistical results we need to consider. Boxplots of the proposed models are given in Figure 9. All plots use the results of each fold of 10-k cross-validation. During cross-validation, train and test sets are selected randomly, and 10 different train and test sets are created. Performance and behavior of the model can be changed depending on the selected train and test data set because of the distribution of data. A good model must show similar performances for all folds; thus, we can say that the model can learn the dataset properly and accurately.

Figure 9
Cross-validation metrics distribution for DL model performance evaluation

As seen in Figure 9, the highest median values of 10-fold belong to the ConvLSTM1D model for precision, recall, and f-score. It also has the shortest range between the minimum and maximum values of related metrics. LSTM has the lowest median for precision, while GRU has the lowest median for recall score. They have about the same median for f-score. In addition, for recall and f-score, GRU has outliers that mean its’ results have not proper distribution, and it indicates some issues about the model’s learning performance in some folds. On the other hand, LSTM has no outliers; however, it has the widest range of minimum and maximum values of all metrics. So, its performance changes most depending on the selected train and test data. Based on this comparison graph, the most reliable and robust model is ConvLSTM1D.

DISCUSSION

The results obtained in this study highlight the effectiveness of the ConvLSTM1D model in classifying dry bean varieties. This model outperformed the LSTM and GRU models in all evaluated performance metrics, achieving the highest accuracy (93.78%) and demonstrating superior precision, recall, and f-score values (Table 5). This performance difference can be attributed to their fundamental architectural distinctions. The standard LSTM and GRU models process the 16 morphological features as a simple one-dimensional sequence. This approach may not effectively capture complex, non-sequential interactions between features. For instance, a critical diagnostic pattern might rely on a relationship between ‘Area’ (feature 1) and ‘Shape Factor 3’ (feature 15), which are far apart in the sequence. In contrast, the ConvLSTM1D model first applies 1D convolutional filters across the feature vector. These filters act as powerful, localized pattern detectors, learning to identify salient combinations of features regardless of their position. This creates a richer, more discriminative set of higher-level features before the data is passed to the LSTM component, providing a clear advantage in classification.

Interestingly, while all models achieved perfect accuracy for the distinct ‘Bombay’ variety, the ‘Sira’ variety consistently posed the greatest challenge. This difficulty is directly linked to its morphological characteristics. As shown in Table 1, the description for ‘Sira’ is “Flattened, one end flat, other rounded,” which is identical to the description for ‘Dermason.’ This high degree of similarity in the core morphological features likely causes confusion for the models, leading to the higher misclassification rates observed for ‘Sira’ across all three architectures. This highlights a limitation of feature-based classification when distinct classes share highly similar quantitative descriptors.

The analysis of ROC curves (Figure 8) and the AUC scores further supports the superiority of the ConvLSTM1D model, which achieved the highest macro-average AUC score of 0.9953 (Table 9). This indicates that the ConvLSTM1D model not only achieved high classification accuracy but also maintained high performance across all classes, making it the most reliable model in this study. In contrast, the LSTM and GRU models exhibited slightly lower AUC scores, reflecting their reduced ability to generalize across the entire dataset.

When compared to previous studies, this research achieves a notable improvement in classification accuracy for the imbalanced Dry Bean Dataset. For example, while the SVM model used by Koklu and Ozkan [20] achieved an accuracy of 93.13%, other recent studies utilizing ensemble methods like XGBoost [21] and techniques such as ELM [24] reported accuracies of 93% and 91.43%, respectively (Table 10). The improved performance of ConvLSTM1D underscores the benefits of combining CNN and RNN structures, particularly in contexts where spatial and sequential patterns must be learned simultaneously. The improvement achieved by ConvLSTM1D (93.78%) signifies a considerable advancement in dry bean classification accuracy. This improvement is particularly noteworthy given the inherent class imbalance present in the dataset (Table 1), where the number of samples per variety varies significantly. The ConvLSTM1D model’s success in handling this imbalance without the need for resampling techniques underscores its robustness and potential for real-world applications.

Table 10
Comparison of various studies on imbalanced Dry Bean Dataset

Despite the promising results, several limitations must be addressed. First, the dataset’s imbalanced nature, while mitigated by the ConvLSTM1D model, still poses a challenge for accurately classifying minority classes like Sira. Future work could explore techniques such as synthetic data generation or the application of more advanced oversampling methods to improve classification accuracy for underrepresented classes. Additionally, the morphological features extracted from 2D images may not fully capture the complexity of dry bean varieties. Incorporating 3D imaging techniques could provide more detailed shape and texture information, potentially improving model performance further.

CONCLUSION

This study investigated the efficacy of three DL models-LSTM, GRU, and ConvLSTM1D-for classifying dry bean varieties. The results quantitatively demonstrate the superiority of the ConvLSTM1D architecture. With an accuracy of 93.78%, the ConvLSTM1D model not only outperformed the standard recurrent LSTM (93.56%) and GRU (93.48%) models but also established a new state-of-the-art benchmark for this publicly available dataset, exceeding previously reported accuracies from leading methods such as SVM (93.13%) and XGBoost (93%). While all three models achieved high accuracy, exceeding 90% in most cases, the ConvLSTM1D model exhibited a significantly lower number of misclassifications, particularly in distinguishing between visually similar bean types. The integration of convolutional layers within its architecture provided a significant advantage in feature extraction, addressing the class imbalance without the need for resampling techniques. This research highlights the potential of ConvLSTM1D as a reliable and accurate method for automated dry bean classification, contributing to improved efficiency and precision in agricultural practices. Looking ahead, future research could explore several promising directions to build upon these results. The integration of hybrid attention mechanisms with the ConvLSTM1D model could allow it to dynamically focus on the most discriminative morphological features, potentially improving accuracy for challenging classes. Furthermore, the application of transformer-based architectures, which excel at capturing global dependencies within data, may offer a powerful alternative. Finally, to specifically address the challenge of minority classes, future work could employ few-shot learning techniques to enhance the model’s ability to generalize from the limited samples of underrepresented varieties like ‘Sira’, thereby advancing the robustness of classification systems for real-world, imbalanced agricultural datasets.

Funding:

This research received no external funding.

Data Availability Statement:

Research data are available in the body of the manuscript.

REFERENCES

  • 1 Hooper SD, Glahn RP, Cichy KA. Single varietal dry bean (Phaseolus vulgaris L.) pastas: nutritional profile and consumer acceptability. Plant Foods Hum Nutr. 2019 Sep;74(3):342-9.
  • 2 Sankaran S, Quirós JJ, Miklas PN. Unmanned aerial system and satellite-based high resolution imagery for high-throughput phenotyping in dry bean. Comput Electron Agric. 2019 Oct;165:104965.
  • 3 Berry M, Izquierdo P, Jeffery H, Shaw S, Nchimbi-Msolla S, Cichy K. QTL analysis of cooking time and quality traits in dry bean (Phaseolus vulgaris L.). Theor Appl Genet. 2020 Jul;133(7):2291-305.
  • 4 Bai Q, Li M, Zhou J, Imran A, de Souza TSP, Barrow C, et al Influence of processing methods on phytochemical composition of different varieties of beans (Phaseolus vulgaris). Food Rev Int. 2024 Oct;40(7):1941-79.
  • 5 Celmeli T, Sari H, Canci H, Sari D, Adak A, Eker T, et al The nutritional content of common bean (Phaseolus vulgaris L.) landraces in comparison to modern varieties. Agronomy. 2018 Sep;8(9):166.
  • 6 Landi N, Alberico L, Clemente A, Peddio S, Hussain HafizaZF, Ragucci S, et al Nutritional, metabolic and genetic profiling of ‘Cerato’ and ‘Curniciello’ bean landraces from Caserta, Southern Italy. Food Biosci. 2023 Oct;55:102975.
  • 7 Kwak M, Gepts P. Structure of genetic diversity in the two major gene pools of common bean (Phaseolus vulgaris L., Fabaceae). Theor Appl Genet. 2009 Mar;118(5):979-92.
  • 8 Mamidi S, Rossi M, Moghaddam SM, Annam D, Lee R, Papa R, et al Demographic factors shaped diversity in the two gene pools of wild common bean Phaseolus vulgaris L. Heredity. 2013 Mar;110(3):267-76.
  • 9 TTSM. Milli Çeşit Listesi (Tarla Bitkisi Çeşitleri) (Field Crops) [Internet]. 2021 [cited 2024 May 30]. Available from: https://www.tarimorman.gov.tr/BUGEM/TTSM/Sayfalar/Detay.aspx?SayfaId=85
    » https://www.tarimorman.gov.tr/BUGEM/TTSM/Sayfalar/Detay.aspx?SayfaId=85
  • 10 TSE (Turkish Standards Institution). Dry Beans (Kuru Fasulye) [Internet]. 2009 [cited 2024 May 30]. Available from: https://www.resmigazete.gov.tr/eskiler/2009/10/20091010-9.htm
    » https://www.resmigazete.gov.tr/eskiler/2009/10/20091010-9.htm
  • 11 FAOSTAT (Crop Statistics). The Food and Agriculture Organization of the United Nations, Rome (FAO) [Internet]. 2022 [cited 2024 May 30]. Available from: https://www.fao.org/faostat/en/#data/QCL
    » https://www.fao.org/faostat/en/#data/QCL
  • 12 Beaver JS, Osorno JM. Achievements and limitations of contemporary common bean breeding using conventional and molecular approaches. Euphytica. 2009 Jul;168(2):145-75.
  • 13 Sankaran S, Zhou J, Khot LR, Trapp JJ, Mndolwa E, Miklas PN. High-throughput field phenotyping in dry bean using small unmanned aerial vehicle based multispectral imagery. Comput Electron Agric. 2018 Aug;151:84-92.
  • 14 Miklas PN, Kelly JD, Cichy KA. Dry bean breeding and production technologies. In: Siddiq M, Uebersax MA, editors. Dry beans and pulses: production, processing, and nutrition. Hoboken, NJ: John Wiley & Sons, Ltd; 2022. p. 29-56.
  • 15 Kılıç K, Boyacı İH, Köksel H, Küsmenoğlu İ. A classification system for beans using computer vision system and artificial neural networks. J Food Eng. 2007 Feb;78(3):897-904.
  • 16 Chen X, Xun Y, Li W, Zhang J. Combining discriminant analysis and neural networks for corn variety identification. Comput Electron Agric. 2010 Apr;71:S48-53.
  • 17 Mollazade K, Omid M, Arefi A. Comparing data mining classifiers for grading raisins based on visual features. Comput Electron Agric. 2012 Jun;84:124-31.
  • 18 Teimouri N, Omid M, Mollazade K, Rajabipour A. An artificial neural network-based method to identify five classes of almond according to visual features. J Food Process Eng. 2016;39(6):625-35.
  • 19 Çifci A, Kırbaş İ. Fusion of machine learning and explainable AI for enhanced rice classification: a case study on Cammeo and Osmancik species. Eur Food Res Technol. 2025;251(1):69-86.
  • 20 Koklu M, Ozkan IA. Multiclass classification of dry beans using computer vision and machine learning techniques. Comput Electron Agric. 2020 Jul;174:105507.
  • 21 Salauddin Khan M, Nath TD, Murad Hossain M, Mukherjee A, Bin Hasnath H, Manhaz Meem T, et al. Comparison of multiclass classification techniques using dry bean dataset. Int J Cogn Comput Eng. 2023 Jun;4:6-20.
  • 22 Gündüz R, Bingol MC, Bişkin OT. Yapay zeka temelli bazı nar hastalıklarının tahmini. Turk J Agric Food Sci Technol. 2025;13(4):946-957.
  • 23 Zhang C, Zhao Y, Yan T, Bai X, Xiao Q, Gao P, et al Application of near-infrared hyperspectral imaging for variety identification of coated maize kernels with deep learning. Infrared Phys Technol. 2020 Dec;111:103550.
  • 24 Dogan M, Taspinar YS, Cinar I, Kursun R, Ozkan IA, Koklu M. Dry bean cultivars classification using deep CNN features and salp swarm algorithm based extreme learning machine. Comput Electron Agric. 2023 Jan;204:107575.
  • 25 Gulzar Y. Enhancing soybean classification with modified inception model: a transfer learning approach. Emir J Food Agric. 2024;36:1-9.
  • 26 Alkanan M, Gulzar Y. Enhanced corn seed disease classification: leveraging MobileNetV2 with feature augmentation and transfer learning. Front Appl Math Stat. 2024;9:1320177.
  • 27 Huong PT, Hien LT, Son NM, Tuan HC, Nguyen TQ. Enhancing deep convolutional neural network models for orange quality classification using MobileNetV2 and data augmentation techniques. J Algorithms Comput Technol. 2025;19:17483026241309070.
  • 28 Korkmaz A, Talan T, Koşunalp S, Iliev T. Comparison of deep learning models in automatic classification of coffee bean species. PeerJ Comput Sci. 2025;11:e2759.
  • 29 Mengstu MT, Taner A. Harnessing deep learning for wheat variety classification: a convolutional neural network and transfer learning approach. J Sci Food Agric. 2025.
  • 30 Gulzar Y, Ünal Z, Ayoub S, Reegu FA. Exploring transfer learning for enhanced seed classification: pre-trained Xception model. In: Cavallo E, Cheein FA, Marinello F, Saçılık K, Muthukumarappan K, Abhilash PC, editors. Proceedings of the 15th International Congress on Agricultural Mechanization and Energy in Agriculture; 2023 Oct 29-Nov 1; Antalya (Türkiye): Springer; 2023. p. 137-147.
  • 31 Gulzar Y, Ünal Z. Optimizing pear leaf disease detection through PL-DenseNet. Appl Fruit Sci. 2025;67(1):40.
  • 32 Oualil Y, Greenberg C, Singh M, Klakow D. Sequential recurrent neural networks for language modeling [Internet]. arXiv; 2017 [cited 2024 Jul 11]. Available from: http://arxiv.org/abs/1703.08068
    » http://arxiv.org/abs/1703.08068
  • 33 Khan A, Sohail A, Zahoora U, Qureshi AS. A survey of the recent architectures of deep convolutional neural networks. Artif Intell Rev. 2020 Dec;53(8):5455-516.
  • 34 Cantillo-Luna S, Moreno-Chuquen R, Celeita D, Anders G. Deep and machine learning models to forecast photovoltaic power generation. Energies. 2S023 Jan;16(10):4097.
  • 35 Mohammad F, Ahmed MA, Kim YC. Efficient energy management based on convolutional long short-term memory network for smart power distribution system. Energies. 2021 Jan;14(19):6161.
  • 36 Hasan MdM, Islam MU, Sadeq MJ. A deep neural network for multi-class dry beans classification. In: 24th International Conference on Computer and Information Technology (ICCIT); 2021 Dec 18-20; Dhaka (Bangladesh): IEEE; 2021. p. 1-5.
  • 37 Słowiński G. Dry beans classification using machine learning. In: 29th international Workshop on Concurrency, Specification and Programming (CS&P’21); 2021 Sep 27-28; Berlin (Germany): CEUR Workshop Proceedings; 2021. p. 120-5.
  • 38 Mendigoria CH, Concepcion R, Dadios E, Aquino H, Alaias OJ, Sybingco E, et al. Seed architectural phenes prediction and variety classification of dry beans (Phaseolus vulgaris) using machine learning algorithms. In: IEEE 9th Region 10 Humanitarian Technology Conference (R10-HTC); 2021 Sep 30-Oct 02; Bangalore (India): IEEE; 2021. p. 01-6.
  • 39 Shahoveisi F, Riahi Manesh M, del Río Mendoza LE. Modeling risk of Sclerotinia sclerotiorum-induced disease development on canola and dry bean using machine learning algorithms. Sci Rep. 2022 Jan;12(1):864.
  • 40 Shobana G, Bushra SN, Maheswari KU, Subramanian N. Multivariate classification of dry beans using pipelined dimensionality reduction technique. In: International Conference on Innovative Computing, Intelligent Communication and Smart Electrical Systems (ICSES); 2022 Jul 15-16; Chennai (India): IEEE; 2022. p. 1-6.
  • 41 Fontenla-Romero O, Guijarro-Berdiñas B, Hernández-Pereira E, Pérez-Sánchez B. FedHEONN: federated and homomorphically encrypted learning method for one-layer neural networks. Future Gener Comput Syst. 2023 Dec;149:200-11.
  • 42 Krishnan S, Aruna SK, Kanagarathinam K, Venugopal E. Identification of dry bean varieties based on multiple attributes using CatBoost machine learning algorithm. Sci Program. 2023;2023(1):2556066.
  • 43 Tigga O, Pal J, Mustafi D. Performance analysis of machine learning algorithms for data classification. AIP Conf Proc. 2024 May;3164(1):030001.
  • 44 Yasar A. Identification of dry bean seeds using PSO feature selection technique. In: 59th International Scientific Conference on Information, Communication and Energy Systems and Technologies (ICEST); 2024 Jul 01-03; Sozopol (Bulgaria): IEEE; 2024. p. 1-4.
  • 45 Aldossary M, Alharbi HA, Anwar Ul Hassan C. Internet of Things (IoT)-enabled machine learning models for efficient monitoring of smart agriculture. IEEE Access. 2024;12:75718-34.

Editor-in-Chief:

Alexandre Rasi Aoki

Associate Editor:

Alexandre Rasi Aoki

*

Correspondence: acifci@mehmetakif.edu.tr Tel.: +90-248-2132777 (A. Ç.).

Conflicts of Interest:

The authors declare no conflict of interest.

Publication Dates

  • Publication in this collection
    19 Dec 2025
  • Date of issue
    2025

History

  • Received
    19 Dec 2024
  • Accepted
    18 Oct 2025
location_on
Instituto de Tecnologia do Paraná - Tecpar Rua Prof. Algacyr Munhoz Mader, 3775 - CIC, 81350-010 , Tel: +55 41 3316-3054 - Curitiba - PR - Brazil
E-mail: babt@tecpar.br
rss_feed Acompanhe os números deste periódico no seu leitor de RSS
Ir para o topo