Submitted by Constant-Cranberry29 t3_ywu5zb in deeplearning
I have a dataset that contains negative and positive values. then here I use MinMaxScaler() to normalize the data to 0 and 1. but because the normalized data has negative and positive values in it, the normalization is not optimal, so the resulting prediction results are not optimal. then I try to change the negative data to positive with abs() then the result from abs() is normalized using MinMaxScaler() the result will be better. is there a way for me to keep the negative and positive values but have good predictions?
my last activation function is Sigmoid
Here my model structure:
model = Sequential()
model.add(LSTM(64, activation='relu', return_sequences= False, input_shape= (50,89)))
model.add(Dense(32,activation='relu'))
model.add(Dense(16,activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss = 'mse', optimizer=Adam(learning_rate=0.002), metrics=['mse'])
model.summary()
​
Here my code of normalization with abs():
df = pd.read_csv('1113_Rwalk40s1.csv', low_memory=False)
columns = ['Fx']]
selected_df = df[columns]
FCDatas = selected_df[:2050]
FCDatas = abs(FCDatas)
SmartInsole = np.array(SIData[:2050])
FCData = np.array(FCDatas)
Dataset = np.concatenate((SmartInsole, FCData), axis=1)
scaler_in = MinMaxScaler(feature_range=(0, 1))
scaler_out = MinMaxScaler(feature_range=(0, 1))
data_scaled_in = scaler_in.fit_transform(Dataset[:,0:89])
data_scaled_out = scaler_out.fit_transform(Dataset[:,89:90])
The result using abs():
​
Here my code of normalization with without abs():
df = pd.read_csv('1113_Rwalk40s1.csv', low_memory=False)
columns = ['Fx']]
selected_df = df[columns]
FCDatas = selected_df[:2050]
SmartInsole = np.array(SIData[:2050])
FCData = np.array(FCDatas)
Dataset = np.concatenate((SmartInsole, FCData), axis=1)
scaler_in = MinMaxScaler(feature_range=(0, 1))
scaler_out = MinMaxScaler(feature_range=(0, 1))
data_scaled_in = scaler_in.fit_transform(Dataset[:,0:89])
data_scaled_out = scaler_out.fit_transform(Dataset[:,89:90])
The result without abs():
​
pornthrowaway42069l t1_iwlbxq2 wrote
You can try neglog,
x > 0: log(x)
x<0: -log(-x)