Python Project
Non-Invasive Blood Glucose Prediction Using
Machine Learning and Microstrip Patch
Antenna Data
A Machine Learning-Based Approach for Glucose
Monitoring
Mohamed Arshadh I
Abstract
This project aims to develop a non-invasive blood glucose monitoring
system using a microstrip patch antenna and machine learning.
By analyzing RF S-parameter variations, a predictive model is trained
to estimate glucose levels accurately.
This approach provides a pain-free alternative to traditional
glucose monitoring methods.
Problem Statement
Traditional blood glucose monitoring methods are
invasive and painful, requiring frequent finger pricks.
This project explores a machine learning-based approach
using RF signals to estimate glucose levels non-invasively.
Existing systems
S.NO Year Title Methodology Outcome Limitations
[1] 2020 Antenna as sensor to measure diabetes Designed an antenna sensor to Successfully measured Limited real-world
mellitus from pancreas in Non-Invasive detect pancreatic dielectric glucose levels with high testing and challenges
method changes associated with sensitivity, enabling in signal accuracy due
diabetes mellitus through non- potential for non- to external factors..
invasive methods. invasive diabetes
monitoring..
[2] 2023 Microwave-Based Technique for Measuring Used microwave sensing to Accurate glucose Limited to lab settings
Glucose Levels in Aqueous Solutions measure glucose in aqueous measurements in and interference from
solutions. controlled conditions. other substances.
[3] 2020 Real-time monitoring glucose by using Applied microwave antenna Enabled real-time, non- Limited to controlled
microwave antenna applied to biosensor technology for real-time invasive glucose environments and
glucose monitoring in a detection with high potential interference
biosensor setup. accuracy. from tissue
heterogeneity.
[4] 2024 A Non-Invasive Glucose Monitoring Using Glucose sensing with varying Variations in Properties Relay on simulations,
Double S-Shaped Antenna Band Stop Filter Properties of glucose solutions of glucose solutions which may not fully
and accuracy of glucose reflect real-world
conditions.
[5] 2022 Design Flexible Micro-strip Antenna for Non- Developed a flexible Micro- Achieved effective Limited testing on real
Invasive Blood Glucose Detection strip patch antenna optimized detection of glucose human tissues,
for non-invasive glucose level variations with potential signal
detection by targeting specific enhanced flexibility and interference from
frequencies and testing on adaptability to curved body movements, and
tissue phantoms. surfaces. challenges in
durability of flexible
materials.
Proposed system
A microstrip patch antenna is used to capture RF signals affected by glucose
levels.
Machine learning models analyze S-parameter variations.
A trained Random Forest model predicts glucose levels accurately.
The system is non-invasive, cost-effective, and easy to use.
System methodology
1. Data Collection & Preprocessing
Extract S11 variations using CST Studio and store them in a CSV file.
Load data using Python (Pandas), clean inconsistencies, and map glucose concentrations to S11 values.
2. Feature Engineering & Model Development
Identify relevant features from S11 variations.
Train a Random Forest Regression model to predict glucose levels.
Optimize with hyperparameter tuning for accuracy.
3. Model Validation & Performance
Evaluate using Mean Absolute Error (MAE) and compare predictions with actual values.
Use scatter plots and trend graphs for visualization.
4. User Input & Prediction
Input an S11 value, find the closest match in the dataset, and interpolate if needed.
Display predicted glucose levels as Low (<80 mg/dL), Normal (80-120 mg/dL), or High (>120 mg/dL).
5. Conclusion & Future Enhancements
Demonstrates non-invasive glucose monitoring feasibility.
6. Future work:
Improve model accuracy, expand dataset, develop a user-friendly application.
This keeps it concise while retaining all key aspects.
Flow Chart
Data Collection – Extracted S11
variations from CST Studio and stored
them in a CSV file.
Data Processing – Loaded the CSV file
using Python and ensured data accuracy.
User Input – Program takes an S11
value as input.
Nearest Value Matching – Finds the
closest S11 value from the dataset.
Output Generation – Displays the
corresponding glucose measurement.
Analytics of the project
1. Machine Learning Model Performance: Mean Absolute Error (MAE) is a metric used to
measure the average magnitude of errors in a set of
Random Forest Regression predictions, without considering their direction (positive
or negative). It calculates the absolute difference
Mean Absolute Error (MAE): ~X mg/dL between actual and predicted values and then
averages them.
Formula:
2. Dataset Analysis: MAE=1/n∑∣ yi−’yi∣
Where:
Collected RF data with glucose variations yi = Actual value
‘yi = Predicted value
Correlation between S-parameters and n = Number of observations
glucose levels
Python code
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def load_data(file_path):
return pd.read_csv(file_path)
def predict_glucose(s11_value, df):
glucose_mapping = {"0 sol": 60, "10 sol": 100, "20 sol": 130, "40 sol": 170, "50 sol": 200}
df_melted = df.melt(id_vars=["Freq"], var_name="Glucose_Concentration", value_name="S11")
df_melted["Glucose_Concentration"] = df_melted["Glucose_Concentration"].map(glucose_mapping)
closest = df_melted.iloc[(df_melted['S11'] - s11_value).abs().argsort()[:2]]
return np.interp(s11_value, closest["S11"], closest["Glucose_Concentration"]) if len(closest) > 1 else
closest["Glucose_Concentration"].values[0]
def classify_glucose(glucose_level):
return "Low" if glucose_level < 80 else "Normal" if glucose_level <= 120 else "High"
def plot_glucose_trend(df):
glucose_mapping = {"0 sol": 60, "10 sol": 100, "20 sol": 130, "40 sol": 170, "50 sol": 200}
df_melted = df.melt(id_vars=["Freq"], var_name="Glucose_Concentration", value_name="S11")
df_melted["Glucose_Concentration"] = df_melted["Glucose_Concentration"].map(glucose_mapping)
plt.scatter(df_melted["S11"], df_melted["Glucose_Concentration"], label="Data Points", color="blue")
plt.xlabel("S11 Value")
plt.ylabel("Glucose Level (mg/dL)")
plt.title("Glucose Level vs S11 Value")
plt.legend()
plt.show()
if __name__ == "__main__":
df = load_data("/content/0% - 50% solutions.csv")
s11_input = float(input("Enter S11 value: "))
glucose_level = predict_glucose(s11_input, df)
print(f"Predicted Glucose Level: {glucose_level:.2f} mg/dL ({classify_glucose(glucose_level)})")
plot_glucose_trend(df)
Program output
Conclusion
This project demonstrates the feasibility of non-invasive glucose
monitoring using RF signals and machine learning.
The proposed method offers a pain-free alternative to traditional
testing, with promising accuracy levels.
Further improvements can enhance reliability for real-world
deployment.
THANK YOU