Dependency Management
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
Dependency management in AlphaPy is centered around providing a robust machine learning framework that integrates standard data science libraries with specialized financial and sports analytics packages. The system is designed to be installed primarily via pip, managing a variety of core requirements for data manipulation, model estimation, and visualization.
The framework relies heavily on the scikit-learn ecosystem while providing optional integrations for high-performance gradient boosting libraries such as XGBoost, LightGBM, and CatBoost. These specific dependencies often require platform-specific installation steps beyond the standard automated pipeline.
Sources: README.rst:12-25, setup.py:35-52
Core Installation Requirements
The primary mechanism for managing dependencies is the setup.py file, which defines the install_requires list. This ensures that essential libraries for data frames, numerical analysis, and basic machine learning are present.
Primary Dependencies
| Package | Minimum Version | Purpose |
|---|---|---|
scikit-learn | 0.23.1 | Core ML algorithms and pipeline utilities |
pandas | 1.0 | Data structure management and I/O |
numpy | 1.17 | Numerical computing and array operations |
keras | 2.3 | Deep learning model support |
tensorflow | 2.0 | Backend for Keras models |
pyfolio | 0.9 | Portfolio and risk analytics |
matplotlib | 3.0 | Static plotting and visualization |
bokeh | 1.3 | Interactive web-based visualizations |
Sources: setup.py:35-52, README.rst:12-20
External and Optional Dependencies
Certain high-performance libraries are supported by AlphaPy but are not included in the automated pip installation due to platform-specific compilation requirements or the need for manual driver configuration.
Gradient Boosting Frameworks
AlphaPy provides native support for several advanced boosting libraries. Users must often install these manually depending on their operating system:
- XGBoost: Requires manual build instructions for Mac and Windows users as it does not always install automatically via
pip. - LightGBM: Managed via external installation guides provided by the Microsoft documentation.
- CatBoost: Requires separate installation via the Yandex CatBoost documentation.
Sources: README.rst:45-62, alphapy/model.py:488-498
Specialized Visualization
While AlphaPy installs pyfolio automatically, specific version conflicts (such as the numpy.int64 attribute error) may require a direct installation from the Quantopian GitHub repository:
pip install git+https://github.com/quantopian/pyfolio
Sources: README.rst:35-43
Module-Specific Dependency Usage
The project is structured such that different modules import specific subsets of dependencies based on their functional role.
Visualization Logic
The plots module manages dependencies across three distinct visualization libraries: Matplotlib, Seaborn, and Bokeh.
The diagram shows how AlphaPy functions map to specific third-party visualization backends.
Model Logic
The model module integrates joblib for serialization and yaml for configuration management, alongside core ML libraries.
This graph illustrates the relationship between the AlphaPy Model class and its primary functional dependencies.
Configuration Management
AlphaPy uses YAML files to define project-wide settings and algorithm-specific parameters, reducing hard-coded dependencies within the Python logic. The pyyaml library is used to parse these configurations.
- model.yml: Governs data splitting, feature selection, and algorithm selection.
- market.yml: Manages market data fractal offsets and leaders.
- sport.yml: Manages league-specific parameters for the sports pipeline.
Sources: alphapy/model.py:165-185, alphapy/market_flow.py:75-95, alphapy/sport_flow.py:115-135
Conclusion
Dependency management in AlphaPy balances standard automated installation with flexibility for high-performance computing. By centralizing core requirements in setup.py and providing clear documentation for external libraries like XGBoost and CatBoost, the framework ensures a consistent environment for both market speculators and data scientists.
Sources: README.rst:12-25, setup.py:55-65