Scaling back the output of neural network (ANN) for multivariate regression?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Scaling back the output of neural network (ANN) for multivariate regression?



I do not have any background in machine learning and neural network. I have a panda dataframe in python where one variable is an unknown function of other independent variables: output = func(input1, input2, ...). So when I plot the output vs any of the output I get a scatter plot without any clear relation between the output and input. So I use ANN to try to find the relation.



I have this code:


from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler, MinMaxScaler, Normalizer, RobustScaler
from sklearn.neural_network import MLPRegressor

X = Data[['input1','input2','input3','input4','input5','input6']].values
y = Data[['output']].values

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.15)

scaler = StandardScaler()
scaler.fit(X_train)
X_train_scaled = scaler.transform(X_train)
X_test_scaled = scaler.transform(X_test)

mlp = MLPRegressor(alpha = 1e-5, hidden_layer_sizes = (50,50,50), max_iter = 5000)
mlp.fit(X_train_scaled,y_train)
predictions = mlp.predict(X_test_scaled)
plt.scatter(X_train[:,0], y_train, color = 'green') %column 0 refers to input1
plt.scatter(X_test[:,0], y_test, marker='^', color = "blue")
plt.scatter(X_test[:,0], predictions, marker='x', color = "red")



The output of the code is how the output changes as input1 (and all the other inputs) change:



enter image description here



Green dots show the training dataset, blue triangles the test dataset, and the red marks show what I get from ANN.



The plot is not bad considering that I am new and the code is relatively simple. In the plot, I used the un-scaled (or scaled back) input on x-axis and scaled predictions on y-axis. The question that I have is if I should scale back the predictions or not.
If I use scaled data as input, there will be a horizontal shift in the data represented by the red marks and the plot wont look correct.
If I try to scale back the predictions, I get an error in this case since I have several inputs and only one output so the dimensions do not match. If I only use one input variable, the dimensions match and I do not get any errors, but the red marks in the plot shifts vertically significantly.



Even when I do not scale back the predictions (well, as I said I can't do that anyways in this case even if I want to) still there can be some red marks that are not within the expected bounds.



What should I do here regarding the scaling back (or anything in general) in order to get better results than what is shown in the plot?
Also I would like to know what metrics are available to determine the performance of ANN for regression problems so I don't have to visually inspect the plots (I have too many data and plots)









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

Future solutions