From f81f9b062e0140610f5e994ea99350ea95bec834 Mon Sep 17 00:00:00 2001 From: Jeroen ter Heerdt Date: Fri, 8 Mar 2019 15:23:39 -0800 Subject: [PATCH] Updating MLeap example --- .../app-deploy/mleap/README.md | 20 ++++---- .../app-deploy/mleap/census_frame.json | 35 ++++++++++++++ .../app-deploy/mleap/frame.json | 45 ------------------ .../app-deploy/mleap/model.lr.zip | Bin 15259 -> 0 bytes .../app-deploy/mleap/run-spec.yaml | 4 +- .../app-deploy/mleap/spec.yaml | 7 ++- 6 files changed, 50 insertions(+), 61 deletions(-) create mode 100644 samples/features/sql-big-data-cluster/app-deploy/mleap/census_frame.json delete mode 100644 samples/features/sql-big-data-cluster/app-deploy/mleap/frame.json delete mode 100644 samples/features/sql-big-data-cluster/app-deploy/mleap/model.lr.zip diff --git a/samples/features/sql-big-data-cluster/app-deploy/mleap/README.md b/samples/features/sql-big-data-cluster/app-deploy/mleap/README.md index cd4f815d..1884e61c 100644 --- a/samples/features/sql-big-data-cluster/app-deploy/mleap/README.md +++ b/samples/features/sql-big-data-cluster/app-deploy/mleap/README.md @@ -43,23 +43,23 @@ To run this sample, you need the following prerequisites. ```bash mssqlctl login -e https://:30777 -u -p ``` -3. This example uses a Machine Learning Model that predicts the price per square foot of an Airbnb property based on various parameters such as the location and type of dwelling. [More details and information on the example are here](http://mleap-docs.combust.ml/mleap-serving/#load-model). The application you will be deploying as part of this sample is a Random Forest Model that was built in Spark and has been serialized as an MLeap bundle. +3. This example uses a TensorFlow Machine Learning Model that uses public US Census data predict income. [More details and information on the example are here](https://docs.microsoft.com/en-us/sql/big-data-cluster/train-and-create-machinelearning-models-with-spark?view=sqlallproducts-allversions). The application you will be deploying as part of this sample is a Random Forest Model that was built in Spark and has been [serialized as an MLeap bundle](https://docs.microsoft.com/en-us/sql/big-data-cluster/export-model-with-spark-mleap?view=sqlallproducts-allversions). Deploy the app using the `create` command and pass the location of the spec file. In the example below, the spec file is expected to be in the `mleap` folder: ```bash - mssqlctl app create --spec ./mleap + mssqlctl app create --spec ./mleap/ ``` -4. Check the deployment by running the following command: +1. Check the deployment by running the following command: ```bash - mssqlctl app list -n mleap -v [version] + mssqlctl app list -n mleap-census -v [version] ``` Once the app is listed as `Ready` you can continue to the next step. -5. Now that the app has been deployed you can test if the app works correctly by passing in a sample input that is available in the mleap folder. The deployed app is a RESTful webservice that is [Swagger](swagger.io) compliant. For this sample we will show you how you can test this using the CLI. +2. Now that the app has been deployed you can test if the app works correctly by passing in a sample input that is available in the `mleap` folder. The deployed app is a RESTful webservice that is [Swagger](swagger.io) compliant. For this sample we will show you how you can test this using the CLI. - To test the app, run the command below. The input parameter is a `LeapFrame`, a `json` file that describes the parameters and the values provided to the model for predicting the cost per square feet. Note that the input parameter has a special character '@' to indicate that a `json` file is being passed. This command needs to be run within the `mleap` folder. + To test the app, run the command below. The input parameter is a `MLeapFrame`, a `json` file that describes the parameters and the values provided to the model for predicting the cost per square feet. Note that the input parameter has a special character '@' to indicate that a `json` file is being passed. This command needs to be run within the `mleap` folder. ```bash - mssqlctl app run --name mleap --version [version] --input mleap-frame=@frame.json + mssqlctl app run --name mleap-census --version [version] --input schema=@census_frame.json ``` The result will be a json output that includes the prediction along with additional data, including the predicted price per square feet. @@ -69,7 +69,7 @@ To run this sample, you need the following prerequisites. 6. You can clean up the sample by running the following commands: ```bash # delete app - mssqlctl app delete --name mleap --version [version] + mssqlctl app delete --name mleap-census --version [version] ``` @@ -82,10 +82,10 @@ The spec file serves as the data required for deploying the app and it contains Here is the spec file for this application: ```yaml -name: mleap +name: mleap-census version: v1 runtime: Mleap -bundleFileName: model.lr.zip +bundleFileName: census_bundle.zip replicas: 2 poolsize: 2 ``` diff --git a/samples/features/sql-big-data-cluster/app-deploy/mleap/census_frame.json b/samples/features/sql-big-data-cluster/app-deploy/mleap/census_frame.json new file mode 100644 index 00000000..4f39529f --- /dev/null +++ b/samples/features/sql-big-data-cluster/app-deploy/mleap/census_frame.json @@ -0,0 +1,35 @@ +{ + "rows": [ + [ + 17, + 4, + "<=50K" + ], + [ + 17, + 5, + "<=50K" + ], + [ + 17, + 5, + "<=50K" + ] + ], + "schema": { + "fields": [ + { + "name": "age", + "type": "integer" + }, + { + "name": "hours_per_week", + "type": "integer" + }, + { + "name": "income", + "type": "string" + } + ] + } +} diff --git a/samples/features/sql-big-data-cluster/app-deploy/mleap/frame.json b/samples/features/sql-big-data-cluster/app-deploy/mleap/frame.json deleted file mode 100644 index 3accc051..00000000 --- a/samples/features/sql-big-data-cluster/app-deploy/mleap/frame.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "schema": { - "fields": [{ - "name": "state", - "type": "string" - }, { - "name": "bathrooms", - "type": "double" - }, { - "name": "square_feet", - "type": "double" - }, { - "name": "bedrooms", - "type": "double" - }, { - "name": "security_deposit", - "type": "double" - }, { - "name": "cleaning_fee", - "type": "double" - }, { - "name": "extra_people", - "type": "double" - }, { - "name": "number_of_reviews", - "type": "double" - }, { - "name": "review_scores_rating", - "type": "double" - }, { - "name": "room_type", - "type": "string" - }, { - "name": "host_is_superhost", - "type": "string" - }, { - "name": "cancellation_policy", - "type": "string" - }, { - "name": "instant_bookable", - "type": "string" - }] - }, - "rows": [["NY", 2.0, 1250.0, 3.0, 50.0, 30.0, 2.0, 56.0, 90.0, "Entire home/apt", "1.0", "strict", "1.0"]] -} diff --git a/samples/features/sql-big-data-cluster/app-deploy/mleap/model.lr.zip b/samples/features/sql-big-data-cluster/app-deploy/mleap/model.lr.zip deleted file mode 100644 index 2141e15932776eb78ad54dbd0ef29a935f9ceba4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15259 zcmc&*c|6qJ_qWs7WnXG+$)1vZ>|@Q+WQoW+iWstIiO3R$l&x&pQwb&7C~IU*6xqv` zgomQ2{62af&oiHD#z^1SPp_lqkGb!A-uHdaJ@=fOp)N5AgkbH*hFnVb`#=8qMM^+V z;O^?`DQ;{;O+emIQ)jkrhFHJDvHl$gq>ZPSJJQO{(GBVBh(d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}zz}0Tdv0K*1#$$%yf;8qRu6+N@aO0_f>&cjdd;|soRhNOS_xCE0 U0)-p`0tw(x9gr$i^RIpSKg*0v7ytkO diff --git a/samples/features/sql-big-data-cluster/app-deploy/mleap/run-spec.yaml b/samples/features/sql-big-data-cluster/app-deploy/mleap/run-spec.yaml index 0aefeec4..a5780250 100644 --- a/samples/features/sql-big-data-cluster/app-deploy/mleap/run-spec.yaml +++ b/samples/features/sql-big-data-cluster/app-deploy/mleap/run-spec.yaml @@ -1,3 +1,3 @@ -name: mleap +name: mleap-census version: v1 -inputs: ./frame.json \ No newline at end of file +inputs: ./census_frame.json \ No newline at end of file diff --git a/samples/features/sql-big-data-cluster/app-deploy/mleap/spec.yaml b/samples/features/sql-big-data-cluster/app-deploy/mleap/spec.yaml index f11bcf1c..1823fea1 100644 --- a/samples/features/sql-big-data-cluster/app-deploy/mleap/spec.yaml +++ b/samples/features/sql-big-data-cluster/app-deploy/mleap/spec.yaml @@ -1,6 +1,5 @@ -name: mleap +name: mleap-census version: v1 runtime: Mleap -bundleFileName: model.lr.zip -replicas: 2 -poolsize: 2 +bundleFileName: census_bundle.zip +replicas: 1