HKUDS/Vibe-Trading · error · ValueError
Unsupported model_type: {model_type}
Error message
Unsupported model_type: {model_type} What it means
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().
Source
Thrown at agent/src/skills/ml-strategy/SKILL.md:159
# Standardization: fit only on training set
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
# Build the model
if model_type == "random_forest":
model = RandomForestClassifier(
n_estimators=100, max_depth=5, random_state=42,
)
elif model_type == "gradient_boosting":
model = GradientBoostingClassifier(
n_estimators=100, max_depth=3, learning_rate=0.05,
random_state=42,
)
elif model_type == "ridge":
model = LogisticRegression(penalty="l2", C=1.0, random_state=42)
else:
raise ValueError(f"Unsupported model_type: {model_type}")
model.fit(X_train, y_train)
# Predict today
X_today = features.iloc[i : i + 1].values
if np.isnan(X_today).any():
predictions.iloc[i] = 0.0
continue
X_today = scaler.transform(X_today)
if hasattr(model, "predict_proba"):
prob = model.predict_proba(X_today)[0, 1]
predictions.iloc[i] = prob * 2 - 1 # [0,1] -> [-1,1]
else:
predictions.iloc[i] = float(model.predict(X_today)[0])
# Output contract: no NaN, clipped to [-1, 1]View on GitHub (pinned to 80ffdda44c)
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
Example fix
# before model = train_walkforward(features, target, model_type="RandomForest") # after model = train_walkforward(features, target, model_type="xgboost") # or "ridge"
Defensive patterns
Strategy: type-guard
Validate before calling
SUPPORTED_MODELS = {"xgboost", "ridge"}
model_type = str(cfg.get("model_type", "")).strip().lower()
if model_type not in SUPPORTED_MODELS:
raise ValueError(f"model_type must be one of {sorted(SUPPORTED_MODELS)}, got {model_type!r}") Type guard
def is_supported_model_type(value: str) -> bool:
return str(value or "").strip().lower() in {"xgboost", "ridge"} Try / catch
try:
model = train_walkforward(features, target, model_type=model_type)
except ValueError as e:
if str(e).startswith("Unsupported model_type"):
raise ConfigError(f"fix strategy config: {e}") from e
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalid job_id
- job {job_id} not found
- Feishu QR login requires a JSON agent config; use ~/.vibe-tr
- agent config 'channels' must be an object
- agent config 'channels.feishu' must be an object
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/b8b081b9192c8a9d.
Report an issue: GitHub.