leaspy.io.data.individual_data ============================== .. py:module:: leaspy.io.data.individual_data Classes ------- .. autoapisummary:: leaspy.io.data.individual_data.IndividualData Module Contents --------------- .. py:class:: IndividualData(idx) Container for an individual's data :Parameters: **idx** : IDType Unique ID :Attributes: **idx** : :class:`~leaspy.utils.typing.IDType` Unique ID **timepoints** : :obj:`np.ndarray` [:obj:`float`] Timepoints associated with the observations 1D array **observations** : :obj:`np.ndarray` [:obj:`float`] Observed data points, Shape is ``(n_timepoints, n_features)`` **cofactors** : :obj:`dict` [:class:`~leaspy.utils.typing.FeatureType`, :class:`~leaspy.utils.typing.Any`] Cofactors in the form {cofactor_name: cofactor_value} **event_time** : :obj:`float` Time of an event, if the event is censored, the time correspond to the last patient observation **event_bool** : :obj:`bool` Boolean to indicate if an event is censored or not: 1 observed, 0 censored .. !! processed by numpydoc !! .. py:attribute:: idx :type: leaspy.utils.typing.IDType .. py:attribute:: timepoints :type: numpy.ndarray :value: None .. py:attribute:: observations :type: numpy.ndarray :value: None .. py:attribute:: event_time :type: Optional[numpy.ndarray] :value: None .. py:attribute:: event_bool :type: Optional[numpy.ndarray] :value: None .. py:attribute:: cofactors :type: dict[leaspy.utils.typing.FeatureType, Any] .. py:attribute:: covariates :type: Optional[numpy.ndarray] :value: None .. py:method:: add_observations(timepoints, observations) Include new observations and associated timepoints :Parameters: **timepoints** : :obj:`array-like` [:obj:`float`] Timepoints associated with the observations to include, 1D array **observations** : :obj:`array-like` [:obj:`float`] Observations to include, 2D array :Raises: :exc:`.LeaspyDataInputError` .. .. !! processed by numpydoc !! .. py:method:: add_event(event_time, event_bool) Include event time and associated censoring bool :Parameters: **event_time** : :obj:`float` Time of the event **event_bool** : :obj:`float` 0 if censored (not observed) and 1 if observed .. !! processed by numpydoc !! .. py:method:: add_covariates(covariates) Include covariates :Parameters: **covariates** : :obj:`array-like` [:obj:`float`] Covariates to include, 2D array .. !! processed by numpydoc !! .. py:method:: add_cofactors(cofactors) Include new cofactors :Parameters: **cofactors** : :obj:`dict` [:class:`~leaspy.utils.typing.FeatureType`, :class:`~leaspy.utils.typing.Any`] Cofactors to include, in the form `{name: value}` :Raises: :exc:`.LeaspyDataInputError` .. :exc:`.LeaspyTypeError` .. .. !! processed by numpydoc !! .. py:method:: to_frame(headers, event_time_name, event_bool_name, covariate_names) Convert the individual data to a pandas DataFrame :Parameters: **headers** : :obj:`list` [:obj:`str`] List of feature names for the observations **event_time_name** : :obj:`str` Name of the column for the event time **event_bool_name** : :obj:`str` Name of the column for the event boolean (0 or 1) **covariate_names** : :obj:`list` [:obj:`str`] List of covariate names :Returns: :obj:`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 .. !! processed by numpydoc !!