neupy.algorithms.Oja

class neupy.algorithms.Oja[source]

Oja is an unsupervised technique used for the dimensionality reduction tasks.

Parameters:
minimized_data_size : int

Expected number of features after minimization, defaults to 1.

weight : array-like or None

Defines networks weights. Defaults to XavierNormal().

step : float

Learning rate, defaults to 0.1.

show_epoch : int

This property controls how often the network will display information about training. It has to be defined as positive integer. For instance, number 100 mean that network shows summary at 1st, 100th, 200th, 300th … and last epochs.

Defaults to 1.

shuffle_data : bool

If it’s True than training data will be shuffled before the training. Defaults to True.

signals : dict, list or function

Function that will be triggered after certain events during the training.

verbose : bool

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

Notes

  • In practice use step as very small value. For instance, value 1e-7 can be a good choice.
  • Normalize the input data before use Oja algorithm. Input data shouldn’t contains large values.
  • Set up smaller values for weight if error for a few first iterations is big compare to the input values scale. For instance, if your input data have values between 0 and 1 error value equal to 100 is big.
  • During the traning network report mean absolute error (MAE)

Examples

>>> import numpy as np
>>> from neupy import algorithms
>>>
>>> data = np.array([[2, 2], [1, 1], [4, 4], [5, 5]])
>>>
>>> ojanet = algorithms.Oja(
...     minimized_data_size=1,
...     step=0.01,
...     verbose=False
... )
>>>
>>> ojanet.train(data, epochs=100)
>>> minimized = ojanet.predict(data)
>>> minimized
array([[-2.82843122],
       [-1.41421561],
       [-5.65686243],
       [-7.07107804]])
>>> ojanet.reconstruct(minimized)
array([[ 2.00000046,  2.00000046],
       [ 1.00000023,  1.00000023],
       [ 4.00000093,  4.00000093],
       [ 5.00000116,  5.00000116]])

Methods

reconstruct(X) Reconstruct original dataset from the minimized input.
train(X, epochs=100) Trains the network to the data X. Network trains until maximum number of epochs was reached.
predict(X) Returns hidden representation of the input data X. Basically, it applies dimensionality reduction.
fit(*args, **kwargs) Alias to the train method.
minimized_data_size = None[source]
one_training_update(X, y_train)[source]

Function would be trigger before run all training procedure related to the current epoch.

Parameters:
epoch : int

Current epoch number.

options = {'minimized_data_size': Option(class_name='Oja', value=IntProperty(name="minimized_data_size")), 'show_epoch': Option(class_name='BaseNetwork', value=IntProperty(name="show_epoch")), 'shuffle_data': Option(class_name='BaseNetwork', value=Property(name="shuffle_data")), 'signals': Option(class_name='BaseNetwork', value=Property(name="signals")), 'step': Option(class_name='BaseNetwork', value=NumberProperty(name="step")), 'verbose': Option(class_name='Verbose', value=VerboseProperty(name="verbose")), 'weight': Option(class_name='Oja', value=ParameterProperty(name="weight"))}[source]
predict(X)[source]
reconstruct(X)[source]
train(X, epochs=100)[source]

Method train neural network.

Parameters:
X_train : array-like
y_train : array-like or None
X_test : array-like or None
y_test : array-like or None
epochs : int

Defaults to 100.

epsilon : float or None

Defaults to None.

weight = None[source]