neupy.algorithms.rbfn.grnn module

class neupy.algorithms.rbfn.grnn.GRNN[source]

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

Parameters:

std : float

Standard deviation for PDF function, defaults to 0.1. 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 interminal. True enables informative output in the terminal and False - disable it. Defaults to False.

Notes

  • GRNN Network is sensitive for cases when one input feature has higher values than the other one. Before use it make sure that input values are normalized and have similar scales.
  • Make sure that standard deviation in the same range as input features. Check std parameter description for more information.
  • The bigger training dataset the slower prediction. It’s 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.

Examples

>>> from sklearn import datasets, preprocessing
>>> from sklearn.model_selection import train_test_split
>>> from neupy import algorithms, estimators, environment
>>>
>>> environment.reproducible()
>>>
>>> dataset = datasets.load_diabetes()
>>> x_train, x_test, y_train, y_test = train_test_split(
...     preprocessing.minmax_scale(dataset.data),
...     preprocessing.minmax_scale(dataset.target.reshape((-1, 1))),
...     train_size=0.7,
... )
>>>
>>> nw = algorithms.GRNN(std=0.1, verbose=False)
>>> nw.train(x_train, y_train)
>>>
>>> y_predicted = nw.predict(x_test)
>>> estimators.rmse(y_predicted, y_test)
0.2381013391408185

Methods

train(input_train, target_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(input_data) Predicts output for the specified input.
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")), 'epoch_end_signal': Option(class_name='BaseNetwork', value=Property(name="epoch_end_signal")), 'shuffle_data': Option(class_name='BaseNetwork', value=Property(name="shuffle_data")), 'show_epoch': Option(class_name='BaseNetwork', value=ShowEpochProperty(name="show_epoch")), 'train_end_signal': Option(class_name='BaseNetwork', value=Property(name="train_end_signal")), 'step': Option(class_name='BaseNetwork', value=NumberProperty(name="step"))}[source]
predict(input_data)[source]

Make a prediction from the input data.

Parameters:

input_data : array-like (n_samples, n_features)

Returns:

array-like (n_samples,)

Raises:

ValueError

In case if something is wrong with input data.

std = None[source]
train(input_train, target_train, copy=True)[source]

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

Parameters:

input_train : array-like (n_samples, n_features)

target_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.

Raises:

ValueError

In case if something is wrong with input data.