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: BaseModel

XGBoost model for forex signal prediction

Parameters:
property name: str

Model name

train(X, y, X_val=None, y_val=None, class_weights=None)[source]

Train XGBoost model with optional external validation set and class weights

Return type:

float

Parameters:
predict(X)[source]

Make prediction with XGBoost

Return type:

Tuple[str, float]

Parameters:

X (ndarray)

load()[source]

Load model from pickle file

Return type:

bool

LightGBM Model

Cerebrum Forex - LightGBM Model Light gradient boosting model for signal prediction.

class models.lightgbm_model.LightGBMModel(timeframe, model_dir)[source]

Bases: BaseModel

LightGBM model for forex signal prediction

Parameters:
property name: str

Model name

train(X, y, X_val=None, y_val=None, class_weights=None)[source]

Train LightGBM model with optional external validation set and class weights

Return type:

float

Parameters:
predict(X)[source]

Make prediction with LightGBM

Return type:

Tuple[str, float]

Parameters:

X (ndarray)

load()[source]

Load model from pickle file

Return type:

bool

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: BaseModel

RandomForest model for forex signal prediction

Parameters:
property name: str

Model name

train(X, y, X_val=None, y_val=None, class_weights=None)[source]

Train RandomForest model with optional external validation set and class weights

Return type:

float

Parameters:
predict(X)[source]

Make prediction with RandomForest

Return type:

Tuple[str, float]

Parameters:

X (ndarray)

load()[source]

Load model from pickle file

Return type:

bool

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: BaseModel

Stacking 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

Parameters:
property name: str

Model name

train(X, y, X_val=None, y_val=None, class_weights=None)[source]

Train the stacking model

Return type:

float

Parameters:
predict(X)[source]

Make prediction

Return type:

Tuple[str, float]

Parameters:

X (ndarray)

load()[source]

Load model from disk

Return type:

bool

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: object

Learns β€˜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

Parameters:
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:

float

Parameters:
  • X_meta (DataFrame)

  • y_meta (Series)

predict_viability(signal, conf, regime, volatility, hour)[source]

Returns Probability of SUCCESS (0.0 to 1.0).

Return type:

float

Parameters:
save()[source]
load()[source]
Return type:

bool