Authors: Joanna Dagil, Liliana Grześkiewicz, Piotr Szpatusko and Adam Włodarski
University coursework project for the Data Analysis Methods course. The project compares several multiclass classification methods (Multinomial logistic regression, Random Forest, Neural Network, Hybrid voting ensemble) for recognizing seven dry bean varieties from geometric and morphological features extracted from seed images.
The analysis uses the Dry Bean Dataset, which contains 13,611 observations of dry bean grains belonging to seven classes (BARBUNYA, BOMBAY, CALI, DERMASON, HOROZ, SEKER, SIRA)
Each grain is described by measurements obtained through computer vision. The project focuses on 12 selected predictors describing bean size, shape, and proportions: Area, Perimeter, MajorAxisLength, MinorAxisLength, ConvexArea, EquivDiameter, Eccentricity, Roundness, Compactness, Solidity, AspectRation, Extent.
The goal is to evaluate how well these features can distinguish bean varieties and to compare classical statistical modeling with machine learning approaches.
The workflow includes:
- Loading the Dry Bean dataset from the ARFF file.
- Selecting 12 geometric and morphological features.
- Exploring distributions, class proportions, descriptive statistics, and correlations.
- Applying logarithmic transformations to highly skewed variables.
- Detecting outliers using the IQR rule and Mahalanobis distance.
- Standardizing numeric predictors.
- Creating a stratified 70/30 train-test split with seed
42. - Training and evaluating four classifiers:
- Multinomial logistic regression
- Random Forest
- Multilayer Perceptron neural network
- Hybrid voting ensemble combining the three models above
Model quality is evaluated with confusion matrices, overall accuracy, precision, recall, and F1-score for each bean class.
The generated report compares the models on the same test set:
| Model | Accuracy |
|---|---|
| Multinomial logistic regression | 0.9538 |
| Random Forest | 0.9421 |
| Neural network | 0.9530 |
| Hybrid voting ensemble | 0.9536 |
All models achieved strong classification performance. The best individual result was obtained by multinomial logistic regression, while the hybrid ensemble produced a very similar result and helped correct some individual model errors in the synthetic-observation example.
The Random Forest model also provides feature importance estimates. In the generated results, shape-related variables such as roundness, Compactness, and Eccentricity are among the most informative predictors.
The project also includes a demonstration of model usage on artificially generated observations. For each bean class, two synthetic examples are created near the class center in the standardized training space. These examples are then classified by all three base models and the hybrid voting ensemble.
This section is intended as a practical prediction example, not as an additional validation benchmark, because the synthetic observations are generated from the training-set statistics.
.
|-- data/
| |-- Dry_Bean_Dataset.arff
| |-- Dry_Bean_Dataset.txt
| `-- Dry_Bean_Dataset.xlsx
|-- report/
| |-- main.tex
| |-- main.pdf
| |-- wyniki_regresja_logistyczna.tex
| |-- wyniki_random_forest.tex
| |-- wyniki_siec_neuronowa.tex
| |-- wyniki_hybrydowe.tex
| |-- wyniki_sztuczne_dane.tex
| `-- porownanie_dokladnosci.tex
|-- main.R
|-- README.md
`-- .gitignore
The analysis is written in R. Required R packages:
install.packages(c(
"moments",
"knitr",
"dplyr",
"ggplot2",
"nnet",
"randomForest"
))To rebuild the PDF report from LaTeX, a LaTeX distribution such as TeX Live or MiKTeX is also required.
From the project root, run:
source("main.R")The script reads data/Dry_Bean_Dataset.arff, trains the models, evaluates them, and writes generated LaTeX tables and plots into the report/ directory.
The final report (in polish) is available at:
report/main.pdf
Koklu, M. and Ozkan, I. A. (2020). Multiclass Classification of Dry Beans Using Computer Vision and Machine Learning Techniques. Computers and Electronics in Agriculture, 174, 105507.
DOI: https://doi.org/10.1016/j.compag.2020.105507