{"record":{"id":"b8b081b9192c8a9d","repo":"HKUDS/Vibe-Trading","slug":"unsupported-model-type-model-type","errorCode":null,"errorMessage":"Unsupported model_type: {model_type}","messagePattern":"Unsupported model_type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/skills/ml-strategy/SKILL.md","lineNumber":159,"sourceCode":"\n            # Standardization: fit only on training set\n            scaler = StandardScaler()\n            X_train = scaler.fit_transform(X_train)\n\n            # Build the model\n            if model_type == \"random_forest\":\n                model = RandomForestClassifier(\n                    n_estimators=100, max_depth=5, random_state=42,\n                )\n            elif model_type == \"gradient_boosting\":\n                model = GradientBoostingClassifier(\n                    n_estimators=100, max_depth=3, learning_rate=0.05,\n                    random_state=42,\n                )\n            elif model_type == \"ridge\":\n                model = LogisticRegression(penalty=\"l2\", C=1.0, random_state=42)\n            else:\n                raise ValueError(f\"Unsupported model_type: {model_type}\")\n\n            model.fit(X_train, y_train)\n\n        # Predict today\n        X_today = features.iloc[i : i + 1].values\n        if np.isnan(X_today).any():\n            predictions.iloc[i] = 0.0\n            continue\n\n        X_today = scaler.transform(X_today)\n\n        if hasattr(model, \"predict_proba\"):\n            prob = model.predict_proba(X_today)[0, 1]\n            predictions.iloc[i] = prob * 2 - 1  # [0,1] -> [-1,1]\n        else:\n            predictions.iloc[i] = float(model.predict(X_today)[0])\n\n    # Output contract: no NaN, clipped to [-1, 1]","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/skills/ml-strategy/SKILL.md#L141-L177","documentation":"This walk-forward ML training loop in the ml-strategy skill instantiates a model by branching on model_type, supporting 'xgboost' (or a tree booster config) and 'ridge' (L2 logistic regression). Any other value falls through to else: raise ValueError(f\"Unsupported model_type: {model_type}\") — a typo or unsupported algorithm is rejected before fit().","triggerScenarios":"Passing model_type strings such as 'random_forest', 'lstm', 'XGBoost' (wrong case), 'ridge ' (trailing space), or 'lightgbm' — typically from a strategy config YAML/CLI arg.","commonSituations":"Config copy-paste from other projects expecting scikit-learn estimator names, case sensitivity, whitespace from templated config files, or an attempt to use a model the skill simply doesn't implement.","solutions":["Set model_type to exactly 'xgboost' or 'ridge' (lowercase, no whitespace)","Strip/normalize the config value before use: model_type.strip().lower()","If you need another estimator, extend the if/elif chain with a new branch that constructs and fits it"],"exampleFix":"# before\nmodel = train_walkforward(features, target, model_type=\"RandomForest\")\n\n# after\nmodel = train_walkforward(features, target, model_type=\"xgboost\")  # or \"ridge\"","handlingStrategy":"type-guard","validationCode":"SUPPORTED_MODELS = {\"xgboost\", \"ridge\"}\n\nmodel_type = str(cfg.get(\"model_type\", \"\")).strip().lower()\nif model_type not in SUPPORTED_MODELS:\n    raise ValueError(f\"model_type must be one of {sorted(SUPPORTED_MODELS)}, got {model_type!r}\")","typeGuard":"def is_supported_model_type(value: str) -> bool:\n    return str(value or \"\").strip().lower() in {\"xgboost\", \"ridge\"}","tryCatchPattern":"try:\n    model = train_walkforward(features, target, model_type=model_type)\nexcept ValueError as e:\n    if str(e).startswith(\"Unsupported model_type\"):\n        raise ConfigError(f\"fix strategy config: {e}\") from e\n    raise","preventionTips":["Normalize model_type (strip/lower) at config load","Define the allowed set in one constant shared by config validation and the trainer","Reject unknown keys in strategy YAML instead of silently passing them through"],"tags":["machine-learning","enum-value","config","strategy"],"backgroundTag":"unsupported-enum-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}