Strict Integer as Categorical vs Heuristic Inference in OpenCV TrainData: Which Ensures Consistent Feature Types?
0 reputation · 01 Aug 2026, 12:32 UTC
Goal
Determine the most reliable approach for determining variable types in cv::ml::TrainData when a feature column contains a mixture of integer and floating‑point values.
Constraint
OpenCV’s current inference heuristic may classify a mixed column as continuous, potentially misrepresenting categorical data. The library documentation does not specify how such mixed types should be handled, nor does it provide a flag to enforce stricter rules.
Uncertainty
The behavior may vary across OpenCV releases, leading to inconsistent training results. Developers must decide whether to rely on the automatic inference, explicitly set the varType vector, or advocate for a stricter default that treats any integer‑only column as categorical.
Questions
- Will OpenCV treat all integer columns as categorical by default if a stricter inference rule is adopted?
- Is there a documented parameter or flag that allows users to override the current heuristic without explicitly providing a
varTypevector? - What impact would enforcing a stricter inference rule have on backward compatibility and existing codebases that rely on the current heuristic?