Installation

Warning

As of the 1.7.0 release, mlfinlab requires Python 3.8 (support for Python 3.9+ is available for later versions of MLFinlab) Older versions of MLFinlab require Python 3.7.


API Keys

In order to use mlfinlab, you will require an API key. This is provided to you when you purchase MLFinlab, and can be found on the client portal. If you are unable to find your API key, please reach out to sales@hudsonthames.org.

Running in Docker (Beta)

We are currently running an open beta for a Dockerized version of MLFinlab. You can read more behind the motivations and benefits here.

Using Docker as your installation method works with your existing API key:

  1. Download and install Docker

  2. If you are on Windows, you will need to install Python

  3. Install docker-compose (if it is not already installed with Docker)

  4. Clone the mlfinlab-quickstart repository

  5. Make sure your MLFINLAB_API_KEY environment variable is set with your API key:

    Open the command prompt as an Administrator, and run the following command to set the environment variable:

    setx MLFINLAB_API_KEY "<your-api-key"
    

    where you replace <your-api-key with your MLFinlab API key you received when you purchased a subscription.

    Verify that your API key is available in your environment by executing the following in a new command prompt terminal:

    echo %MLFINLAB_API_KEY%
    

    which should echo your API key to the terminal.

  6. Execute python start.py inside of the mlfinlab-quickstart folder to launch a Jupyter Lab instance with mlfinlab installed.

Alternative ways of adding the API Key

Warning

The following is not recommended for security reasons, since you run the risk of accidentally leaking your API key in your source code by accidentally committing it to your version control system. As a result, we highly recommended using environment variables instead.

You can also use the os module in your Python script or Jupyter notebook to add the MLFINLAB_API_KEY environment variable before importing mlfinlab:

# Insert this at the start of your script or notebook
import os

os.environ["MLFINLAB_API_KEY"] = "<your-api-key>"

Optional Dependencies

The mlfinlab library provides optional packages that can be installed based on specific requirements. The use of optional dependencies allows for a more flexible installation process based on specific requirements and use cases. By separating optional dependencies from the core library, users have the choice to install only the specific functionality they need. This modular approach promotes efficiency in terms of disk space, computational resources, and installation time.

These optional packages are POT, which is used in the optimal_transport module under the section Measures of Codependence, and Tensorflow, which is used in corrgan module under the Synthetic Data Generation section.

The installation options for mlfinlab with and without these optional dependencies are as follows:

  1. Install mlfinlab without any optional dependencies:

    pip install "mlfinlab @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py38-none-any.whl"
    
  2. Install mlfinlab with CorrGAN (Tensorflow) optional dependency:

    pip install "mlfinlab[corrgan] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py38-none-any.whl"
    
  3. Install mlfinlab with Optimal Transport (POT) optional dependency:

    pip install "mlfinlab[optimal-transport] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py38-none-any.whl"
    
  4. Install mlfinlab with all optional dependencies:

    pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py38-none-any.whl"