YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Honey Sugar Rate Predictor (FTIR-Based)

A hybrid machine learning project for predicting sugar content in honey samples using FTIR (Infrared Spectroscopy) data.

This model combines deep learning with classical chemometrics to remain stable and meaningful even on small datasets. The goal is not just prediction, but chemically sensible prediction.


Project Overview

  • Input: Raw FTIR spectra (4000–650 cm⁻¹)
  • Target: Sugar rate (%) in honey samples
  • Dataset Size: 65 samples
  • Special Focus: Robust performance at low sugar concentrations (10–20%), where most models collapse

Architecture

Hybrid Model

The system blends two complementary approaches:

  • Triple-Scale 1D CNN
    • Captures fine, medium, and broad spectral features
    • Especially effective for subtle peak variations
  • PLS Regression
    • Provides chemically interpretable latent structure
    • Stabilizes learning on small datasets

The outputs of both models are fused using an optimized nonlinear calibration function.


Spectral Preprocessing

  1. Crop to the Golden Region
    1366–768 cm⁻¹
  2. Apply 2nd derivative transformation
    • Enhances weak spectral features
    • Reduces baseline drift and noise

Smart Calibration (Differential Evolution)

Instead of manually tuning coefficients, Differential Evolution was used to evolve the optimal calibration equation.

Why?

  • Avoids arbitrary scaling constants
  • Learns nonlinear relationships automatically
  • Improves generalization on small datasets

“Brave Mode” Training Strategy

Low sugar concentrations produce weak FTIR signals.
Most models respond by predicting near-zero values.

This project modifies the fitness function to:

  • Penalize underestimation in low-signal regions
  • Encourage meaningful predictions instead of collapse

Result: significantly better performance in the 10–20% sugar range.


Final Prediction Formula

Base Combination

[ \text{Base} = (-0.1366 \cdot CNN_{raw}) + (0.7579 \cdot PLS_{raw}) ]

Golden Formula

[ y = 29.96 \cdot Base^{0.49} - 32.86 \cdot \ln(Base + 1) - 5.19 ]

Where:

  • CNN_raw = raw CNN output
  • PLS_raw = raw PLS output
  • y = predicted sugar percentage

Performance

Metric Value
Correlation (R) 0.9074
MAE ~5.17%
Samples 65

Given the dataset size, performance is strong and trend-following.


Files

  • honey_regression_model.keras
    Trained CNN model

  • honey_pls_component.pkl
    PLS regression component

  • inference.py
    Lightweight script for running predictions


Usage

  1. Load raw FTIR spectrum
  2. Crop to 1366–768 cm⁻¹
  3. Apply 2nd derivative preprocessing
  4. Run CNN + PLS inference
  5. Apply the Golden Formula for final prediction

License

MIT License

Free to use, modify, and build upon.


Author

Developed by a chemistry student
With assistance from some AI tools

Downloads last month
5
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support