def standard(train, test):
mean = train.mean(axis=0)
train -= mean
std = train.std(axis=0)
train /= std
test -= mean
test /= std
standard(tf_train_x, tf_test_x)
Make data smaller for standardization.
Make model, compile and validation check
Final save model data for serving
after that we use model using load_model() in web or etc.
Calculate the mean of each feature in the training set.
Subtract the mean from each feature in both the training and test sets.
Calculate the standard deviation of each feature in the training set.
Divide each feature in both the training and test sets by the standard deviation.
To obtain the mean and standard deviation values for each feature, you can modify your standard function like this:
def standard(train, test):
mean = train.mean(axis=0)
train -= mean
std = train.std(axis=0)
train /= std
test -= mean
test /= std
return mean, std
# Apply standardization and get the mean and std values
mean_values, std_values = standard(tf_train_x, tf_test_x)
# Print or store the mean and std values for later use
print("Mean values:", mean_values)
print("Standard deviation values:", std_values)