We’re excited to announce the launch of Amazon DocumentDB (with MongoDB compatibility) integration with Amazon SageMaker Canvas, permitting Amazon DocumentDB prospects to construct and use generative AI and machine studying (ML) options with out writing code. Amazon DocumentDB is a totally managed native JSON doc database that makes it easy and cost-effective to function important doc workloads at nearly any scale with out managing infrastructure. Amazon SageMaker Canvas is a no-code ML workspace providing ready-to-use fashions, together with basis fashions, and the flexibility to organize knowledge and construct and deploy customized fashions.
On this publish, we focus on the best way to convey knowledge saved in Amazon DocumentDB into SageMaker Canvas and use that knowledge to construct ML fashions for predictive analytics. With out creating and sustaining knowledge pipelines, it is possible for you to to energy ML fashions along with your unstructured knowledge saved in Amazon DocumentDB.
Answer overview
Let’s assume the function of a enterprise analyst for a meals supply firm. Your cellular app shops details about eating places in Amazon DocumentDB due to its scalability and versatile schema capabilities. You need to collect insights on this knowledge and construct an ML mannequin to foretell how new eating places shall be rated, however discover it difficult to carry out analytics on unstructured knowledge. You encounter bottlenecks as a result of you could depend on knowledge engineering and knowledge science groups to perform these targets.
This new integration solves these issues by making it easy to convey Amazon DocumentDB knowledge into SageMaker Canvas and instantly begin making ready and analyzing knowledge for ML. Moreover, SageMaker Canvas removes the dependency on ML experience to construct high-quality fashions and generate predictions.
We reveal the best way to use Amazon DocumentDB knowledge to construct ML fashions in SageMaker Canvas within the following steps:
Create an Amazon DocumentDB connector in SageMaker Canvas.
Analyze knowledge utilizing generative AI.
Put together knowledge for machine studying.
Construct a mannequin and generate predictions.
Stipulations
To implement this answer, full the next stipulations:
Have AWS Cloud admin entry with an AWS Id and Entry Administration (IAM) consumer with permissions required to finish the mixing.
Full the setting setup utilizing AWS CloudFormation via both of the next choices:
Deploy a CloudFormation template into a brand new VPC – This selection builds a brand new AWS setting that consists of the VPC, non-public subnets, safety teams, IAM execution roles, Amazon Cloud9, required VPC endpoints, and SageMaker area. It then deploys Amazon DocumentDB into this new VPC. Obtain the template or fast launch the CloudFormation stack by selecting Launch Stack:
Deploy a CloudFormation template into an current VPC – This selection creates the required VPC endpoints, IAM execution roles, and SageMaker area in an current VPC with non-public subnets. Obtain the template or fast launch the CloudFormation stack by selecting Launch Stack:
Word that in case you’re creating a brand new SageMaker area, you should configure the area to be in a personal VPC with out web entry to have the ability to add the connector to Amazon DocumentDB. To be taught extra, discuss with Configure Amazon SageMaker Canvas in a VPC with out web entry.
Comply with the tutorial to load pattern restaurant knowledge into Amazon DocumentDB.
Add entry to Amazon Bedrock and the Anthropic Claude mannequin inside it. For extra info, see Add mannequin entry.
Create an Amazon DocumentDB connector in SageMaker Canvas
After you create your SageMaker area, full the next steps:
On the Amazon DocumentDB console, select No-code machine studying within the navigation pane.
Underneath Select a website and profile¸ select your SageMaker area and consumer profile.
Select Launch Canvas to launch SageMaker Canvas in a brand new tab.
When SageMaker Canvas finishes loading, you’ll land on the Knowledge flows tab.
Select Create to create a brand new knowledge move.
Enter a reputation in your knowledge move and select Create.
Add a brand new Amazon DocumentDB connection by selecting Import knowledge, then select Tabular for Dataset kind.
On the Import knowledge web page, for Knowledge Supply, select DocumentDB and Add Connection.
Enter a connection identify resembling demo and select your required Amazon DocumentDB cluster.
Word that SageMaker Canvas will prepopulate the drop-down menu with clusters in the identical VPC as your SageMaker area.
Enter a consumer identify, password, and database identify.
Lastly, choose your learn choice.
To guard the efficiency of main situations, SageMaker Canvas defaults to Secondary, which means that it’ll solely learn from secondary situations. When learn choice is Secondary most popular, SageMaker Canvas reads from accessible secondary situations, however will learn from the first occasion if a secondary occasion just isn’t accessible. For extra info on the best way to configure an Amazon DocumentDB connection, see the Connect with a database saved in AWS.
Select Add connection.
If the connection is profitable, you will notice collections in your Amazon DocumentDB database proven as tables.
Drag your desk of option to the clean canvas. For this publish, we add our restaurant knowledge.
The primary 100 rows are displayed as a preview.
To start out analyzing and making ready your knowledge, select Import knowledge.
Enter a dataset identify and select Import knowledge.
Analyze knowledge utilizing generative AI
Subsequent, we need to get some insights on our knowledge and search for patterns. SageMaker Canvas gives a pure language interface to investigate and put together knowledge. When the Knowledge tab masses, you can begin chatting along with your knowledge with the next steps:
Select Chat for knowledge prep.
Collect insights about your knowledge by asking questions just like the samples proven within the following screenshots.
To be taught extra about the best way to use pure language to discover and put together knowledge, discuss with Use pure language to discover and put together knowledge with a brand new functionality of Amazon SageMaker Canvas.
Let’s get a deeper sense of our knowledge high quality through the use of the SageMaker Canvas Knowledge High quality and Insights Report, which robotically evaluates knowledge high quality and detects abnormalities.
On the Analyses tab, select Knowledge High quality and Insights Report.
Select ranking because the goal column and Regression as the issue kind, then select Create.
This may simulate mannequin coaching and supply insights on how we are able to enhance our knowledge for machine studying. The whole report is generated in a couple of minutes.
Our report reveals that 2.47% of rows in our goal have lacking values—we’ll deal with that within the subsequent step. Moreover, the evaluation reveals that the deal with line 2, identify, and type_of_food options have essentially the most prediction energy in our knowledge. This means fundamental restaurant info like location and delicacies might have an outsized influence on scores.
Put together knowledge for machine studying
SageMaker Canvas provides over 300 built-in transformations to organize your imported knowledge. For extra info on transformation options of SageMaker Canvas, discuss with Put together knowledge with superior transformations. Let’s add some transformations to get our knowledge prepared for coaching an ML mannequin.
Navigate again to the Knowledge move web page by selecting the identify of your knowledge move on the high of the web page.
Select the plus signal subsequent to Knowledge sorts and select Add rework.
Select Add step.
Let’s rename the deal with line 2 column to cities.
Select Handle columns.
Select Rename column for Rework.
Select deal with line 2 for Enter column, enter cities for New identify, and select Add.
Moreover, lets drop some pointless columns.
Add a brand new rework.
For Rework, select Drop column.
For Columns to drop, select URL and restaurant_id.
Select Add.[
Our rating feature column has some missing values, so let’s fill in those rows with the average value of this column.
Add a new transform.
For Transform, choose Impute.
For Column type, choose Numeric.
For Input columns, choose the rating column.
For Imputing strategy, choose Mean.
For Output column, enter rating_avg_filled.
Choose Add.
We can drop the rating column because we have a new column with filled values.
Because type_of_food is categorical in nature, we’ll want to numerically encode it. Let’s encode this feature using the one-hot encoding technique.
Add a new transform.
For Transform, choose One-hot encode.
For Input columns, choose type_of_food.
For Invalid handling strategy¸ choose Keep.
For Output style¸ choose Columns.
For Output column, enter encoded.
Choose Add.
Build a model and generate predictions
Now that we have transformed our data, let’s train a numeric ML model to predict the ratings for restaurants.
Choose Create model.
For Dataset name, enter a name for the dataset export.
Choose Export and wait for the transformed data to be exported.
Choose the Create model link at the bottom left corner of the page.
You can also select the dataset from the Data Wrangler feature on the left of the page.
Enter a model name.
Choose Predictive analysis, then choose Create.
Choose rating_avg_filled as the target column.
SageMaker Canvas automatically selects a suitable model type.
Choose Preview model to ensure there are no data quality issues.
Choose Quick build to build the model.
The model creation will take approximately 2–15 minutes to complete.
You can view the model status after the model finishes training. Our model has an RSME of 0.422, which means the model often predicts the rating of a restaurant within +/- 0.422 of the actual value, a solid approximation for the rating scale of 1–6.
Finally, you can generate sample predictions by navigating to the Predict tab.
Clean up
To avoid incurring future charges, delete the resources you created while following this post. SageMaker Canvas bills you for the duration of the session, and we recommend logging out of SageMaker Canvas when you’re not using it. Refer to Logging out of Amazon SageMaker Canvas for more details.
Conclusion
In this post, we discussed how you can use SageMaker Canvas for generative AI and ML with data stored in Amazon DocumentDB. In our example, we showed how an analyst can quickly build a high-quality ML model using a sample restaurant dataset.
We showed the steps to implement the solution, from importing data from Amazon DocumentDB to building an ML model in SageMaker Canvas. The entire process was completed through a visual interface without writing a single line of code.
To start your low-code/no-code ML journey, refer to Amazon SageMaker Canvas.
About the authors
Adeleke Coker is a Global Solutions Architect with AWS. He works with customers globally to provide guidance and technical assistance in deploying production workloads at scale on AWS. In his spare time, he enjoys learning, reading, gaming and watching sport events.
Gururaj S Bayari is a Senior DocumentDB Specialist Solutions Architect at AWS. He enjoys helping customers adopt Amazon’s purpose-built databases. He helps customers design, evaluate, and optimize their internet scale and high performance workloads powered by NoSQL and/or Relational databases.
Tim Pusateri is a Senior Product Manager at AWS where he works on Amazon SageMaker Canvas. His goal is to help customers quickly derive value from AI/ML. Outside of work, he loves to be outdoors, play guitar, see live music, and spend time with family and friends.
Pratik Das is a Product Manager at AWS. He enjoys working with customers looking to build resilient workloads and strong data foundations in the cloud. He brings expertise working with enterprises on modernization, analytical and data transformation initiatives.
Varma Gottumukkala is a Senior Database Specialist Solutions Architect at AWS based out of Dallas Fort Worth. Varma works with the customers on their database strategy and architect their workloads using AWS purpose built databases. Before joining AWS, he worked extensively with relational databases, NOSQL databases and multiple programming languages for the last 22 years.