0
$\begingroup$

I am trying to build an algorithm that uses GRNN for regression, a model based on the formula: enter image description here

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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Alright seems like I had to apply the same method for each feature. But the steps I followed were wrong. I thought there was something more complicated. Anyway, if someone gets stuck just like me, here is the solution:

your test inputs are a1=5 and a2=7

For each test input find the euclidean distance **SEPERATELY**

d11 = 9    d21 = 9 
d12 = 1    d22 = 1
d13 = 1    d23 = 1
d14 = 9    d24 = 9

Now, we need to find the weights, we will do the same thing.(values can be soo close to 0)

w11 = 0      w21 = 0
w12 = 0.6    w22 = 0.6
w13 = 0.6    w23 = 0.6
w14 = 0      w24 = 0

After finding weights, calculate numerator and dominator for each one.

Num1 = w11*3 + w12*5 + w13*7 + w14*9 = 7.2
Num2 = w21*3 + w22*5 + w23*7 + w24*9 = 7.2

Denom1 = w11 + w12 + w13 + w14 = 1.2
Denom2 = w21 + w22 + w23 + w24 = 1.2

Output is

Num1 + Num2 / Denom1 + Denom2 = 14.4/2.4 = **6**
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.