|
1 | 1 | # DoubleML-Serverless - Distributed Double Machine Learning with a Serverless Architecture |
2 | 2 |
|
| 3 | +This repo contains a prototype implementation **DoubleML-Serverless** of distributed double machine learning with a serverless infrastructure |
| 4 | +using [AWS Lambda](https://aws.amazon.com/lambda). |
| 5 | +A detailed discussion of this prototype can be found in the paper "Distributed Double Machine Learning with a Serverless Architecture" (Kurz, 2021). |
| 6 | +**DoubleML-Serverless** is an extension for serverless cloud computing of the Python package **DoubleML**. |
| 7 | +**DoubleML** is available via PyPI [https://pypi.org/project/DoubleML](https://pypi.org/project/DoubleML) and on GitHub [https://github.com/DoubleML/doubleml-for-py](https://github.com/DoubleML/doubleml-for-py). |
| 8 | +Also see [https://docs.doubleml.org](https://docs.doubleml.org) for a detailed documentation and user guide for the **DoubleML** package. |
3 | 9 |
|
| 10 | +## Getting started |
| 11 | + |
| 12 | +### Installation of DoubleML-Serverless |
| 13 | + |
| 14 | +To install download the latest source code from GitHub via |
| 15 | +``` |
| 16 | +git clone git@github.com:DoubleML/doubleml-serverless.git |
| 17 | +cd doubleml-serverless |
| 18 | +``` |
| 19 | + |
| 20 | +Then build the package from source using pip in the editable mode. |
| 21 | + |
| 22 | +``` |
| 23 | +pip install --editable . |
| 24 | +``` |
| 25 | + |
| 26 | +Alternatively to the installation from source, released versions of the DoubleML-Serverless package in form of |
| 27 | +.whl files can be obtained from [GitHub Releases](https://github.com/DoubleML/doubleml-serverless/releases). |
| 28 | +After downloading the wheel, the package can be installed with pip (replace `XXX` with the downloaded package version). |
| 29 | +``` |
| 30 | +pip install -U DoubleML-Serverless-XXX-py3-none-any.whl |
| 31 | +``` |
| 32 | + |
| 33 | +### Deploy the corresponding serverless app to AWS Lambda using AWS SAM |
| 34 | + |
| 35 | +To use AWS Lambda for estimating double machine learning models, a deployment in your AWS account is necessary. |
| 36 | +The corresponding serverless application consists of the following components: |
| 37 | + |
| 38 | +* A AWS Lambda function called `LambdaCVPredict` (the source code is taken from this repository [https://github.com/DoubleML/doubleml-serverless/blob/master/aws_lambda_app/lambda_functions/cv_predict.py](https://github.com/DoubleML/doubleml-serverless/blob/master/aws_lambda_app/lambda_functions/cv_predict.py)). |
| 39 | +* A layer providing the Python libraries `scikit-learn`, `pandas` and `numpy` together with their dependencies. |
| 40 | +* An S3 bucket for the data transfer (can be optionally generated, or an existing bucket is used). |
| 41 | +* A role for the execution of the lambda function `LambdaCVPredict` which consists of the AWS-managed `AWSLambdaBasicExecutionRole` policy plus read access to the S3 bucket for data transfer. |
| 42 | + |
| 43 | + |
| 44 | +There are two options for deployment: |
| 45 | + |
| 46 | +1. A version of DoubleML-Serverless is available in the AWS Serverless Application Repository. It can be deployed by clicking on the `Deploy` button. |
| 47 | + |
| 48 | +2. The second option for deployment is based on AWS Serverless Application Model (AWS SAM). |
| 49 | + |
| 50 | +2.1 Setup the AWS SAM CLI as described here: [https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started.html](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started.html) |
| 51 | + |
| 52 | +2.2 To deploy the application use the following commands (for more information see [https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html)) |
| 53 | + |
| 54 | +``` |
| 55 | +cd aws_lambda_app |
| 56 | +sam build |
| 57 | +sam deploy --guided |
| 58 | +``` |
| 59 | + |
| 60 | +### Estimating a partially linear regression model with double machine learning and serverless scaling using AWS Lambda |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +## References |
| 65 | +Kurz, M.S. 2020. "Distributed Double Machine Learning with a Serverless Architecture". Unpublished Working Paper. |
0 commit comments