pytuq.utils.maps

Module for various mapping functions.

Classes

XMap

Base class for a map.

Expon

Exponential map.

Logar

Logarithmic map.

ComposeMap

Composition of two maps.

LinearScaler

Linear scaler map.

Standardizer

Standardizer map, linearly scaling data to zero mean and unit variance.

Normalizer

Normalizer map, linearly scaling data to [0,1].

Domainizer

Domainizer map, linearly scaling data (assumed to be in [0,1]) to a given domain.

Affine

Affine map.

Functions

scale01ToDom(xx, dom)

Scaling an array to a given domain, assuming the inputs are in [0,1]^d.

scaleDomTo01(xx, dom)

Scaling an array from a given domain to [0,1]^d.

scaleTo01(xx)

Scale an array to [0,1], using dimension-wise min and max.

standardize(xx)

Normalize an array, i.e. map it to zero mean and unit variance.

Module Contents

pytuq.utils.maps.scale01ToDom(xx, dom)[source]

Scaling an array to a given domain, assuming the inputs are in [0,1]^d.

Parameters:
  • xx (np.ndarray) – Nxd input array.

  • dom (np.ndarray) – dx2 domain.

Returns:

Nxd scaled array.

Return type:

np.ndarray

Note

If input is outside [0,1]^d, a warning is given, but the scaling will happen nevertheless.

pytuq.utils.maps.scaleDomTo01(xx, dom)[source]

Scaling an array from a given domain to [0,1]^d.

Parameters:
  • xx (np.ndarray) – Nxd input array.

  • dom (np.ndarray) – dx2 domain.

Returns:

Nxd scaled array.

Return type:

np.ndarray

Note

If input is outside domain, a warning is given, but the scaling will happen nevertheless.

pytuq.utils.maps.scaleTo01(xx)[source]

Scale an array to [0,1], using dimension-wise min and max.

Parameters:

xx (np.ndarray) – Initial 2d array

Returns:

Scaled array.

Return type:

np.ndarray

pytuq.utils.maps.standardize(xx)[source]

Normalize an array, i.e. map it to zero mean and unit variance.

Parameters:

xx (np.ndarray) – Initial 2d array

Returns:

Normalized array.

Return type:

np.ndarray

class pytuq.utils.maps.XMap[source]

Base class for a map.

forw(x)[source]

Forward map.

Parameters:

x (np.ndarray) – 2d numpy input array.

Returns:

2d numpy output array.

Return type:

np.ndarray

abstract inv(xs)[source]

Inverse of the map.

Parameters:

xs (np.ndarray) – 2d numpy array.

Returns:

if implemented, 2d numpy array.

Return type:

np.ndarray

class pytuq.utils.maps.Expon[source]

Bases: XMap

Exponential map.

inv(xs)[source]

Inverse of the map.

Parameters:

xs (np.ndarray) – 2d numpy array.

Returns:

if implemented, 2d numpy array.

Return type:

np.ndarray

class pytuq.utils.maps.Logar[source]

Bases: XMap

Logarithmic map.

inv(xs)[source]

Inverse of the map.

Parameters:

xs (np.ndarray) – 2d numpy array.

Returns:

if implemented, 2d numpy array.

Return type:

np.ndarray

class pytuq.utils.maps.ComposeMap(map1, map2)[source]

Bases: XMap

Composition of two maps.

map1[source]
map2[source]
inv(xs)[source]

Inverse of the map.

Parameters:

xs (np.ndarray) – 2d numpy array.

Returns:

if implemented, 2d numpy array.

Return type:

np.ndarray

class pytuq.utils.maps.LinearScaler(shift=None, scale=None)[source]

Bases: XMap

Linear scaler map.

shift = None[source]
scale = None[source]
inv(xs)[source]

Inverse of the map.

Parameters:

xs (np.ndarray) – 2d numpy array.

Returns:

if implemented, 2d numpy array.

Return type:

np.ndarray

class pytuq.utils.maps.Standardizer(x)[source]

Bases: LinearScaler

Standardizer map, linearly scaling data to zero mean and unit variance.

class pytuq.utils.maps.Normalizer(x, nugget=0.0)[source]

Bases: LinearScaler

Normalizer map, linearly scaling data to [0,1].

class pytuq.utils.maps.Domainizer(dom)[source]

Bases: LinearScaler

Domainizer map, linearly scaling data (assumed to be in [0,1]) to a given domain.

Note

This also can be accomplished by functions scaleDomTo01 and its inverse scale01ToDom.

class pytuq.utils.maps.Affine(weight=None, bias=None)[source]

Bases: XMap

Affine map.

weight = None[source]
bias = None[source]
inv(xs)[source]

Inverse of the map.

Parameters:

xs (np.ndarray) – 2d numpy array.

Returns:

if implemented, 2d numpy array.

Return type:

np.ndarray