技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
data-pipeline【数据与研究】Prepare tabular time-series data for PyTorch Forecasting v1 TimeSeriesDataSet, encoders, normalizers, dataloaders, serialization, and validation.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the task is to turn a pandas-style tabular time-series DataFrame into PyTorch Forecasting 1.8.0 data objects for training, validation, testing, or prediction. The primary API is pytorch_forecasting.TimeSeriesDataSet and the v1 data utilities under pytorch_forecasting.data.
time_idx, target, group_ids, static covariates, known-future covariates, unknown-future covariates, weights, lags, encoders, scalers, and target normalizers.TimeSeriesDataSet objects for train/validation/test/predict workflows with TimeSeriesDataSet.from_dataset() or TimeSeriesDataSet.from_parameters().TimeSeriesDataSet.to_dataloader() and understanding returned batch keys and shapes..from_dataset() model construction, checkpoint loading, and prediction API details belong in ../forecasting-models/SKILL.md.../metrics-and-tuning/SKILL.md.TimeSeries and EncoderDecoderTimeSeriesDataModule workflows belong in ../api-v2-workflows/SKILL.md.references/time-series-dataset.md when you need the v1 TimeSeriesDataSet constructor contract, column-role map, train/validation/inference recipes, normalizer/encoder notes, dataloader shapes, serialization, and validation snippets.references/data-validation-and-troubleshooting.md when data construction fails or behaves unexpectedly; it maps symptoms to likely causes and concrete recovery steps for NaNs, gaps, short series, categorical unknowns, normalizers, and shape surprises.scripts/validate_timeseries_dataframe.py before constructing a dataset from a CSV to catch missing required columns, duplicate group/time rows, target NaNs, role overlap, non-integer time indexes, sort issues, gaps, and too-short groups without importing PyTorch Forecasting.from pytorch_forecasting import TimeSeriesDataSet
from pytorch_forecasting.data import GroupNormalizer, NaNLabelEncoder
training = TimeSeriesDataSet(
train_df,
time_idx="time_idx", # integer, increasing within each group
target="sales", # continuous or categorical target column
group_ids=["store", "sku"], # columns that identify one series
max_encoder_length=36,
max_prediction_length=6,
static_categoricals=["store", "sku"],
time_varying_known_reals=["time_idx", "price", "promotion"],
time_varying_unknown_reals=["sales"],
target_normalizer=GroupNormalizer(groups=["store", "sku"], transformation="log1p"),
categorical_encoders={"sku": NaNLabelEncoder(add_nan=True)},
)
validation = TimeSeriesDataSet.from_dataset(
training,
full_df,
min_prediction_idx=train_df["time_idx"].max() + 1,
stop_randomization=True,
)
train_loader = training.to_dataloader(train=True, batch_size=64, num_workers=0)
val_loader = validation.to_dataloader(train=False, batch_size=64, num_workers=0)
If a task starts from CSV, run the bundled validator first, then use the references above to construct the actual TimeSeriesDataSet.