Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update xgboost version to 1.5-1 in notebooks #3439

Merged
merged 5 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
],
"source": [
"import sagemaker\n",
"\n",
"print(sagemaker.__version__)"
]
},
Expand Down Expand Up @@ -338,6 +339,7 @@
"from sagemaker import get_execution_role\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #27.    ENDPOINT_NAME = f'mme-xgboost-housing-{strftime("%Y-%m-%d-%H-%M-%S", gmtime())}'

Please run black-nb -l 100 {notebook-name}.ipynb for each notebook to apply code formatting - the standard is double quotes.


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I used this command and with new commits it passed the code-formatting check

"from sagemaker.amazon.amazon_estimator import image_uris\n",
"import boto3\n",
"from time import gmtime, strftime\n",
"\n",
"from sklearn.model_selection import train_test_split\n",
"\n",
Expand All @@ -350,7 +352,7 @@
"\n",
"# This is references the AWS managed XGBoost container\n",
"XGBOOST_IMAGE = image_uris.retrieve(\n",
" region=boto3.Session().region_name, framework=\"xgboost\", version=\"1.0-1\"\n",
" region=boto3.Session().region_name, framework=\"xgboost\", version=\"1.5-1\"\n",
")\n",
"\n",
"DATA_PREFIX = \"XGBOOST_BOSTON_HOUSING\"\n",
Expand All @@ -359,7 +361,7 @@
"TRAIN_INSTANCE_TYPE = \"ml.m4.xlarge\"\n",
"ENDPOINT_INSTANCE_TYPE = \"ml.m4.xlarge\"\n",
"\n",
"ENDPOINT_NAME = \"mme-xgboost-housing\"\n",
"ENDPOINT_NAME = f'mme-xgboost-housing-{strftime(\"%Y-%m-%d-%H-%M-%S\", gmtime())}'\n",
"\n",
"MODEL_NAME = ENDPOINT_NAME"
]
Expand Down Expand Up @@ -506,9 +508,9 @@
" gamma=4,\n",
" min_child_weight=6,\n",
" subsample=0.8,\n",
" silent=0,\n",
" verbosity=0,\n",
" early_stopping_rounds=5,\n",
" objective=\"reg:linear\",\n",
" objective=\"reg:squarederror\",\n",
" num_round=25,\n",
" )\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"from sagemaker import image_uris\n",
"\n",
"container = image_uris.retrieve(\n",
" framework=\"xgboost\", region=boto3.Session().region_name, version=\"1.0-1\"\n",
" framework=\"xgboost\", region=boto3.Session().region_name, version=\"1.5-1\"\n",
")"
]
},
Expand Down Expand Up @@ -377,7 +377,7 @@
" gamma=4,\n",
" min_child_weight=6,\n",
" subsample=0.8,\n",
" silent=0,\n",
" verbosity=0,\n",
" objective=\"binary:logistic\",\n",
" num_round=100,\n",
")\n",
Expand Down Expand Up @@ -437,9 +437,9 @@
" split_array = np.array_split(data, int(data.shape[0] / float(rows) + 1))\n",
" predictions = \"\"\n",
" for array in split_array:\n",
" predictions = \",\".join([predictions, xgb_predictor.predict(array).decode(\"utf-8\")])\n",
" predictions = \"\".join([predictions, xgb_predictor.predict(array).decode(\"utf-8\")])\n",
"\n",
" return np.fromstring(predictions[1:], sep=\",\")\n",
" return predictions.split(\"\\n\")[:-1]\n",
"\n",
"\n",
"predictions = predict(test_data.values[:, 1:])"
Expand All @@ -458,6 +458,7 @@
"metadata": {},
"outputs": [],
"source": [
"predictions = np.array([float(num) for num in predictions])\n",
"pd.crosstab(\n",
" index=test_data.iloc[:, 0],\n",
" columns=np.round(predictions),\n",
Expand Down Expand Up @@ -621,7 +622,7 @@
" input_shape={\"data\": [1, 69]},\n",
" role=role,\n",
" framework=\"xgboost\",\n",
" framework_version=\"latest\",\n",
" framework_version=\"1.5-1\",\n",
" output_path=output_path,\n",
")"
]
Expand Down Expand Up @@ -670,9 +671,9 @@
" split_array = np.array_split(data, int(data.shape[0] / float(rows) + 1))\n",
" predictions = \"\"\n",
" for array in split_array:\n",
" predictions = \",\".join([predictions, compiled_predictor.predict(array).decode(\"utf-8\")])\n",
" predictions = \"\".join([predictions, xgb_predictor.predict(array).decode(\"utf-8\")])\n",
"\n",
" return np.fromstring(predictions[1:], sep=\",\")\n",
" return predictions.split(\"\\n\")[:-1]\n",
"\n",
"\n",
"predictions = optimized_predict(test_data.values[:, 1:])"
Expand Down Expand Up @@ -721,4 +722,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
"source": [
"from sagemaker.image_uris import retrieve\n",
"\n",
"training_image = retrieve(framework=\"xgboost\", region=region, version=\"latest\")\n",
"training_image = retrieve(framework=\"xgboost\", region=region, version=\"1.5-1\")\n",
"\n",
"s3_input_train = \"s3://{}/{}/train\".format(bucket, prefix)\n",
"s3_input_validation = \"s3://{}/{}/validation/\".format(bucket, prefix)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
"source": [
"from sagemaker.image_uris import retrieve\n",
"\n",
"container = retrieve(framework=\"xgboost\", region=region, version=\"1.0-1\")"
"container = retrieve(framework=\"xgboost\", region=region, version=\"1.5-1\")"
]
},
{
Expand All @@ -275,7 +275,7 @@
" \"eta\": \"0.2\",\n",
" \"gamma\": \"4\",\n",
" \"min_child_weight\": \"6\",\n",
" \"silent\": \"0\",\n",
" \"verbosity\": \"0\",\n",
" \"objective\": \"multi:softmax\",\n",
" \"num_class\": \"10\",\n",
" \"num_round\": \"10\",\n",
Expand Down Expand Up @@ -636,7 +636,7 @@
" EndpointName=endpoint_name, ContentType=content_type, Body=payload\n",
" )\n",
" result = response[\"Body\"].read().decode(\"ascii\")\n",
" preds = [float(num) for num in result.split(\",\")]\n",
" preds = [float(num) for num in result.split(\"\\n\")[:-1]]\n",
" return preds\n",
"\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@
},
"outputs": [],
"source": [
"container = sagemaker.image_uris.retrieve(\"xgboost\", sess.boto_region_name, \"latest\")\n",
"container = sagemaker.image_uris.retrieve(\"xgboost\", sess.boto_region_name, \"1.5-1\")\n",
"display(container)"
]
},
Expand Down Expand Up @@ -790,7 +790,7 @@
" gamma=4,\n",
" min_child_weight=6,\n",
" subsample=0.8,\n",
" silent=0,\n",
" verbosity=0,\n",
" objective=\"binary:logistic\",\n",
" num_round=100,\n",
")\n",
Expand Down Expand Up @@ -900,9 +900,9 @@
" split_array = np.array_split(data, int(data.shape[0] / float(rows) + 1))\n",
" predictions = \"\"\n",
" for array in split_array:\n",
" predictions = \",\".join([predictions, xgb_predictor.predict(array).decode(\"utf-8\")])\n",
" predictions = \"\".join([predictions, xgb_predictor.predict(array).decode(\"utf-8\")])\n",
"\n",
" return np.fromstring(predictions[1:], sep=\",\")\n",
" return predictions.split(\"\\n\")[:-1]\n",
"\n",
"\n",
"predictions = predict(test_data.to_numpy()[:, 1:])"
Expand All @@ -915,6 +915,7 @@
"metadata": {},
"outputs": [],
"source": [
"predictions = np.array([float(num) for num in predictions])\n",
"print(predictions)"
]
},
Expand Down
Loading