Regression Leaner App , data structure for multiple sensors and input possibility?
2 views (last 30 days)
Show older comments
I am working on a sensor project where I need to calibrate electrochemical sensors using reference data. These sensors are affected by temperature and humidity, so I have created a table that includes the
[Sensor ID, temperature, humidity, and reference data for each sensor]
I input this table into the Regression Model App, and I find that exponential GPR produces the best results. However, each sensor has its own tolerance and sensitivity variation (+/- 10%) when reacting to changes in temperature and humidity. Ideally, I want to create a general model, but also give the user the option to adjust a variable factor to compensate for each sensor's unique characteristics.
If I use the table with Sensor ID included, the model works well for that specific sensor. However, if I remove the Sensor ID and only use the table with temperature, humidity, and reference data, the results are average and do not capture each sensor's unique characteristics.
This is my code
all_timetable=[];
for i=1:8
temptime_table=timetable(app.electrosensors_table{i}.Time, ...
app.electrosensors_table{i}.Temperature,...
app.electrosensors_table{i}.Humidity,...
app.electrosensors_table{i}.NO2,'VariableNames',["Temperture","Humdity","Sensor"]);
%all_timetable=[all_timetable;temptime_table]
%all_ref= [all_ref;app.sensor_table_data(i).ref_timetable_period.locationA]
temptime_table.SensorID = categorical(repmat(i,height(temptime_table),1));
temptime_table.CorrectionFactor = ones(height(temptime_table),1);
data = temptime_table(app.sensor_table_data(1).ref_timetable_period.locationA.ref_time,:); % only use reference times
data.Ref = app.sensor_table_data(1).ref_timetable_period.locationA.ref_data; % add reference (used as "response")
all_timetable=[all_timetable;data];
end
%data = timetable2table(data);
data = timetable2table(all_timetable);
time = data.Time;
data.Time = []; % remove Time
rng("default") % for repeatability
n = height(data);
p = randperm(n,round(0.8*n)); % 80% for training, 20% for testing
idx = false(n,1);
idx(p) = true;
data_for_regression = data(idx,:);
assignin('base','data_for_regression',data_for_regression)
disp("a");
My question is, how can I instruct the regression app to account for the slight variation in each sensor and create a general model that can also be adjusted by the user to compensate for each sensor's individual differences? Is this possible?
0 Comments
Answers (2)
Amal Raj
on 13 Mar 2023
Yes, it is possible to account for the slight variations in each sensor and develop a general model that can be adjusted by the user to account for the individual differences in each sensor.
One approach would be to add an additional input variable that is unique to each sensor, such as a scaling factor or bias term. Calibration experiments can be used to determine the value of this variable, in which you measure the response of each sensor under different temperature and humidity conditions and fit a linear model to relate the response to the input variables and the scaling factor.
To use this method in the Regression Model App, modify your input table to include a column for each sensor's response as well as a column for the scaling factor or bias term for each sensor. Then, using the temperature, humidity, and scaling factor columns as inputs and the response columns as outputs, you can train a regression model, such as a Gaussian Process Regression (GPR). Additional features, such as the product of temperature and humidity, can be included to capture any nonlinear interactions between the input variables.
Once the model has been trained, the user can adjust the scaling factor or bias term for each sensor to account for its unique characteristics. This can be accomplished by either directly modifying the input table or by utilising a user interface that allows the user to adjust the values interactively.
4 Comments
Amal Raj
on 16 Mar 2023
Yes, it is possible to include an exponential term in your input table to reflect the non-linear relationship between sensor output and temperature. One approach you could try is to include a new input variable that is the exponential function of temperature, such as exp(k * T), where k is a user-defined constant that determines the steepness of the exponential curve and T is the temperature input variable. The user could adjust the value of k to match the specific characteristics of each sensor.
Alternatively, you could use a more flexible model that can capture non-linear relationships between the input variables and the sensor output, such as a neural network or decision tree. These models can learn to approximate the non-linear relationship without the need for a specific functional form, such as an exponential curve.
Regarding the bias or variation factor, you could still include a scaling factor or bias term to adjust for individual differences in the sensor's sensitivity or offset. This could be a separate input variable that is unique to each sensor and is learned during calibration experiments.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!