From 02eea40410e42cd141010a026b572b1b53cf4384 Mon Sep 17 00:00:00 2001 From: Vineet Khare Date: Fri, 24 Nov 2017 20:48:21 -0800 Subject: [PATCH] fixing the environment to conda 3 --- .../xgboost_bring_your_own_model.ipynb | 86 ++++++------------- 1 file changed, 26 insertions(+), 60 deletions(-) diff --git a/advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb b/advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb index 746273261c..ae394e6d4c 100644 --- a/advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb +++ b/advanced_functionality/xgboost_bring_your_own_model/xgboost_bring_your_own_model.ipynb @@ -44,7 +44,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": true, "isConfigCell": true }, "outputs": [], @@ -60,7 +59,7 @@ "assumed_role = boto3.client('sts').get_caller_identity()['Arn']\n", "role = re.sub(r'^(.+)sts::(\\d+):assumed-role/(.+?)/.*$', r'\\1iam::\\2:role/\\3', assumed_role)\n", "\n", - "bucket='' # put your s3 bucket name here, and create s3 bucket\n", + "bucket='' # put your s3 bucket name here, and create s3 bucket\n", "prefix = 'sagemaker/xgboost-byo'\n", "bucket_path = 'https://s3-{}.amazonaws.com/{}'.format(region,bucket)\n", "# customize to your bucket where you have stored the data" @@ -81,9 +80,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "!conda install -y -c conda-forge xgboost scikit-learn" @@ -99,9 +96,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "%%time\n", @@ -124,9 +119,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "%%time\n", @@ -147,9 +140,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "train_set, valid_set, test_set = get_dataset()\n", @@ -174,9 +165,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "import xgboost as xgb\n", @@ -202,9 +191,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "model_file_name = \"locally-trained-xgboost-model\"\n", @@ -214,9 +201,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "!tar czvf model.tar.gz $model_file_name" @@ -232,9 +217,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "fObj = open(\"model.tar.gz\", 'rb')\n", @@ -255,9 +238,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "containers = {'us-west-2': '433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest',\n", @@ -270,9 +251,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "%%time\n", @@ -309,9 +288,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "from time import gmtime, strftime\n", @@ -341,9 +318,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "%%time\n", @@ -381,9 +356,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "runtime_client = boto3.client('sagemaker-runtime')" @@ -399,9 +372,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", @@ -413,9 +384,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "%%time\n", @@ -445,9 +414,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "arr = result[1:len(result)-1].split(',')\n", @@ -461,16 +428,15 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Delete Endpoint\n", - "Once you are done using the endpoint, you can use the following to delete it. " + "### (Optional) Delete the Endpoint\n", + "\n", + "If you're ready to be done with this notebook, please uncomment the delete_endpoint line in the cell below and then run it. This will remove the hosted endpoint you created and avoid any charges from a stray instance being left on." ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "# sm_client.delete_endpoint(EndpointName=endpoint_name)" @@ -480,21 +446,21 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [conda root]", + "display_name": "Environment (conda_python3)", "language": "python", - "name": "conda-root-py" + "name": "conda_python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" + "pygments_lexer": "ipython3", + "version": "3.6.3" }, "notice": "Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License." },