我是神经网络的新手(只是免责声明)。
基于8个特征,我有一个预测混凝土强度的回归问题。我首先做的是使用min-max规范化重新调整数据:
# Normalize data between 0 and 1
from sklearn.preprocessing import MinMaxScaler
min_max = MinMaxScaler()
dataframe2 = pd.DataFrame(min_max.fit_transform(dataframe), columns = dataframe.columns)
然后将数据帧转换为numpy数组并将其拆分为X_train,y_train,X_test,y_test。 现在这里是网络本身的Keras代码:
from keras.models import Sequential
from keras.layers import Dense, Activation
#Set the params of the Neural Network
batch_size = 64
num_of_epochs = 40
hidden_layer_size = 256
model = Sequential()
model.add(Dense(hidden_layer_size, input_shape=(8, )))
model.add(Activation('relu'))
model.add(Dense(hidden_layer_size))
model.add(Activation('relu'))
model.add(Dense(hidden_layer_size))
model.add(Activation('relu'))
model.add(Dense(1))
model.add(Activation('linear'))
model.compile(loss='mean_squared_error', # using the mean squared error function
optimizer='adam', # using the Adam optimiser
metrics=['mae', 'mse']) # reporting the accuracy with mean absolute error and mean squared error
model.fit(X_train, y_train, # Train the model using the training set...
batch_size=batch_size, epochs=num_of_epochs,
verbose=0, validation_split=0.1)
# All predictions in one array
predictions = model.predict(X_test)
问题:
预测数组将包含缩放格式的所有值(介于0和1之间),但显然我需要将预测置于其实际值中。如何将这些输出重新调整为实际值?
Min-Max或Z-Score标准化是否更适合回归问题?这个'批量标准化'
谢谢,
答案 0 :(得分:2)
根据doc,inverse_transform
类有一个$('body').on('click','[data-toggle="collapse"][data-mytarget^="$("]',function(){
eval($(this).data('mytarget')).collapse('toggle');
});
方法可以满足您的需求:
inverse_transform(X):根据feature_range撤消X的缩放。
答案 1 :(得分:1)
For 1:使用inverse_transform()
与您匹配的相同MinMaxScaler转换原始数据: