Models Referenceο
This section documents the machine learning models used by Cerebrum Forex.
XGBoost Modelο
Cerebrum Forex - XGBoost Model Gradient boosting model for signal prediction.
- class models.xgboost_model.XGBoostModel(timeframe, model_dir)[source]ο
Bases:
BaseModelXGBoost model for forex signal prediction
- train(X, y, X_val=None, y_val=None, class_weights=None)[source]ο
Train XGBoost model with optional external validation set and class weights
LightGBM Modelο
Cerebrum Forex - LightGBM Model Light gradient boosting model for signal prediction.
- class models.lightgbm_model.LightGBMModel(timeframe, model_dir)[source]ο
Bases:
BaseModelLightGBM model for forex signal prediction
- train(X, y, X_val=None, y_val=None, class_weights=None)[source]ο
Train LightGBM model with optional external validation set and class weights
RandomForest Modelο
Cerebrum Forex - RandomForest Model Ensemble tree-based model for signal prediction. Replaces CatBoost for sklearn 1.8+ compatibility.
- class models.randomforest_model.RandomForestModel(timeframe, model_dir)[source]ο
Bases:
BaseModelRandomForest model for forex signal prediction
- train(X, y, X_val=None, y_val=None, class_weights=None)[source]ο
Train RandomForest model with optional external validation set and class weights
Stacking Modelο
Cerebrum Forex - Stacking Ensemble Model Meta-learner that combines XGBoost, LightGBM, RandomForest predictions. Replaces LSTM for faster training without TensorFlow dependency.
- class models.stacking_model.StackingModel(timeframe, model_dir)[source]ο
Bases:
BaseModelStacking Ensemble Model using XGBoost, LightGBM, RandomForest as base learners and LogisticRegression as meta-learner.
Benefits over LSTM: - 10-20x faster training (no deep learning) - No TensorFlow/GPU dependency - Often better for tabular data
Meta Modelο
Cerebrum Forex - Meta-Labeling Model (The Guard) SECONDARY MODEL to filter Primary Model execution.
- class models.meta_model.MetaModel(timeframe, model_dir)[source]ο
Bases:
objectLearns βWhen is the Primary Model wrong?β.
Inputs: - Primary Model Probability/Confidence - Market Regime - Volatility State - Time of Day
Target: - 1 if Primary Trade was Profitable - 0 if Primary Trade was Loss
- prepare_meta_features(df, primary_signals, primary_confs, regime_series)[source]ο
Construct features for the Meta-Model.
- Return type:
DataFrame- Parameters:
df (DataFrame)
primary_signals (Series)
primary_confs (Series)
regime_series (Series)
- train(X_meta, y_meta)[source]ο
Train the Meta-Filter. y_meta should be: 1 (Trade Won), 0 (Trade Lost).
- Return type:
- Parameters:
X_meta (DataFrame)
y_meta (Series)