neupy.algorithms.rbfn.pnn module

class neupy.algorithms.rbfn.pnn.PNN[source]

Probabilistic Neural Network (PNN). Network applies only to the classification problems.


std : float

Standard deviation for the Probability Density Function (PDF). 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.

batch_size : int or {None, -1, ‘all’, ‘*’, ‘full’}

Set up min-batch size. If mini-batch size is equal to one of the values from the list (like full) then it’s just a batch that equal to number of samples. Defaults to 128.

verbose : bool

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


  • PNN 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.


>>> import numpy as np
>>> from sklearn import datasets, metrics
>>> from sklearn.model_selection import train_test_split
>>> from neupy import algorithms, environment
>>> environment.reproducible()
>>> dataset = datasets.load_digits()
>>> x_train, x_test, y_train, y_test = train_test_split(
...,, test_size=0.3
... )
>>> pnn = algorithms.PNN(std=10, verbose=False)
>>> pnn.train(x_train, y_train)
>>> y_predicted = pnn.predict(x_test)
>>> metrics.accuracy_score(y_test, y_predicted)


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. The target_train argument should be a vector or matrix with one feature column.
predict(input_data) Predicts output for the specified input.
predict_proba(input_data) Predict probabilities for each class.
fit(*args, **kwargs) Alias to the train method.
options = {'batch_size': Option(class_name='MinibatchTrainingMixin', value=BatchSizeProperty(name="batch_size")), 'verbose': Option(class_name='Verbose', value=VerboseProperty(name="verbose")), 'step': Option(class_name='BaseNetwork', value=NumberProperty(name="step")), 'show_epoch': Option(class_name='BaseNetwork', value=ShowEpochProperty(name="show_epoch")), 'shuffle_data': Option(class_name='BaseNetwork', value=Property(name="shuffle_data")), 'epoch_end_signal': Option(class_name='BaseNetwork', value=Property(name="epoch_end_signal")), 'train_end_signal': Option(class_name='BaseNetwork', value=Property(name="train_end_signal")), 'std': Option(class_name='PNN', value=BoundedProperty(name="std"))}[source]

Predicts class from the input data.

Parameters:input_data : array-like (n_samples, n_features)
Returns:array-like (n_samples,)

Predict probabilities for each class.

Parameters:input_data : array-like (n_samples, n_features)
Returns:array-like (n_samples, n_classes)

Raw prediction.


input_data : array-like (n_samples, n_features)


array-like (n_samples, n_classes)



If network hasn’t been trained.


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.


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.



In case if something is wrong with input data.