TAYU Academy course material · Machine Learning for Trading
Text walkthrough
Random forests and XGBoost
A self-paced text walkthrough, without video or audio. See the article below for worked examples and materials.
Course Notes
1. Understand the core idea of “Random forests and XGBoost” and explain it in your own words
2. Master this module's focus: Model training and evaluation
3. Complete the assignment on your own and check it against the reference answer
Random Forest integrates multiple randomized trees, while XGBoost adds trees in order of residual/gradient. Their training mechanisms differ. Accompanying implementations are Random Forest, not evidence of XGBoost training.
Random forests and XGBoost, among tree models, are prone to overfitting to noise. Evaluate the model using time series cross-validation (e.g., TimeSeriesSplit with a gap setting); an accuracy exceeding 50% does not necessarily mean profitability, and one must also consider the cost and drawdown after accounting for costs.
Model accuracy is 53%, but the average profit of profitable trades is less than the average loss of losing trades, including the spread, resulting in a negative expected value. Therefore, it is not usable.
Run `ml_lab.py` → Split Time → Compare with Majority Class Baseline → Read Tree Depth/Leaf Samples Limit; XGBoost listed as not run with different results from inference.
Fix these problems and output only the corrected English translation: keep only the translation.
Actual script is Random Forest; fair comparison must use the same data, out-of-sample data, budget, and metrics. XGBoost cannot be scored without installation and running, and its classification scores cannot be used as returns.
The confusion matrix shows TP=6, FP=4, FN=3, TN=7. The accuracy is 13/20=65%, and the precision is 6/10=60%. The recall is approximately 6/9=66.67%. If the majority class constitutes 70%, an accuracy of 65% is worse than the baseline. Correct classification does not guarantee profitability without incurring costs.
Feature importance is not a causal explanation; if XGBoost cannot be installed, it should indicate optional dependencies not verified, rather than renaming it to random forest.
Install the dependencies listed for this lab in the README first. If a dependency or platform is unavailable, mark the lab as not run; downloading the source is not evidence of running it.
python ml_lab.py1. Use time-series cross-validation
2. Accuracy does not equal profitability
3. Evaluations must include trading costs
Risk warning: leveraged trading in forex, precious metals and similar products carries a high level of risk and you may lose all of your capital, or more. This course is for education only. It is not investment advice and does not promise any return. Example prices and contract specifications are teaching assumptions; always use what your own platform discloses. Past performance and backtests do not indicate future results.
All values, prices, accounts and cases in this course are teaching assumptions; the fixed materials can be reproduced offline. Marking a lesson complete only records your study. It is not a certification, a service approval or a promise of returns. Workbooks and answer files are currently provided in Chinese.
Key Takeaways
Completion records your own study, not verified competence. Exercises use fictional data; no real account or deposit is required.