helpers Package

helpers Package

helpers Module

pypr.helpers.helpers.MSE(y, t, axis=None)

Returns the Mean Square Error (MSE).

pypr.helpers.helpers.RMSE(y, t, axis=None)

Returns the Root Mean Square Error (RMSE).

pypr.helpers.helpers.k_fold_cross_validation(X, K, k, inv=False)

K-fold cross-validation.

Usage: X : NxD array

Input data (N samples row-wise)
K : int
Numer of folds to make.
k : int
Fold number to leave out. Ranges from [0; K-1]
inv : bool
If true, then return the left out fold instead.
pypr.helpers.helpers.shuffle(A, axis=0)

Returns a shuffled version of A. If axis = 0, then the rows are shuffled, if axis = 1 then the columns are shuffled.


Returns an matrix with the rows in A shuffled. A must be 2d.

modelwithdata Module

class pypr.helpers.modelwithdata.ModelWithData(model, trainX, trainT)

Bases: object

The ModelWithData class encapsulates data and a model in one class, allowing easy use of new or existing algorithms, such as error function minimizers. TODO: Make more general, should be blind to x and t (just use ‘data’)



Returns an row vector with all controllable weights in the model.


Sets the weights of the network.

wrappers Module

pypr.helpers.wrappers.wrap_model(X0, functions, **indices)

Wrap a chain of function calls. It is typical to call a series of functions to obtain a result from a model. For example a preprocessing function, a model call, and a post-processing function. X0 is a defalt input for the function chain.

Parameters :

X0 : np array

Default input for the chain. Samples row-wise, dimensions column-wise.

functions : list of functions

The list is called from left to right. For exaple [a,b,c] would result in c(b(a(X0)))

**indices : dictionary, optional

Specify a names for the colums in X0 or the input. For example saying that the first colums is called speed: {‘speed’:0}

Returns :

eval_wrap : function

A function for evaluation the wrapped network,

Table Of Contents

This Page