Skip to content

🧪 TimeSeriesDataset

A time series dataset maps feature to a target column. It can be used to train machine learning models.

Data can be segmented into windows when loading it into the models.

Parent type: Dataset<Table, Column<Any?>>

Parameters:

Name Type Description Default
data union<Map<String, List<Any>>, Table> The data. -
targetName String The name of the target column. -
windowSize Int The number of consecutive sample to use as input for prediction. -
extraNames List<String>? Names of the columns that are neither features nor target. If None, no extra columns are used, i.e. all but the target column are used as features. null
forecastHorizon Int The number of time steps to predict into the future. 1
continuous Boolean Whether or not to continue the forecast in the steps before forecast horizon. false

Examples:

pipeline example {
    val dataset = TimeSeriesDataset(
        {"time": [1, 2, 3], "feature": [4, 5, 6], "target": [1, 2, 3], "id": [1, 2, 3]},
        targetName = "target",
        windowSize = 1,
        extraNames = ["id"]
    );
}
Stub code in TimeSeriesDataset.sdsstub
class TimeSeriesDataset(
    data: union<Map<String, List<Any>>, Table>,
    @PythonName("target_name") targetName: String,
    @PythonName("window_size") windowSize: Int,
    @PythonName("extra_names") extraNames: List<String>? = null,
    @PythonName("forecast_horizon") forecastHorizon: Int = 1,
    continuous: Boolean = false
) sub Dataset<Table, Column> {
    /**
     * The feature columns of the time series dataset.
     */
    attr features: Table
    /**
     * The target column of the time series dataset.
     */
    attr target: Column<Any>
    /**
     * The number of consecutive sample to use as input for prediction.
     */
    @PythonName("window_size") attr windowSize: Int
    /**
     * The number of time steps to predict into the future.
     */
    @PythonName("forecast_horizon") attr forecastHorizon: Int
    /**
     * True if the time series will make a continuous prediction.
     */
    attr continuous: Boolean
    /**
     * Additional columns of the time series dataset that are neither features nor target.
     *
     * These can be used to store additional information about instances, such as IDs.
     */
    attr extras: Table

    /**
     * Return a new `Table` containing the feature columns, the target column and the extra columns.
     *
     * The original `TimeSeriesDataset` is not modified.
     *
     * @result table A table containing the feature columns, the target column and the extra columns.
     *
     * @example
     * pipeline example {
     *     val dataset = TimeSeriesDataset(
     *         {"time": [1, 2, 3], "feature": [4, 5, 6], "target": [1, 2, 3], "id": [1, 2, 3]},
     *         targetName = "target",
     *         windowSize = 1,
     *         extraNames = ["id"]
     *     );
     *     val result = dataset.toTable();
     * }
     */
    @Pure
    @PythonName("to_table")
    fun toTable() -> table: Table
}

continuous

True if the time series will make a continuous prediction.

Type: Boolean

extras

Additional columns of the time series dataset that are neither features nor target.

These can be used to store additional information about instances, such as IDs.

Type: Table

features

The feature columns of the time series dataset.

Type: Table

forecastHorizon

The number of time steps to predict into the future.

Type: Int

target

The target column of the time series dataset.

Type: Column<Any>

windowSize

The number of consecutive sample to use as input for prediction.

Type: Int

toTable

Return a new Table containing the feature columns, the target column and the extra columns.

The original TimeSeriesDataset is not modified.

Results:

Name Type Description
table Table A table containing the feature columns, the target column and the extra columns.

Examples:

pipeline example {
    val dataset = TimeSeriesDataset(
        {"time": [1, 2, 3], "feature": [4, 5, 6], "target": [1, 2, 3], "id": [1, 2, 3]},
        targetName = "target",
        windowSize = 1,
        extraNames = ["id"]
    );
    val result = dataset.toTable();
}
Stub code in TimeSeriesDataset.sdsstub
@Pure
@PythonName("to_table")
fun toTable() -> table: Table