Search code examples
pythonneural-networkdata-scienceneupy

GRNN using neupy


Im trying to figure out how to configure a neural network using Neupy. The problem is that I cant seem to find much options for a GRNN, only the sigma value as described here:

There is a parameter, y_i, that I want to be able to adjust, but there doesn't seem to be a way to do it on the package. I'm parsing through the code but i'm not a developer so i've trouble following all the steps, maybe a more experienced set of eyes can find a way to tweak that parameter.

Thanks


Solution

  • From the link that you've provided it looks like y_i is the target variable. In your case it's your target training variable. In the neupy code it's used during the prediction. https://github.com/itdxer/neupy/blob/master/neupy/algorithms/rbfn/grnn.py#L140

    GRNN uses lazy learning, which means that it doesn't train, it just re-uses all your training data per each prediction. The self.target_train variable is just a copy that you use during the training phase. You can update this value before making prediction

    from neupy import algorithms
    
    grnn = algorithms.GRNN(std=0.1)
    grnn.train(x_train, y_train)
    
    grnn.train_target = modify_grnn_algorithm(grnn.train_target)
    predicted = grnn.predict(x_test)
    

    Or you can use GRNN code for prediction instead of default predict function

    import numpy as np
    from neupy import algorithms
    from neupy.algorithms.rbfn.utils import pdf_between_data
    
    grnn = algorithms.GRNN(std=0.1)
    grnn.train(x_train, y_train)
    
    # In this part of the code you can do any moifications you want
    ratios = pdf_between_data(grnn.input_train, x_test, grnn.std)
    predicted = (np.dot(grnn.target_train.T, ratios) / ratios.sum(axis=0)).T