hypertools.tools.normalize

hypertools.tools.normalize(x, normalize='across', internal=False, format_data=True)[source]

Z-transform the columns or rows of an array, or list of arrays

This function normalizes the rows or columns of the input array(s). This can be useful because data reduction and machine learning techniques are sensitive to scaling differences between features. By default, the function is set to normalize ‘across’ the columns of all lists, but it can also normalize the columns ‘within’ each individual list, or alternatively, for each row in the array.

Parameters
xNumpy array or list of arrays

This can either be a single array, or list of arrays

normalizestr or False or None

If set to ‘across’, the columns of the input data will be z-scored across lists (default). That is, the z-scores will be computed with with respect to column n across all arrays passed in the list. If set to ‘within’, the columns will be z-scored within each list that is passed. If set to ‘row’, each row of the input data will be z-scored. If set to False, the input data will be returned with no z-scoring.

format_databool

Whether or not to first call the format_data function (default: True).

Returns
normalized_xNumpy array or list of arrays

An array or list of arrays where the columns or rows are z-scored. If the input was a list, a list is returned. Otherwise, an array is returned.