Block View
- class BlockView
View data as pattern-aligned blocks.
- __init__(pattern_provider: CIT_DataPatterned, cache_id: object | None, x_blocks: ndarray, y_blocks: ndarray, z_blocks: ndarray) None
Construct block-view from reference to pattern-provider and block-views of X, Y, Z.
See also
In most cases, the user should use
CIT_DataPatterned.view_blocks()instead. This constructor is primarily for internal use.
- pattern_provider: CIT_DataPatterned
Pattern-provider used to generate this view. Primarily for internal use in convenience-functions like
match_blocksize().
- cache_id: object | None
unique identifier associated to the data by the data-manager, to be used for caching results of tests. None to disable caching (eg for bootstrap)
- x_blocks: ndarray
shape=(n,B) with n the block-count, B the block-size
- y_blocks: ndarray
shape=(n,B) with n the block-count, B the block-size
- z_blocks: ndarray
shape=(n,B,k) with n the block-count, B the block-size, k=dim(Z)
- copy_and_center() BlockView
Copy and subtract mean. (Used internally by cit to structure residuals correctly, no cach-id required.)
- Returns:
Centered copy
- Return type:
- block_size() int
Get block-size (total number of samples per block).
- Returns:
block-size
- Return type:
int
- block_count() int
Get block-count.
- Returns:
block-count
- Return type:
int
- sample_count_used() int
Get number of used (contained in a block) data-points.
- Returns:
used sample-size
- Return type:
int
- z_dim() int
Get z-dimension (number of variables in the conditioning set Z).
- Returns:
dim(Z)
- Return type:
int
- trivialize() BlockView
View data as trivial (a single block of block-size=sampe-size) blocks.
- Returns:
trivial block-view
- Return type:
- match_blocksize(other: BlockView) BlockView
View data as blocks with size matching another block-view.
- apply_blockformat(X: ndarray, Y: ndarray, Z: ndarray | None = None) BlockView
Given data for X, Y, Z, match to current block-size settings. (Used internally by cit to structure residuals correctly, no cach-id required.)
- Parameters:
X (np.ndarray) – X
Y (np.ndarray) – Y
Z (np.ndarray | None, optional) – Z, defaults to None
- Returns:
block-view of given data matching current size
- Return type:
- bootstrap_unaligned_blocks(rng: Generator, bootstrap_block_count: int) BlockView
Bootstrap random (unaligned) blocks.
- Parameters:
rng (np.random.Generator (or similar, requires .integers behaving as numpy.random.Generator)) – A random number generator.
bootstrap_block_count (int) – Number of blocks to bootstrap
- Returns:
The bootstrapped blocks (actually a copy, not a view, despite being typed as block-“view”).
- Return type: