lir.data_setup package
Submodules
lir.data_setup.inference module
- class lir.data_setup.inference.InferenceDataSetup(training: DataProvider | None, inference: DataProvider | None)[source]
Bases:
DataSetupA data setup that uses two separate data providers for training and inference.
If no data provider for training is specified, the training phase is skipped and the model is assumed to be fitted.
If no data provider for inference is specified, the model will be trained only, and the inference phase is skipped.
- Parameters:
training (DataProvider, optional) – The
DataProviderthat loads the training data.inference (DataProvider, optional) – The
DataProviderthat loads the inference data.
- get_train_inference_pairs() Iterable[tuple[InstanceData | None, InstanceData | None]][source]
Return the training and inference data as a single (training, inference) pair.
The instances of the data providers are fetched once and cached, so consecutive calls return the same data.
- Returns:
An iterator over a single tuple of (training data, inference data), where an element is None if the corresponding data provider is not configured.
- Return type:
Iterable[tuple[InstanceData | None, InstanceData | None]]
lir.data_setup.train_test_split module
- class lir.data_setup.train_test_split.SplitDataSetup(provider: DataProvider, strategy: DataStrategy, data_filter: Transformer | None, use_cache: bool = True)[source]
Bases:
DataSetupA data setup that uses a single data provider to construct pairs of training and test sets.
A split data setup consists of three components: a data provider, a filter, and a strategy.
The filter is a
Transformerthat supports calling the apply() method without first calling fit(). Unlike in LR system pipelines, this transformer may change the number of instances in the dataset.- Parameters:
provider (DataProvider) –
- The
DataProviderthat retrieves the data from some data source, such as a CSV file or a database.
- The
strategy (DataStrategy) – The
DataStrategythat determines how the data are used.data_filter (Transformer | None) – An optional filter (
Transformer) to apply to the raw data before doing anything else.use_cache (bool, optional) – If
True, the train/inference pairs will be cached locally. Defaults toTrue.
- get_train_inference_pairs() Iterable[tuple[InstanceData, InstanceData]][source]
Return the data in the form of one or more train/test splits.
This method follows three steps: - retrieve instances from the data provider; - pass them through the filter by calling its apply() method; - apply the data strategy to arrange them into one or more train/test splits.
This method caches results for speeding up consecutive calls if the class is instantiated with
use_cache=True.- Returns:
An iterator over tuples of train/test splits.
- Return type:
Iterable[tuple[InstanceData, InstanceData]]