microsoft/qlib · error · ValueError
The type of dataset is not DatasetH instead of {:}
Error message
The type of dataset is not DatasetH instead of {:} What it means
MultiSegRecord (qlib/contrib/workflow/record_temp.py) generates predictions per segment by calling model.predict(dataset, segment) and dataset.prepare(segments=..., ...), both of which are DatasetH APIs. The constructor therefore enforces isinstance(dataset, DatasetH) and raises ValueError naming the actual type otherwise.
Source
Thrown at qlib/contrib/workflow/record_temp.py:28
from ...contrib.eva.alpha import calc_ic
from ...workflow.record_temp import RecordTemp
from ...workflow.record_temp import SignalRecord
from ...data import dataset as qlib_dataset
from ...log import get_module_logger
logger = get_module_logger("workflow", logging.INFO)
class MultiSegRecord(RecordTemp):
"""
This is the multiple segments signal record class that generates the signal prediction.
This class inherits the ``RecordTemp`` class.
"""
def __init__(self, model, dataset, recorder=None):
super().__init__(recorder=recorder)
if not isinstance(dataset, qlib_dataset.DatasetH):
raise ValueError("The type of dataset is not DatasetH instead of {:}".format(type(dataset)))
self.model = model
self.dataset = dataset
def generate(self, segments: Dict[Text, Any], save: bool = False):
for key, segment in segments.items():
predics = self.model.predict(self.dataset, segment)
if isinstance(predics, pd.Series):
predics = predics.to_frame("score")
labels = self.dataset.prepare(
segments=segment, col_set="label", data_key=qlib_dataset.handler.DataHandlerLP.DK_R
)
# Compute the IC and Rank IC
ic, ric = calc_ic(predics.iloc[:, 0], labels.iloc[:, 0])
results = {"all-IC": ic, "mean-IC": ic.mean(), "all-Rank-IC": ric, "mean-Rank-IC": ric.mean()}
logger.info("--- Results for {:} ({:}) ---".format(key, segment))
ic_x100, ric_x100 = ic * 100, ric * 100
logger.info("IC: {:.4f}%".format(ic_x100.mean()))
logger.info("ICIR: {:.4f}%".format(ic_x100.mean() / ic_x100.std()))View on GitHub (pinned to 79633dd950)
Solutions
- Build your dataset with DatasetH (qlib.data.dataset.DatasetH) before creating MultiSegRecord
- If you use a custom dataset, either inherit from DatasetH or use a RecordTemp subclass that calls your own predict/prepare API
- Make sure you pass the dataset object itself, not its handler or the underlying DataFrame
Example fix
# before
from qlib.data.dataset.handler import DataHandlerLP
rec = MultiSegRecord(model=model, dataset=my_handler)
# after
from qlib.data.dataset import DatasetH
dataset = DatasetH(handler=my_handler, segments={"train": (...), "test": (...)})
rec = MultiSegRecord(model=model, dataset=dataset) Defensive patterns
Strategy: type-guard
Validate before calling
from qlib.data.dataset import DatasetH
assert isinstance(dataset, DatasetH), f'MultiSegRecord needs DatasetH, got {type(dataset).__name__}'
rec = MultiSegRecord(model=model, dataset=dataset) Type guard
from qlib.data.dataset import DatasetH
def is_dataset_h(obj) -> bool:
return isinstance(obj, DatasetH) Prevention
- Construct record templates with objects produced by qlib's own dataset factory (DatasetH), not raw handlers or DataFrames
- Custom dataset classes should either subclass DatasetH or skip MultiSegRecord in favor of a custom RecordTemp
When it happens
Trigger: Passing anything other than a qlib.data.dataset.DatasetH instance to MultiSegRecord(model=..., dataset=...) — e.g. a plain DataFrame, a custom dataset class, or an DatasetH subclass imported from a different module path (isinstance still passes for real subclasses).
Common situations: Wiring record templates into a custom workflow whose dataset is a user-defined class; passing the handler instead of the dataset by mistake; newer qlib refactorings splitting DatasetH across modules.
Related errors
- This type of signal is not supported
- This type of input is not supported
- This type of input is not supported
- Please make sure the recorder has been created and started p
- The fetched task must be `STATUS_WAITING` or `STATUS_PART_DO
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/18cd37d787d57494.
Report an issue: GitHub.