tempor.datasources.datasource module

Module defining the data source classes.

tempor.datasources.datasource.DATA_DIR = 'data'

The subdirectory on the user’s system where all data source files will be stored.

The full directory will be < tempor -> config -> working_directory > / DATA_DIR.

tempor.datasources.datasource.monkeypatch_ssl_error_workaround() Generator[source]

Some datasets (e.g. UCI diabetes) are hosted on servers that may have SSL issues. This is a workaround that monkeypatches the ssl module to ignore SSL errors temporarily.

class tempor.datasources.datasource.DataSource(**kwargs: Any)[source]

Bases: Plugin, ABC

DataSource class to load a DataSet.

Initializer for DataSource.

Parameters:
**kwargs : Any

Any additional keyword arguments for the DataSource.

data_root_dir : ClassVar[str] = '/home/docs/checkouts/readthedocs.org/user_builds/temporai/checkouts/latest/docs/data'

The automatically determined root directory for data on the user’s system. It will be < tempor -> config -> working_directory > / data.

abstract static dataset_dir() str | None[source]

The path to the directory where the data file(s) will be stored, if relevant. If the data source has no data files, return None.

Note

the path should correspond to a subdirectory within data_root_dir.

Returns:

The path of the directory where the data file(s) will be stored, if relevant, else None.

Return type:

Optional[str]

abstract static url() str | None[source]

Define the URL of the data source, if relevant, otherwise return None.

Returns:

The URL of the data source, if relevant, otherwise None.

Return type:

Optional[str]

classmethod requires_internet() bool[source]

A classmethod that returns true if the DataSource requires access to the Internet to load (at least before it is saved locally).

Returns True if cls.url() is not None, else returns False.

Returns:

Whether the DataSource requires Internet access to load.

Return type:

bool

abstract property predictive_task : PredictiveTask

The expected predictive task of the loaded dataset.

Returns:

Predictive task of loaded dataset.

Return type:

data_typing.PredictiveTask

abstract load(**kwargs: Any) PredictiveDataset[source]

The method that should return the loaded dataset for the appropriate predictive_task.

Parameters:
**kwargs : Any

Any additional keyword arguments.

Returns:

The loaded dataset.

Return type:

dataset.PredictiveDataset

class tempor.datasources.datasource.OneOffPredictionDataSource(**kwargs: Any)[source]

Bases: DataSource

Initializer for DataSource.

Parameters:
**kwargs : Any

Any additional keyword arguments for the DataSource.

property predictive_task : PredictiveTask

The expected predictive task of the loaded dataset. Here, it is ONE_OFF_PREDICTION.

Returns:

Predictive task of loaded dataset. Here, it is ONE_OFF_PREDICTION.

Return type:

data_typing.PredictiveTask

abstract load(**kwargs: Any) OneOffPredictionDataset[source]

The method that should return a one-off prediction dataset.

Parameters:
**kwargs : Any

Any additional keyword arguments.

Returns:

The loaded dataset.

Return type:

dataset.OneOffPredictionDataset

class tempor.datasources.datasource.TemporalPredictionDataSource(**kwargs: Any)[source]

Bases: DataSource

Initializer for DataSource.

Parameters:
**kwargs : Any

Any additional keyword arguments for the DataSource.

property predictive_task : PredictiveTask

The expected predictive task of the loaded dataset. Here, it is TEMPORAL_PREDICTION.

Returns:

Predictive task of loaded dataset. Here, it is TEMPORAL_PREDICTION.

Return type:

data_typing.PredictiveTask

abstract load(**kwargs: Any) TemporalPredictionDataset[source]

The method that should return a temporal prediction dataset.

Parameters:
**kwargs : Any

Any additional keyword arguments.

Returns:

The loaded dataset.

Return type:

dataset.TemporalPredictionDataset

class tempor.datasources.datasource.TimeToEventAnalysisDataSource(**kwargs: Any)[source]

Bases: DataSource

Initializer for DataSource.

Parameters:
**kwargs : Any

Any additional keyword arguments for the DataSource.

property predictive_task : PredictiveTask

The expected predictive task of the loaded dataset. Here, it is TIME_TO_EVENT_ANALYSIS.

Returns:

Predictive task of loaded dataset. Here, it is TIME_TO_EVENT_ANALYSIS.

Return type:

data_typing.PredictiveTask

abstract load(**kwargs: Any) TimeToEventAnalysisDataset[source]

The method that should return a time-to-event analysis dataset.

Parameters:
**kwargs : Any

Any additional keyword arguments.

Returns:

The loaded dataset.

Return type:

dataset.TimeToEventAnalysisDataset

class tempor.datasources.datasource.OneOffTreatmentEffectsDataSource(**kwargs: Any)[source]

Bases: DataSource

Initializer for DataSource.

Parameters:
**kwargs : Any

Any additional keyword arguments for the DataSource.

property predictive_task : PredictiveTask

The expected predictive task of the loaded dataset. Here, it is ONE_OFF_TREATMENT_EFFECTS.

Returns:

Predictive task of loaded dataset. Here, it is ONE_OFF_TREATMENT_EFFECTS.

Return type:

data_typing.PredictiveTask

abstract load(**kwargs: Any) OneOffTreatmentEffectsDataset[source]

The method that should return a one-off treatment effects dataset.

Parameters:
**kwargs : Any

Any additional keyword arguments.

Returns:

The loaded dataset.

Return type:

dataset.OneOffTreatmentEffectsDataset

class tempor.datasources.datasource.TemporalTreatmentEffectsDataSource(**kwargs: Any)[source]

Bases: DataSource

Initializer for DataSource.

Parameters:
**kwargs : Any

Any additional keyword arguments for the DataSource.

property predictive_task : PredictiveTask

The expected predictive task of the loaded dataset. Here, it is TEMPORAL_TREATMENT_EFFECTS.

Returns:

Predictive task of loaded dataset. Here, it is TEMPORAL_TREATMENT_EFFECTS.

Return type:

data_typing.PredictiveTask

abstract load(**kwargs: Any) TemporalTreatmentEffectsDataset[source]

The method that should return a temporal treatment effects dataset.

Parameters:
**kwargs : Any

Any additional keyword arguments.

Returns:

The loaded dataset.

Return type:

dataset.TemporalTreatmentEffectsDataset