Processing of MQ-X sensors’ data with Machine Learning.

pip3 list
!pip install tensorflow==2.5.0
import tensorflow as tf
Divided data.
MQ-3 sensor’s diagram.
Values after normalization.
# First take the good data
data_first_day_good = fields1[10:210]
data_second_day_good = fields2[10:210]
data_third_day_good = fields3[10:210]
# Then take the bad data
data_first_day_bad = fields1[-200:]
data_second_day_bad = fields2[-200:]
data_third_day_bad = fields3[-200:]
data_all_days = [data_first_day_good, data_second_day_good, data_third_day_good, data_first_day_bad, data_second_day_bad, data_third_day_bad]data_rest = pd.concat(data_all_days)# SHUFFLE the dataset before splitting into training and validation and reset the indexdata_rest = data_rest.sample(frac=1).reset_index(drop=True)# Separate the data into features and targets
target_field = ['day']
data_features, data_targets = data_rest.drop(target_field, axis=1), data_rest[target_field]
One hot encoding.
Building the network.
Diagram of the losses.
# Convert the model
converter = tf.lite.TFLiteConverter.from_saved_model('/content/saved_model') # path to the SavedModel directory
tflite_model = converter.convert()

# Save the model.
with open('food_model_250.tflite', 'wb') as f:
Using the Interpreter.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store