Skip to content

Commit

Permalink
Add FeatureMetadata related APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
imingtsou committed Jul 11, 2022
1 parent b4b39f1 commit 0144687
Showing 1 changed file with 75 additions and 4 deletions.
79 changes: 75 additions & 4 deletions sagemaker-featurestore/feature_store_introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,74 @@
").list_feature_groups() # We use the boto client to list FeatureGroups"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Add metadata to a feature\n",
"\n",
"We can put some searchable metadata to the features of the FeatureGroups by using the `UpdateFeatureMetadata` API. The current support metadata fields are `description` and `parameters`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from sagemaker.feature_store.inputs import FeatureParameter\n",
"\n",
"customers_feature_group.update_feature_metadata(\n",
" feature_name=\"customer_id\",\n",
" description=\"The ID of a customer. It is also used in orders_feature_group.\",\n",
" parameter_additions=[FeatureParameter(\"idType\", \"primaryKey\")],\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To confirm that the feature has been updated with the new metadata, we use `DescribeFeatureMetadata` to display that feature."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"customers_feature_group.describe_feature_metadata(feature_name=\"customer_id\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Feature metadata fields are searchable. We use `search` API with filters to display the specific feature."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sagemaker_session.boto_session.client(\"sagemaker\", region_name=region).search(\n",
" Resource=\"FeatureMetadata\",\n",
" SearchExpression={\n",
" \"Filters\": [\n",
" {\n",
" \"Name\": \"FeatureGroupName\",\n",
" \"Operator\": \"Contains\",\n",
" \"Value\": \"customers-feature-group-\",\n",
" },\n",
" {\"Name\": \"Parameters.idType\", \"Operator\": \"Equals\", \"Value\": \"primaryKey\"},\n",
" ]\n",
" },\n",
") # We use the boto client to search"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -474,20 +542,23 @@
"* `delete()`\n",
"* `create()`\n",
"* `load_feature_definitions()`\n",
"* `update_feature_metadata()`\n",
"* `describe_feature_metadata()`\n",
"\n",
"#### Boto3 API Calls\n",
"* `list_feature_groups()`\n",
"* `get_record()`\n",
"* `batch_get_record()`\n"
"* `batch_get_record()`\n",
"* `search()`\n"
]
}
],
"metadata": {
"instance_type": "ml.t3.medium",
"kernelspec": {
"display_name": "Environment (conda_anaconda3)",
"display_name": "Python 3 (Data Science)",
"language": "python",
"name": "conda_anaconda3"
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-west-2:236514542706:image/datascience-1.0"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -499,7 +570,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.10"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 0144687

Please sign in to comment.