tensap.approximation.tools package

Submodules

tensap.approximation.tools.model_selection module

Module model_selection.

class tensap.approximation.tools.model_selection.ModelSelection

Bases: object

Class ModelSelection.

Attributes
pen_shapefunction

Function specifying the penalization shape.

datadict

Dictionnary containing the data used for the model selection. data[‘complexity’] contains the complexities of the models, and data[‘empirical_risk’] the associated empirical risk values.

gap_factorint or float

Multiplicative factor used in the slope heuristic.

Methods

complexity(x, *args, **kwargs)

Return the complexity associated to the input argument’s type.

complexity_functional_basis_array(x[, fun])

Return the complexity associated with a FunctionalBasisArray.

complexity_tree_based_tensor(x[, fun, c_type])

Return the complexity associated with the TreeBasedTensor.

lambda_path()

Return the path of possible values of lambda and associated arguments of the minimum of the penalized risk.

m_lambda(lbda)

Compute the argument of the minimum of the penalized risk for given values of the penalization factor lbda.

slope_heuristic([lambda_path, m_path])

Apply the slope heuristic to the path of possible values of lambda to compute its optimal value lambda_hat and associated argument of the minimum of the penalized risk m_hat.

static complexity(x, *args, **kwargs)

Return the complexity associated to the input argument’s type.

See also complexity_functional_basis_array, complexity_tree_based_tensor.

Parameters
xlist or numpy.ndarray or tensap.FunctionalBasisArray or
tensap.FunctionalTensor or tensap.TreeBasedTensor

The object(s) of which the complexity is computed.

*args, **kwargstuples

Additional parameters for the methods complexity_functional_basis_array and complexity_tree_based_tensor.

Returns
float or list

The complexity(ies) associated with the object(s).

Raises
ValueError

If the argument x is not of correct type.

static complexity_functional_basis_array(x, fun=None)

Return the complexity associated with a FunctionalBasisArray.

Parameters
xtensap.FunctionalBasisArray

The FunctionalBasisArray of which the complexity is computed.

funstr, optional

Name of the function applied to the array to extract the storage complexity. The default is ‘storage’.

Returns
float

The complexity associated with the FunctionalBasisArray.

static complexity_tree_based_tensor(x, fun=None, c_type='standard')

Return the complexity associated with the TreeBasedTensor.

Parameters
xtensap.TreeBasedTensor

The TreeBasedTensor of which the complexity is computed.

funstr, optional

Name of the function applied to the array to extract the storage complexity. The default is ‘storage’. Can also be ‘sparse_storage’ or ‘sparse_leaves_storage’ for instance.

c_typestr, optional

The complexity type. The default is ‘standard’. Can also be ‘stiefel’ or ‘grassman’.

Returns
float or list

The complexity(ies) associated with the TreeBasedTensor(s).

Raises
ValueError

If the complexity type is neither ‘standard’ nor ‘stiefel’ nor ‘grassman’.

lambda_path()

Return the path of possible values of lambda and associated arguments of the minimum of the penalized risk.

Returns
numpy.ndarray

The path of possible values of lambda.

numpy.ndarray

The path of the arguments of the minimum of the penalized risk associated with the path of possible values of lambda.

m_lambda(lbda)

Compute the argument of the minimum of the penalized risk for given values of the penalization factor lbda.

Parameters
lbdalist or numpy.ndarray

The values of the penalization factor.

Returns
numpy.ndarray

The argument of the minimum of the penalized risk for the values of the penalization factor.

slope_heuristic(lambda_path=None, m_path=None)

Apply the slope heuristic to the path of possible values of lambda to compute its optimal value lambda_hat and associated argument of the minimum of the penalized risk m_hat.

Parameters
lambda_pathlist or numpy.ndarray, optional

The path of possible values of lambda. The default is None, indicating to compute it using the method lambda_path.

m_pathlist or numpy.ndarray, optional

The path of the arguments of the minimum of the penalized risk associated with the path of possible values of lambda. The default is None, indicating to compute it using the method lambda_path.

Returns
lambda_hatfloat

The value of lambda determined using the slope heuristic.

m_hatint

The model number associated with the value of lambda determined using the slope heuristic.

lambda_pathnumpy.ndarray

The path of possible values of lambda.

m_pathnumpy.ndarray

The path of the arguments of the minimum of the penalized risk associated with the path of possible values of lambda.

Module contents