Code Monkey home page Code Monkey logo

xgboost_indicators_3's Introduction

XGBoost Model Optimization

This repository contains Python code for optimizing the hyperparameters of an XGBoost classifier using the hyperopt library. The model is trained to predict trading signals, which are categorized as long, short, or neutral, based on various technical indicators.

Features

  1. Data Cleaning: Removes rows with missing values.
  2. Encoding: Encodes the categorical target column ('Signal').
  3. Hyperparameter Optimization: Uses Bayesian optimization with hyperopt to find the best hyperparameters for the XGBoost classifier.
  4. Model Evaluation: Evaluates the model's performance on a test set, providing a classification report, confusion matrix, accuracy, and ROC-AUC score.
  5. Feature Importance: Visualizes the importance of each feature used in the model.

Installation

Make sure you have the following Python packages installed:

  • numpy
  • matplotlib
  • xgboost
  • sklearn
  • hyperopt

You can install them using pip:

pip install numpy matplotlib xgboost sklearn hyperopt

Usage

  1. Clone this repository.
  2. Navigate to the repository's root directory in your terminal.
  3. Run the code using the following command:
python xgb_hyperop.py

Sample Output

After running the code, you will get:

  1. A printout of the best hyperparameters discovered during the optimization.
  2. A bar chart visualizing the feature importances.
  3. A detailed performance report including accuracy, ROC-AUC score, classification report, and confusion matrix.
  4. An ROC Curve plot.

Features ROC Performance

Conclusion

Upon evaluating the XGBoost model's performance using the test dataset, we observed the following:

  • The confusion matrix shows that the model correctly predicted 218 'long' signals and 239 'short' signals. However, there were 54 'long' signals that were misclassified as 'short' and 54 'short' signals that were misclassified as 'long'.

  • The precision, recall, and F1-score for both 'long' and 'short' signals are approximately 0.81, indicating a balanced performance between the two classes.

  • The overall accuracy of the model stands at 81%, which means that the model correctly predicted the trading signals for 81% of the test data.

  • The ROC-AUC Score is 0.89, which is quite impressive. An ROC-AUC score closer to 1 suggests that the model has good discriminative power between positive and negative classes.

Related Projects

  • Finding Features with XGBoost: Training and evaluating an XGBoost classifier on the Bitcoin technical indicators dataset. It aims to predict trading signals (like 'long', 'short', or 'neutral') based on the values of various indicators.
  • Technical Analysis Repository: This repository fetches 120 days of hourly Bitcoin price data, calculates technical indicators, and analyzes the relations between these indicators.

๐Ÿค Let's Connect!

Connect with me on LinkedIn.

For more insights into my work, check out my latest project: tafou.io.

I'm always eager to learn, share, and collaborate. If you have experiences, insights, or thoughts about RL, Prophet, XGBoost, SARIMA, ARIMA, or even simple Linear Regression in the domain of forecasting, please create an issue, drop a comment, or even better, submit a PR!

Let's learn and grow together! ๐ŸŒฑ

xgboost_indicators_3's People

Contributors

tzelalouzeir avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.