{"record":{"id":"9891464f0f3704ab","repo":"HKUDS/Vibe-Trading","slug":"vif-test-needs-at-least-one-column","errorCode":null,"errorMessage":"vif_test needs at least one column","messagePattern":"vif_test needs at least one column","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/timeseries.py","lineNumber":754,"sourceCode":"        severe_threshold: VIF strictly above which collinearity is flagged\n            severe. A VIF exactly on the threshold is not flagged.\n        watch_threshold: VIF strictly above which collinearity is flagged as\n            worth watching. A VIF exactly on the threshold is not flagged.\n\n    Returns:\n        DataFrame with one row per column of ``X`` and columns ``feature``\n        (str), ``VIF`` (float) and ``concern`` (str, one of ``'severe'`` /\n        ``'watch'`` / ``'normal'``).\n\n    Raises:\n        ImportError: If ``statsmodels`` is not installed.\n        ValueError: If ``X`` has no columns.\n    \"\"\"\n    influence = _require(\n        \"statsmodels.stats.outliers_influence\", \"statsmodels\", \"vif_test\"\n    )\n    if X.shape[1] == 0:\n        raise ValueError(\"vif_test needs at least one column\")\n\n    values = np.asarray(X, dtype=float)\n    vifs = [float(influence.variance_inflation_factor(values, i)) for i in range(X.shape[1])]\n\n    return pd.DataFrame(\n        {\n            \"feature\": list(X.columns),\n            \"VIF\": vifs,\n            \"concern\": [\n                \"severe\" if v > severe_threshold else \"watch\" if v > watch_threshold else \"normal\"\n                for v in vifs\n            ],\n        }\n    )\n\n\ndef bootstrap_statistic(\n    data: np.ndarray,","sourceCodeStart":736,"sourceCodeEnd":772,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/timeseries.py#L736-L772","documentation":"vif_test requires the design matrix X to have at least one column; an empty (n, 0) frame cannot produce variance inflation factors. The check runs after statsmodels is imported and before any per-column VIF computation.","triggerScenarios":"vif_test(pd.DataFrame()) or vif_test(np.empty((100, 0))); commonly a feature-selection step removed all columns before the VIF pass.","commonSituations":"Pipelines that drop columns by variance/threshold filters and end up with none; empty config-driven feature lists; slicing bugs producing zero-width frames.","solutions":["Verify X.shape[1] > 0 before calling vif_test.","Fix the upstream filter that removed every column.","If no features is legitimately possible, skip the VIF stage conditionally."],"exampleFix":"// before\nvif_test(X_filtered)  # all columns were dropped by a variance filter\n// after\nif X_filtered.shape[1] == 0:\n    return pd.DataFrame(columns=[\"feature\", \"vif\"])\nvif_test(X_filtered)","handlingStrategy":"validation","validationCode":"assert X.shape[1] > 0, f\"vif_test needs columns, got shape {X.shape}\"\nvif_test(X)","typeGuard":"def has_columns(X) -> bool:\n    return getattr(X, \"shape\", (0, 0))[1] > 0","tryCatchPattern":null,"preventionTips":["Gate the VIF stage on X.shape[1] > 0 in pipelines.","Assert feature lists are non-empty after filtering steps."],"tags":["python","statistics","dataframe-validation"],"backgroundTag":"empty-dataframe-argument","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}