I am using the scikit-learn neural network toolbox sklearn.neural_network.MLPRegressor to train a regressor with an output vector of 24 nodes. I am looking to use an error function similar to dynamic time warping (but slightly simplified) to quantify the prediction error. I have written the function that quantifies the error between two input vectors but am not sure how to link this in with sklearn's MLP Regressor.
Q: Is it simply a case of defining a scoring object as shown here sklearn and feeding it into the training part.
Below is my defined loss function.
def MAAPE(actual,forecast,p,w):
error_array = np.zeros([len(actual), len(forecast)])
error_sum = 0
for i in range(len(actual)):
for j in range(len(forecast)):
if abs(i-j)>w:
error_array[i,j] = float('inf')
else:
error_array[i,j] = abs(actual[i] - forecast[j])/actual[i]
error_sum = error_sum + min(error_array[i,:])**p
MAAPE = (error_sum**(1/p))/len(actual)
return MAAPE