pflm.utils.FlattenFunctionalData#
- class FlattenFunctionalData(y: ndarray, t: ndarray, w: ndarray, tid: ndarray, unique_tid: ndarray, inverse_tid_idx: ndarray, sid: ndarray, unique_sid: ndarray, sid_cnt: ndarray)[source][source]#
Bases:
objectFlattened functional dataset in 1D arrays with indexing helpers.
- Attributes:
- ynp.ndarray of shape (M,)
Flattened responses after removing NaN.
- tnp.ndarray of shape (M,)
Flattened time points aligned to y.
- wnp.ndarray of shape (M,)
Per-observation weights expanded from sample-level weights.
- tidnp.ndarray of shape (M,)
Integer indices mapping each t to its position in unique_tid.
- unique_tidnp.ndarray of shape (nt,)
Sorted unique time points (observation grid).
- inverse_tid_idxnp.ndarray of shape (M,)
Inverse mapping indices from t back to unique_tid.
- sidnp.ndarray of shape (M,)
Sample id for each observation (0-based).
- unique_sidnp.ndarray of shape (n_samples,)
Unique sample ids present in the data.
- sid_cntnp.ndarray of shape (n_samples,)
Number of observations for each sample id.
Examples
>>> import numpy as np >>> from pflm.utils.utility import flatten_and_sort_data_matrices >>> y = [np.array([1.0, 2.0]), np.array([3.0, 4.0, 5.0])] >>> t = [np.array([0.0, 1.0]), np.array([0.0, 0.5, 1.0])] >>> ffd = flatten_and_sort_data_matrices(y, t) >>> ffd.y.shape (5,) >>> ffd.unique_sid.shape (2,)