athena.active.ActiveSubspaces.fit

ActiveSubspaces.fit(inputs=None, outputs=None, gradients=None, weights=None, metric=None)[source]

Compute the active subspaces given the gradients of the model function wrt the input parameters, or given the input/outputs couples. Only two methods are available: ‘exact’ and ‘local’.

Parameters
  • inputs (numpy.ndarray) – input parameters oriented as rows.

  • outputs (numpy.ndarray) – corresponding outputs oriented as rows.

  • gradients (numpy.ndarray) – n_samples-by-n_params matrix containing the gradient samples oriented as rows. If frequent directions needed to be performed, gradients is an object of GeneratorType.

  • weights (numpy.ndarray) – n_samples-by-1 weight vector, corresponds to numerical quadrature rule used to estimate matrix whose eigenspaces define the active subspace.

  • metric (numpy.ndarray) – metric matrix output_dim-by-output-dim for vectorial active subspaces.

Raises

TypeError

Example
>>> # inputs shape is n_samples-by-n_params
>>> # outputs shape is n_samples-by-1
>>> # gradients shape is n_samples-by-n_params
>>> # if gradients are available use the 'exact' method:
>>> ss1 =  ActiveSubspaces(dim=1, method='exact', n_boot=150)
>>> ss1.fit(gradients=gradients)
>>> # for the frequent direction method to compute the eigenpairs
>>> # you need to pass a generator to gradients:
>>> gradients_gen = (grad for grad in gradients)
>>> ss2 =  ActiveSubspaces(dim=2, method='exact')
>>> ss2.fit(gradients=gradients_gen)
>>> # if no gradients are available use the 'local' method:
>>> ss3 =  ActiveSubspaces(dim=1, method='local', n_boot=150)
>>> ss3.fit(inputs=inputs, outputs=outputs)