ml-finance-python

python scripts for finance machine learning

git clone https://9o.is/git/ml-finance-python.git

installation.md

(3189B)


      1 # Installation Instructions
      2 
      3 ## How to install the required libaries
      4 
      5 ### Install miniconda
      6 
      7 The notebooks use a virtual environment based on [miniconda3]() that you need to install first. You can find detailed instructions for various operating systems [here](https://conda.io/projects/conda/en/latest/user-guide/install/index.html).
      8 
      9 ### Create a virtual conda environment
     10 
     11 [conda] is the package manager provided by the [Anaconda](https://www.anaconda.com/) python distribution that is tailored to faciliate the installation of data science libraries.
     12 
     13 Just like there are [virtual environments](https://docs.python.org/3/tutorial/venv.html) for generic python installations, conda permits the creation of separate [environments](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) that are based on the same interpreter (miniconda3 if you followed the above instructions) but can contain different package and versions of packages. See also [here](https://towardsdatascience.com/getting-started-with-python-environments-using-conda-32e9f2779307) for a more detailed tutorial.
     14 
     15 You can create a new conda environment with name `env_name` and one or more packages with a specific version number using the command: 
     16 ```python
     17 conda create --name env_name package=version_number 
     18 ```
     19 e.g.
     20 ```python
     21 conda create --name pandas_environment pandas=0.24
     22 ```
     23 ### Create conda environment from file for this book
     24 
     25 Here, we will create an environment from a file to ensure you install the versions the code has been tested with. The environment specs are in the file `environment_[linux|mac_osx].yml` in the root of this repo, where you should choose the one corresponding to your operating system. To create the environment with the name `ml4t` (specified in the file), just run:
     26 
     27 ```python
     28 conda env create -f environment_linux.yml
     29 ```
     30 
     31 or 
     32 
     33 ```python
     34 conda env create -f environment_mac_osx.yml
     35 ```
     36 from the command line in the root directory.
     37 
     38 #### Know Issues
     39 
     40 In case `conda` throws a `RemoveError`, a quick fix [can be](https://github.com/conda/conda/issues/8149):
     41 
     42 ```python
     43 conda update conda
     44 ``` 
     45 
     46 possibly adding `--force`.
     47 
     48 ### Activate conda environment
     49 
     50 After you've create it, you can activate the environment using its name, which in our case is `ml4t`:
     51 
     52 ```python
     53 conda activate ml4t
     54 ```
     55 
     56 To deactivate, simply use
     57 
     58 ```python
     59 conda deactivate
     60 ```
     61 
     62 ## Set up jupyter extensions
     63 
     64 jupyter notebooks can use a range of [extentsion](https://github.com/ipython-contrib/jupyter_contrib_nbextensions) provided by the community. There are many useful ones that are described in the [documentation](https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/).
     65 
     66 The notebooks in this repo are formatted to use the [Table of Contents (2)](https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/toc2/README.html) extension. For the best experience, activate it using the Configurator inthe [Nbextensions](https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator) tab available in your browser after starting the jupyter server. Modify the settings to check the option 'Leave h1 items out of ToC' if not set by default.