Projection depth#
- DepthEucl.projection(x: ndarray | None = None, solver: str = 'neldermead', NRandom: int = 1000, n_refinements: int = 10, sphcap_shrink: float = 0.5, alpha_Dirichlet: float = 1.25, cooling_factor: float = 0.95, cap_size: int = 1, start: str = 'mean', space: str = 'sphere', line_solver: str = 'goldensection', bound_gc: bool = True, CUDA: bool = False, output_option: Literal['lowest_depth', 'final_depht_dir', 'all_depth', 'all_depth_directions'] = 'final_depht_dir', evaluate_dataset: bool = False) ndarray [source]
Calculates approximately the projection depth of points w.r.t. a multivariate data set.
- Arguments
- x: array-like or None, default=None
Matrix of objects (numerical vector as one object) whose depth is to be calculated; each row contains a d-variate point. Should have the same dimension as data.
- solverstr {
'simplegrid'
,'refinedgrid'
,'simplerandom'
,'refinedrandom'
,'coordinatedescent'
,'randomsimplices'
,'neldermead'
,'simulatedannealing'
}, default=”neldermead” The type of solver used to approximate the depth.
- NRandomint, default=1000
The total number of iterations to compute the depth. Some solvers are converging faster so they are run several time to achieve
NRandom
iterations.- n_refinementsint, default = 10
Set the maximum of iteration for computing the depth of one point. For
solver='refinedrandom'
or'refinedgrid'
.- sphcap_shrinkfloat, default = 0.5
It’s the shrinking of the spherical cap. For
solver='refinedrandom'
or'refinedgrid'
.- alpha_Dirichletfloat, default = 1.25
It’s the parameter of the Dirichlet distribution. For
solver='randomsimplices'
.- cooling_factorfloat, default = 0.95
It’s the cooling factor. For
solver='simulatedannealing'
.- cap_sizeint | float, default = 1
It’s the size of the spherical cap. For
solver='simulatedannealing'
or'neldermead'
.- startstr {‘mean’, ‘random’}, default = mean
For
solver='simulatedannealing'
or'neldermead'
, it’s the method used to compute the first depth.- spacestr {‘sphere’, ‘euclidean’}, default = ‘sphere’
For
solver='coordinatedescent'
or'neldermead'
, it’s the type of spacecin which the solver is running.- line_solverstr {‘uniform’, ‘goldensection’}, default = goldensection
For
solver='coordinatedescent'
, it’s the line searh strategy used by this solver.- bound_gcbool, default = True
For
solver='neldermead'
, it’sTrue
if the search is limited to the closed hemisphere.- CUDAbool, default=False
Determines if approximate computation will be performed in GPU. avaiable only for simplerandom or refinedrandom
- output_optionstr {“lowest_depth”,”final_depht_dir”,”all_depth”,”all_depth_directions}, default = final_depht_dir
Determines what will be computated alongside with the final depth | If
output_option=lowest_depth
, only approximated depths are returned. | Ifoutput_option=final_depht_dir
, best directions to approximate depths are also returned. | Ifoutput_option=all_depth
, depths calculated at every iteration are also returned. | Ifoutput_option=all_depth_directions
, random directions used to project depths are also returned with indices of converging for the solver selected.- evaluate_datasetbool, default=False
Determines if dataset loaded will be evaluated. Automatically sets x to dataset
- References
Zuo, Y. and Serfling, R. (2000). General notions of statistical depth function. The Annals of Statistics, 28, 461–482.
Dyckerhoff, R., Mozharovskyi, P., and Nagy, S. (2021). Approximate computation of projection depths. Computational Statistics and Data Analysis, 157, 107166.
- Examples
>>> import numpy as np >>> from depth.model import DepthEucl >>> np.random.seed(0) >>> mat1=[[1, 0, 0, 0, 0],[0, 2, 0, 0, 0],[0, 0, 3, 0, 0],[0, 0, 0, 2, 0],[0, 0, 0, 0, 1]] >>> mat2=[[1, 0, 0, 0, 0],[0, 1, 0, 0, 0],[0, 0, 1, 0, 0],[0, 0, 0, 1, 0],[0, 0, 0, 0, 1]] >>> data = np.random.multivariate_normal([0,0,0,0,0], mat1, 100) >>> model=DepthEucl().load_dataset(data) >>> x = np.random.multivariate_normal([1,1,1,1,1], mat2, 10) >>> model.projection(x, NRandom=1000) [0.090223 0.19577999 0.15769263 0.20123535 0.10375507 0.14635662 0.20611053 0.17846703 0.19801984 0.23230606]