microsoft/qlib · error · ValueError

Empty data from dataset, please check your dataset config.

Error message

Empty data from dataset, please check your dataset config.

What it means

IGMTFModel.fit prepares the train and valid segments and raises if either DataFrame is empty. Without train rows there is nothing to learn from, and without valid rows the early-stopping loop cannot score epochs, so the run is aborted as a dataset configuration error.

Source

Thrown at qlib/contrib/model/pytorch_igmtf.py:260

            score = self.metric_fn(pred, label)
            scores.append(score.item())

        return np.mean(losses), np.mean(scores)

    def fit(
        self,
        dataset: DatasetH,
        evals_result=dict(),
        save_path=None,
    ):
        df_train, df_valid = dataset.prepare(
            ["train", "valid"],
            col_set=["feature", "label"],
            data_key=DataHandlerLP.DK_L,
        )
        if df_train.empty or df_valid.empty:
            raise ValueError("Empty data from dataset, please check your dataset config.")

        x_train, y_train = df_train["feature"], df_train["label"]
        x_valid, y_valid = df_valid["feature"], df_valid["label"]

        save_path = get_or_create_path(save_path)
        stop_steps = 0
        train_loss = 0
        best_score = -np.inf
        best_epoch = 0
        evals_result["train"] = []
        evals_result["valid"] = []

        # load pretrained base_model
        if self.base_model == "LSTM":
            pretrained_model = LSTMModel()
        elif self.base_model == "GRU":
            pretrained_model = GRUModel()
        else:

View on GitHub (pinned to 79633dd950)

Solutions

  1. Check dataset.prepare('train') and dataset.prepare('valid') shapes before fit and fix whichever is empty
  2. Align segment dates with the actual data calendar (D.calendar)
  3. Verify provider_uri / data dump so instruments have rows

Example fix

# before
model.fit(dataset)  # segments: train (2025, 2026) but data ends 2020

# after
for seg in ("train", "valid"):
    assert not dataset.prepare(seg, col_set="feature").empty, seg
model.fit(dataset)
Defensive patterns

Strategy: validation

Validate before calling

for seg in ("train", "valid"):
    if dataset.prepare(seg, col_set=["feature", "label"], data_key=DataHandlerLP.DK_L).empty:
        raise RuntimeError(f"{seg} segment empty; fix DatasetH config/data")

Try / catch

try:
    model.fit(dataset)
except ValueError as e:
    if "Empty data" in str(e):
        # log segments + data calendar, fix config, retry once
        raise

Prevention

When it happens

Trigger: Calling fit(dataset) where dataset.prepare(['train','valid'], col_set=['feature','label'], data_key=DK_L) yields an empty train or valid frame: segments outside the data calendar, no instruments resolved, or labels all NaN.

Common situations: Misconfigured segment dates in DatasetH, missing qlib binary data (dump not run or wrong provider_uri), expression-engine features returning all NaN for the chosen instruments.

Related errors


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/2b5a4c74d30b9558. Report an issue: GitHub.