class neupy.algorithms.GRNN[source]

Generalized Regression Neural Network (GRNN). Network applies only to the regression problems.

std : float

Standard deviation for PDF function. If your input features have high values than standard deviation should also be high. For instance, if input features from range [0, 20] that standard deviation should be also a big value like 10 or 15. Small values will lead to bad prediction.

verbose : bool

Property controls verbose output in terminal. The True value enables informative output in the terminal and False - disable it. Defaults to False.


  • GRNN Network is sensitive for cases when one input feature has higher values than the other one. Input data has to be normalized before training.
  • Standard deviation has to match the range of the input features Check std parameter description for more information.
  • The bigger training dataset the slower prediction. Algorithm is much more efficient for small datasets.
  • Network uses lazy learning which mean that network doesn’t need iterative training. It just stores parameters and use them to make a predictions.


>>> import numpy as np
>>> from sklearn import datasets, preprocessing
>>> from sklearn.model_selection import train_test_split
>>> from neupy import algorithms
>>> dataset = datasets.load_diabetes()
>>> x_train, x_test, y_train, y_test = train_test_split(
...     preprocessing.minmax_scale(,
...     preprocessing.minmax_scale(, 1)),
...     test_size=0.3,
... )
>>> nw = algorithms.GRNN(std=0.1, verbose=False)
>>> nw.train(x_train, y_train)
>>> y_predicted = nw.predict(x_test)
>>> mse = np.mean((y_predicted - y_test) ** 2)
>>> mse


train(X_train, y_train, copy=True) Network just stores all the information about the data and use it for the prediction. Parameter copy copies input data before saving it inside the network.
predict(X) Return prediction per each sample in the X.
fit(*args, **kwargs) Alias to the train method.
options = {'std': Option(class_name='GRNN', value=BoundedProperty(name="std")), 'verbose': Option(class_name='Verbose', value=VerboseProperty(name="verbose"))}[source]

Make a prediction from the input data.

X : array-like (n_samples, n_features)
array-like (n_samples,)

In case if something is wrong with input data.

std = None[source]
train(X_train, y_train, copy=True)[source]

Trains network. PNN doesn’t actually train, it just stores input data and use it for prediction.

X_train : array-like (n_samples, n_features)
y_train : array-like (n_samples,)

Target variable should be vector or matrix with one feature column.

copy : bool

If value equal to True than input matrices will be copied. Defaults to True.


In case if something is wrong with input data.