I am trying to build an algorithm that uses GRNN for regression, a model based on the formula:
My csv files are looks like:
Train.csv: Test.csv:
Number1 Number2 NumberT Number1 Number2
2 4 3 5 7
4 6 5
6 8 7
8 10 9
Predictors are Number1
and Number2
. My Target is NumberT
. It is pretty easy to predict the output with only 1 predictor Number1
. But when multiple features comes in, I can't figure it out.
To solve this problem, I have stored all the features and outputs automatically:
inputsTrain = [[2,4,6,8],[4,6,8,10]]
outputsTrain = [3,5,7,9]
inputsTest = [[5],[7]]
I've used inputsTrain
and outputsTrain
to find the weights by activation function. (I assumed σ=1
).
To calculate the weights, I found all the distances between inputsTest and inputsTrain.
for test input 5: euc_distances = [[9, 1, 1, 9], [1, 1, 9, 25]]
for test input 7: euc_distances = [[25, 9, 1, 1], [9, 1, 1, 9]]
After inserting these distances into the activation function, I have stored all the weights in a list called hiddenLayers
.
weights = [[[0, 0.6, 0.6, 0], [0.6, 0.6, 0, 0]], [[0, 0, 0.6, 0.6], [0, 0.6, 0.6, 0]]]
But now I don't know what to do with these weights. It was easy when I got 1 predictor, I could just multiply weights with corresponding outputsTrain
elements and then do numerator/denominator. But when it comes to multiple predictors, I can't find what to do after this point. Any help would be appreciated.