leaspy.io.data.individual_data¶
Classes¶
Container for an individual's data |
Module Contents¶
- class IndividualData(idx)[source]¶
Container for an individual’s data
- Parameters:
- idxIDType
Unique ID
- Attributes:
- idx
IDType Unique ID
- timepoints
np.ndarray[float] Timepoints associated with the observations 1D array
- observations
np.ndarray[float] Observed data points, Shape is
(n_timepoints, n_features)- cofactors
dict[FeatureType,Any] Cofactors in the form {cofactor_name: cofactor_value}
- event_time
float Time of an event, if the event is censored, the time correspond to the last patient observation
- event_bool
bool Boolean to indicate if an event is censored or not: 1 observed, 0 censored
- idx
- Parameters:
idx (IDType)
- cofactors: dict[FeatureType, Any]¶
- add_observations(timepoints, observations)[source]¶
Include new observations and associated timepoints
- add_cofactors(cofactors)[source]¶
Include new cofactors
- Parameters:
- cofactors
dict[FeatureType,Any] Cofactors to include, in the form {name: value}
- cofactors
- Raises:
- Parameters:
cofactors (dict[FeatureType, Any])
- Return type:
None
- to_frame(headers, event_time_name, event_bool_name, covariate_names)[source]¶
Convert the individual data to a pandas DataFrame
- Parameters:
- Returns:
pd.DataFrame- DataFrame containing the individual’s data with the following columns:
ID: Unique identifier for the individual
TIME: Timepoints associated with the observations
Observations: Observed data points for each feature
Event Time: Time of the event (if any)
Event Boolean: Boolean indicating if the event was observed (1) or censored (0)
Covariates: Values of the covariates for the individual
- Parameters:
- Return type: