Installation & Environment Setup
Relevant source files
The following files were used as context for generating this wiki page:
AlphaPy is a machine learning framework designed for speculators and data scientists to test predictive models in stock markets and sporting events. The installation process involves setting up a Python environment, installing core dependencies via pip, and optionally configuring specialized gradient boosting libraries and environment-specific API keys.
The environment setup requires a specific directory structure for projects, which AlphaPy automatically initializes during its first run. This includes dedicated folders for configuration, input data, model storage, and output results.
Prerequisites and Core Installation
AlphaPy is compatible with Python 3, specifically versions 3.7 and 3.8. It relies on scikit-learn and pandas as its primary engines for machine learning and data manipulation.
Basic Installation
The standard installation is performed using the Python package manager:
pip install -U alphapy
Sources: README.rst:38, setup.py:18-28
Core Dependencies
The framework automatically installs several key libraries required for the pipeline:
| Library | Minimum Version | Purpose |
|---|---|---|
scikit-learn | 0.23.1 | Core ML algorithms and metrics |
pandas | 1.0 | Data structures and analysis |
numpy | 1.17 | Numerical computing |
tensorflow | 2.0 | Backend for Keras models |
keras | 2.3 | Deep learning interface |
pyfolio | 0.9 | Portfolio and risk analytics |
category_encoders | 2.1 | Categorical feature engineering |
Sources: setup.py:38-55
Specialized Library Configuration
Certain high-performance libraries are not automatically bundled during the standard pip installation due to platform-specific build requirements (particularly for macOS and Windows).
Gradient Boosting Frameworks
If your models require XGBoost, LightGBM, or CatBoost, these must be installed manually:
- XGBoost: Required for specialized gradient boosting. Mac and Windows users must follow specific build instructions.
- LightGBM: Microsoft's gradient boosting framework.
- CatBoost: Yandex's framework optimized for categorical data.
Sources: README.rst:49-65, alphapy/estimators.py:173-200
Pyfolio Hotfix
If an AttributeError related to numpy.int64 occurs when creating tear sheets, a specific version of pyfolio should be installed from the source:
pip install git+https://github.com/quantopian/pyfolio
Sources: README.rst:41-47
Project Environment Setup
AlphaPy operates within a structured project directory. When the main function is executed, the system verifies and creates a standard set of subdirectories if they do not exist.
Directory Structure
This structure ensures that configuration files, raw datasets, and generated models are logically isolated.
Sources: alphapy/main.py:534-541, alphapy/market_flow.py:448-454
Environment Variables
For MarketFlow applications, users can configure an API key for data retrieval. If an api_key is provided in market.yml, AlphaPy sets it as a system environment variable using the name specified in api_key_name.
Sources: alphapy/market_flow.py:118-120
Executable Entry Points
AlphaPy registers multiple console scripts during installation, allowing users to trigger different pipelines directly from the terminal.
| Command | Module | Description |
|---|---|---|
alphapy | alphapy.__main__:main | General machine learning pipeline |
mflow | alphapy.market_flow:main | MarketFlow pipeline for trading |
sflow | alphapy.sport_flow:main | SportFlow pipeline for games |
Sources: setup.py:71-75
Runtime Initialization Flow
The following diagram illustrates the sequence of environment initialization when a user runs the alphapy command:
Sources: alphapy/main.py:516-554
Summary
The Installation & Environment Setup for AlphaPy provides a standardized ecosystem for running complex ML pipelines. By combining a strict directory architecture with a comprehensive set of data science dependencies, it allows developers to focus on feature engineering and model selection rather than infrastructure management. Significant care should be taken to ensure that optional gradient boosting libraries are correctly linked for the target operating system to leverage the full suite of available estimators.