This repository contains a machine learning model for predicting DON (Deoxynivalenol or vomitoxin) concentration in corn samples using spectral reflectance data.
This project analyzes spectral reflectance data from corn samples to predict DON concentration levels. The model uses a Convolutional Neural Network (CNN) architecture to process spectral data and predict contamination levels.
main.ipynb: Jupyter notebook containing the complete analysis pipelinedataset.csv: Dataset with spectral reflectance values and DON concentration measurementsmodel_cnn.keras: Saved trained CNN modelscaler.pkl: Saved StandardScaler object for preprocessing new data
-
Clone this repository:
git clone https://github.com/arnnv/Corn-DON-Concentration-Prediction.git cd Corn-DON-Concentration-Prediction -
Create and activate a virtual environment (recommended):
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate -
Install required packages:
pip install -r requirements.txt
-
Launch Jupyter Notebook:
jupyter notebook -
Open and run
main.ipynb
The notebook is structured to:
- Load and preprocess the spectral data
- Perform exploratory data analysis
- Transform the target variable
- Build and train a CNN model
- Evaluate model performance
- Save the model for future use
To use the saved model for predictions on new data:
import numpy as np
import joblib
from tensorflow.keras.models import load_model
# Load the saved model and scaler
model = load_model('model_cnn.keras')
scaler = joblib.load('scaler.pkl')
# Preprocess new data (replace X_new with your new spectral data)
X_new_scaled = scaler.transform(X_new)
X_new_reshaped = X_new_scaled.reshape(X_new_scaled.shape[0], X_new_scaled.shape[1], 1)
# Make predictions
predictions = model.predict(X_new_reshaped)