If you are looking to contribute to TemporAI, this guide is a good starting point.
✅ Please read the Contributing Guide first.
.
├── .github/: GitHub workflows (CI/CD)
├── docs/: Sphinx documentation content
├── src/: Source code
├── tests/: Tests (pytest)
├── tutorials/: Jupyter notebook tutorials
└── <root files>: Configuration files, README, and LICENSE
The source code is located under src/tempor
, the code organization is shown below.
.
└── tempor/
├── automl: AutoML tools
├── benchmarks: Benchmarking tools
├── config: Library config
├── core: Core code, such as global utils
├── data: Data format
├── datasources: Data sources for provided datasets
├── exc: Exceptions
├── log: Logger
├── models: Model components
├── plugins: Plugins/
│ ├── core: The core plugin mechanism, base classes
│ ├── pipeline: Pipeline mechanism
│ ├── prediction: Prediction plugins
│ ├── preprocessing: Preprocessing plugins
│ ├── time_to_event: Time-to-event plugins
│ └── treatments: Treatment effects plugins
└── utils: Utilities/
└── serialization: Serialization tools
Tests located in the tests
directory follow the directory structure of the source code.
The project contains the following config files:
.coveragerc
: coverage config..isort.cfg
: isort config..pre-commit-config.yaml
: pre-commit config..readthedocs.yml
: ReadTheDocs config.codecov.yml
: codecov config.mypy.ini
: mypy config.pyproject.toml
: miscellaneous setup and tools configuration in the pyproject.toml form.pytest.ini
: pytest config.setup.cfg
: miscellaneous setup and tools configuration in the setuptools setup.cfg config.tox.ini
: tox config.
Please familiarize yourself with the data format we use.
- Go through the data tutorials.
- See the following parts of the full API (module) reference:
Usage
It is recommended to go through the usage tutorials before contributing.
Extending
🔥 The extending guide provides a great starring point for developing new methods.
The sklearn-inspired fit/transform/predict
API is used for the methods. This section briefly describes the base classes used to achieve this. Full details are available in the API documentation linked for each class.
:::{caution} TemporAI is in alpha, and the details of the API may change. :::
All method plugins derive from BaseEstimator
:
Methods worth noting are: fit
(fits model), hyperparameter_space
(abstract method, returns the default hyperparameter space), sample_hyperparameters
(implements sampling of said hyperparameters). The _fit
method is the abstract method that the concrete plugins should implement (it will be called by fit
).
Note also that the BaseEstimator
inherits from the Plugin
interface, which facilitates loading of the methods by the PluginLoader.
ParamsDefinition
attribute facilitates accessing the class parameters using self.params
in the derived classes.
All predictive method plugins derive from BasePredictor
:
This base class adds prediction-specific methods (analogously to _fit/fit
):
predict
(public API) and_predict
(for concrete implementation by each plugin): return predicted values.predict_proba
and_predict_proba
: return predicted probabilities, classification setting only.predict_counterfactuals
and_predict_counterfactuals
: return counterfactual predictions, treatment effects setting only.
Some of these methods are defined further in task-specific base classes.
All preprocessing data transformation method plugins derive from BaseTransformer
:
This base class provides the transform
(public API) and _transform
(for concrete implementation by each plugin) methods that take in, and return a transformed version of, a Dataset
.
These are the base classes for imputation ("preprocessing.imputation"
) and scaling imputation ("preprocessing.scaling"
). These currently do not differ from BaseTransformer
.
BaseTimeToEventAnalysis
is the base class for time-to-event (survival) analysis. Note that the predict
method requires a horizons
argument to specify time points for risk estimation.
This class expects TimeToEventAnalysisDataset
.
BaseOneOffTreatmentEffects
is the base class for one-off treatment effects plugins. predict_counterfactuals
returns StaticSamples
.
This class expects OneOffTreatmentEffectsDataset
.
BaseTemporalTreatmentEffects
is the base class for temporal treatment effects plugins. predict_counterfactuals
returns TimeSeriesSamples
.
This class expects BaseTemporalTreatmentEffectsDataset
.
These are the base classes for the one-off prediction setting, where the targets are static values.
-
BaseOneOffClassifier
, base class for one-off classification task plugins:{w=600px}
-
BaseOneOffRegressor
, base class for one-off regression task plugins:{w=600px}
These classes expects OneOffPredictionDataset
.
These are the base classes for the temporal prediction setting, where the targets are time series.
-
BaseTemporalClassifier
, base class for one-off classification task plugins:{w=600px}
-
BaseTemporalRegressor
, base class for one-off regression task plugins:{w=600px}
These classes expects TemporalPredictionDataset
.
The Pipeline
functionality is provided by the tempor.methods.pipeline
module, see especially:
PipelineBase
base class (defines pipeline interface),PipelineMeta
metaclass (dynamically generates pipelines),pipeline
function (creates pipeline from its definition).
The tempor.models
namespace contains various underlying model components (currently mostly torch
modules), such as MLP
, general-purpose TimeSeriesModel
, NeuralODE
, etc. Feel free to use or build upon these in your methods.
For implementing custom data formats (experimental), se the "Custom Data Format" tutorial in the extending guide.