parallelkdepy.wrapper¶
High-level API: Functions and objects that wrap Julia calls.
Functions
|
Initialize a Dirac sequence on the given grid. |
Classes
|
Main API object for density estimation. |
|
Higher level implementation of a grid to use over meshgrid. |
- class parallelkdepy.wrapper.DensityEstimation(data: ndarray, *, grid: Grid | bool = False, dims: Sequence | None = None, grid_bounds: Sequence | None = None, grid_padding: Sequence | None = None, device: str = 'cpu')[source]¶
Bases:
objectMain API object for density estimation.
- property data¶
Numpy array of data points for density estimation.
- property density¶
Numpy array representing the estimated density.
- property device¶
Device type, e.g., ‘cpu’ or ‘cuda’.
- estimate_density(estimation: str, **kwargs) None[source]¶
Executes the density estimation algorithm on the data.
- generate_grid(dims: Sequence | None = None, grid_bounds: Sequence | None = None, grid_padding: Sequence | None = None, overwrite: bool = False) Grid[source]¶
Generates a grid based on the data and specified parameters.
- Returns:
A Grid object representing the generated grid.
- Return type:
- property grid¶
Grid used for density estimation, if any.
- class parallelkdepy.wrapper.Grid(ranges: Sequence[tuple] = [], *, device: str = 'cpu', b32: bool | None = None, grid_jl=None)[source]¶
Bases:
objectHigher level implementation of a grid to use over meshgrid.
- property device¶
Device type, e.g., ‘cpu’ or ‘cuda’.
- property grid_jl¶
Underlying Julia grid object.
- initial_bandwidth() list[source]¶
List of the minimum bandwidth that the grid can support in each dimension.
- property shape¶
Shape of the grid.
- parallelkdepy.wrapper.initialize_dirac_sequence(data: ndarray, grid: Grid, *, bootstrap_indices: ndarray | None = None, device: str = 'cpu', method: str | None = None) ndarray[source]¶
Initialize a Dirac sequence on the given grid.
- Parameters:
data (np.ndarray) – Data points to initialize the Dirac sequence.
grid (Grid) – The grid on which to initialize the Dirac sequence.
bootstrap_indices (Optional[np.ndarray], optional) – Numpy array of bootstrap indices, by default None. If provided, the shape should be (n_bootstraps, n_samples).
device (str, optional) – Device to store the array, e.g., ‘cpu’ or ‘cuda’, by default ‘cpu’.
method (str, optional) – Method to use for initialization, e.g., ‘serial’ or ‘parallel’, by default ‘serial’.
- Returns:
Numpy array representing the initialized Dirac sequence.
- Return type:
np.ndarray