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:
-
Download and install Docker
-
If you are on Windows, you will need to install Python
-
Install
docker-compose
(if it is not already installed with Docker) -
Clone the
mlfinlab-quickstart
repository -
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.
If you’re running on Linux or MacOS, you can add the following to your
~/.zshrc
,~/.bashrc
or~/.profile
file in order to make the API key available:MLFINLAB_API_KEY="<your-api-key>"
where you replace
<your-api-key
with your MLFinlab API key you received when you purchased a subscription.Note
Remember to close and open a new terminal, or
source
your terminal configuration to make sure the environment gets refreshed with our newMLFINLAB_API_KEY
variable.Verify that your API key is available in your environment by executing the following in your refreshed terminal
echo $MLFINLAB_API_KEY
which should echo your API key to the terminal.
-
Execute
python start.py
inside of themlfinlab-quickstart
folder to launch a Jupyter Lab instance withmlfinlab
installed.
Recommended Setup on Windows
-
Download and install the latest version of Anaconda 3
Launch Anaconda Navigator
-
Click Environments, choose an environment name, select Python 3.8, and click Create
-
Click Home, browse to your new environment, and click Install under Jupyter Notebook
-
Launch the Anaconda Prompt and activate the environment:
conda activate <env_name>
-
Install MLFinlab using
pip
: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"
pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py39-none-any.whl"
pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py310-none-any.whl"
pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py311-none-any.whl"
-
Make sure your API key is available in your environment under the
MLFINLAB_API_KEY
environment variable by opening the Command Prompt as an administrator, and running the following command: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.
You are now ready to use MLFinlab.
Recommended Setup on Linux / MacOS
Note
If you are running on Apple Silicon, you will need to make sure
Homebrew
is installed, and that you have installed
cmake
:
brew install cmake
-
Install some variant of
conda
environment manager (we recommend Anaconda or Miniconda) for your platform. -
Launch a new terminal and create a new
conda
environment using your environment manager:conda create -n <env_name> python=3.8
-
Make sure the environment is activated:
conda activate <env_name>
-
Install MLFinlab using
pip
: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"
pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py39-none-any.whl"
pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py310-none-any.whl"
pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py311-none-any.whl"
-
Make sure your API key is available in your environment under the
MLFINLAB_API_KEY
environment variable.If you’re running on Linux or MacOS, you can add the following to your
~/.zshrc
,~/.bashrc
or~/.profile
file in order to make the API key available:MLFINLAB_API_KEY="<your-api-key>"
where you replace
<your-api-key
with your MLFinlab API key you received when you purchased a subscription.Note
Remember to close and open a new terminal, or
source
your terminal configuration to make sure the environment gets refreshed with our newMLFINLAB_API_KEY
variable.Verify that your API key is available in your environment by executing the following in your refreshed terminal
echo $MLFINLAB_API_KEY
which should echo your API key to the terminal.
You are now ready to use MLFinlab.
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:
-
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"
pip install "mlfinlab @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py39-none-any.whl"
pip install "mlfinlab @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py310-none-any.whl"
pip install "mlfinlab @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py311-none-any.whl"
-
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"
pip install "mlfinlab[corrgan] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py39-none-any.whl"
pip install "mlfinlab[corrgan] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py310-none-any.whl"
pip install "mlfinlab[corrgan] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py311-none-any.whl"
-
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"
pip install "mlfinlab[optimal-transport] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py39-none-any.whl"
pip install "mlfinlab[optimal-transport] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py310-none-any.whl"
pip install "mlfinlab[optimal-transport] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py311-none-any.whl"
-
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"
pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py39-none-any.whl"
pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py310-none-any.whl"
pip install "mlfinlab[all] @ https://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@raw.githubusercontent.com/hudson-and-thames-clients/mlfinlab/master/mlfinlab-2.2.0-py311-none-any.whl"