I’ve found a solution, if anyone wants to know:
In tensorflow scale the data normally:
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaler.fit(X_train)
X_train = scaler.transform(X_train)
X_test = scaler.transform(X_test)
To get the mean type: scaler.mean_
To get the std type: scaler.scale_
Copy and paste these figures into your Arduino code using the formula below:
The standard score of a sample x
is calculated as:
z = (x - u) / s
where u
is the mean of the training samples or zero if with_mean=False
, and s
is the standard deviation of the training samples or one if with_std=False
.
Example code below:
float Sensor1 = (sensorReading1 - mean_) / scale_;