{"record":{"id":"ee762091a18c982d","repo":"microsoft/qlib","slug":"empty-data-from-dataset-please-check-your-dataset-ee7620","errorCode":null,"errorMessage":"Empty data from dataset, please check your dataset config.","messagePattern":"Empty data from dataset, please check your dataset config\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/contrib/model/pytorch_tabnet.py","lineNumber":172,"sourceCode":"        evals_result=dict(),\n        save_path=None,\n    ):\n        if self.pretrain:\n            # there is a  pretrained model, load the model\n            self.logger.info(\"Pretrain...\")\n            self.pretrain_fn(dataset, self.pretrain_file)\n            self.logger.info(\"Load Pretrain model\")\n            self.tabnet_model.load_state_dict(torch.load(self.pretrain_file, map_location=self.device))\n\n        # adding one more linear layer to fit the final output dimension\n        self.tabnet_model = FinetuneModel(self.out_dim, self.final_out_dim, self.tabnet_model).to(self.device)\n        df_train, df_valid = dataset.prepare(\n            [\"train\", \"valid\"],\n            col_set=[\"feature\", \"label\"],\n            data_key=DataHandlerLP.DK_L,\n        )\n        if df_train.empty or df_valid.empty:\n            raise ValueError(\"Empty data from dataset, please check your dataset config.\")\n        df_train.fillna(df_train.mean(), inplace=True)\n        x_train, y_train = df_train[\"feature\"], df_train[\"label\"]\n        x_valid, y_valid = df_valid[\"feature\"], df_valid[\"label\"]\n        save_path = get_or_create_path(save_path)\n\n        stop_steps = 0\n        train_loss = 0\n        best_score = -np.inf\n        best_epoch = 0\n        evals_result[\"train\"] = []\n        evals_result[\"valid\"] = []\n\n        self.logger.info(\"training...\")\n        self.fitted = True\n\n        for epoch_idx in range(self.n_epochs):\n            self.logger.info(\"epoch: %s\" % (epoch_idx))\n            self.logger.info(\"training...\")","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/contrib/model/pytorch_tabnet.py#L154-L190","documentation":"Raised by TabNet model fit() in qlib/contrib/model/pytorch_tabnet.py:172 when the train or valid DataFrame from dataset.prepare(['train','valid']) is empty. Standard qlib data guard: it fires before NaN-filling and training, indicating the handler/dataset config produced zero rows for a required segment.","triggerScenarios":"Segment dates outside the dumped data calendar; handler expressions filtering out all rows; wrong provider_uri / no qlib.init; also fires after the optional pretrain branch, so pretrain may succeed while the finetune 'train'/'valid' segments are empty.","commonSituations":"Using pretrain segments that exist but train/valid boundaries misconfigured; examples run against a market different from the downloaded dump; custom instruments missing from the dump.","solutions":["Check which segment is empty: dataset.prepare('train', col_set=['feature','label']).empty and same for 'valid'.","Align segment date ranges with the data calendar and instrument universe.","Verify qlib.init(provider_uri=...) and that the dump contains your instruments.","If using named segments, ensure DatasetH.segments defines 'train' and 'valid'."],"exampleFix":"# before\ntrain: [2008-01-01, 2024-12-31]   # dump ends 2020\n\n# after\ntrain: [2008-01-01, 2014-12-31]\nvalid: [2015-01-01, 2020-12-31]","handlingStrategy":"validation","validationCode":"for seg in (\"train\", \"valid\"):\n    df = dataset.prepare(seg, col_set=[\"feature\", \"label\"], data_key=\"learn\")\n    if df.empty:\n        raise ValueError(f\"TabNet fit(): segment '{seg}' empty — check segment config and data dump\")","typeGuard":null,"tryCatchPattern":"try:\n    model.fit(dataset)\nexcept ValueError as e:\n    if \"Empty data\" in str(e):\n        print({s: dataset.prepare(s, col_set=[\"feature\", \"label\"]).shape for s in (\"train\", \"valid\")})\n        raise\n    raise","preventionTips":["Verify train/valid segments are non-empty before fit(), especially when pretrain segments are also configured.","Keep segment dates inside the dumped calendar and instruments present in the dump.","Smoke-test the handler expression on a small date window first."],"tags":["qlib","dataset","empty-data","config","data-validation","tabnet"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}