This submit is co-authored by Daryl Martis, Director of Product, Salesforce Einstein AI.
That is the third submit in a collection discussing the combination of Salesforce Knowledge Cloud and Amazon SageMaker.
In Half 1 and Half 2, we present how the Salesforce Knowledge Cloud and Einstein Studio integration with SageMaker permits companies to entry their Salesforce knowledge securely utilizing SageMaker and use its instruments to construct, practice, and deploy fashions to endpoints hosted on SageMaker. SageMaker endpoints may be registered to the Salesforce Knowledge Cloud to activate predictions in Salesforce.
On this submit, we display how enterprise analysts and citizen knowledge scientists can create machine studying (ML) fashions, with none code, in Amazon SageMaker Canvas and deploy educated fashions for integration with Salesforce Einstein Studio to create highly effective enterprise functions. SageMaker Canvas supplies a no-code expertise to entry knowledge from Salesforce Knowledge Cloud and construct, check, and deploy fashions utilizing just some clicks. SageMaker Canvas additionally lets you perceive your predictions utilizing characteristic significance and SHAP values, making it easy so that you can clarify predictions made by ML fashions.
SageMaker Canvas
SageMaker Canvas allows enterprise analysts and knowledge science groups to construct and use ML and generative AI fashions with out having to write down a single line of code. SageMaker Canvas supplies a visible point-and-click interface to generate correct ML predictions for classification, regression, forecasting, pure language processing (NLP), and pc imaginative and prescient (CV). As well as, you’ll be able to entry and consider basis fashions (FMs) from Amazon Bedrock or public FMs from Amazon SageMaker JumpStart for content material technology, textual content extraction, and textual content summarization to help generative AI options. SageMaker Canvas means that you can convey ML fashions constructed anyplace and generate predictions straight in SageMaker Canvas.
Salesforce Knowledge Cloud and Einstein Studio
Salesforce Knowledge Cloud is a knowledge platform that gives companies with real-time updates of their buyer knowledge from any contact level.
Einstein Studio is a gateway to AI instruments on Salesforce Knowledge Cloud. With Einstein Studio, admins and knowledge scientists can effortlessly create fashions with a couple of clicks or utilizing code. Einstein Studio’s convey your personal mannequin (BYOM) expertise supplies the potential to attach customized or generative AI fashions from exterior platforms reminiscent of SageMaker to Salesforce Knowledge Cloud.
Answer overview
To display how one can construct ML fashions utilizing knowledge in Salesforce Knowledge Cloud utilizing SageMaker Canvas, we create a predictive mannequin to suggest a product. This mannequin makes use of the options saved in Salesforce Knowledge Cloud reminiscent of buyer demographics, advertising engagements, and buy historical past. The product suggestion mannequin is constructed and deployed utilizing the SageMaker Canvas no-code person interface utilizing knowledge in Salesforce Knowledge Cloud.
We use the next pattern dataset saved in Amazon Easy Storage Service (Amazon S3). To make use of this dataset in Salesforce Knowledge Cloud, consult with Create Amazon S3 Knowledge Stream in Knowledge Cloud. The next attributes are wanted to create the mannequin:
- Membership Member – If the shopper is a membership member
- Marketing campaign – The marketing campaign the shopper is part of
- State – The state or province the shopper resides in
- Month – The month of buy
- Case Rely – The variety of instances raised by the shopper
- Case Kind Return – Whether or not the shopper returned any product throughout the final 12 months
- Case Kind Cargo Broken – Whether or not the shopper had any shipments broken within the final 12 months
- Engagement Rating – The extent of engagement the shopper has (response to mailing campaigns, logins to the web retailer, and so forth)
- Tenure – The tenure of the shopper relationship with the corporate
- Clicks – The typical variety of clicks the shopper has made inside per week prior to buy
- Pages Visited – The typical variety of pages the shopper visited inside per week prior to buy
- Product Bought – The precise product bought
The next steps give an summary of the way to use the Salesforce Knowledge Cloud connector launched in SageMaker Canvas to entry your enterprise knowledge and construct a predictive mannequin:
- Configure the Salesforce related app to register the SageMaker Canvas area.
- Arrange OAuth for Salesforce Knowledge Cloud in SageMaker Canvas.
- Connect with Salesforce Knowledge Cloud knowledge utilizing the built-in SageMaker Canvas Salesforce Knowledge Cloud connector and import the dataset.
- Construct and practice fashions in SageMaker Canvas.
- Deploy the mannequin in SageMaker Canvas and make predictions.
- Deploy an Amazon API Gateway endpoint as a front-end connection to the SageMaker inference endpoint.
- Register the API Gateway endpoint in Einstein Studio. For directions, consult with Deliver Your Personal AI Fashions to Knowledge Cloud.
The next diagram illustrates the answer structure.
Stipulations
Earlier than you get began, full the next prerequisite steps to create a SageMaker area and allow SageMaker Canvas:
- Create an Amazon SageMaker Studio area. For directions, consult with Onboard to Amazon SageMaker Area.
- Be aware down the area ID and execution position that’s created and will likely be utilized by your person profile. You add permissions to this position in subsequent steps.
The next screenshot reveals the area we created for this submit.
- Subsequent, go to the person profile and select Edit.
- Navigate to the Amazon SageMaker Canvas settings part and choose Allow Canvas base permissions.
- Choose Allow direct deployments of Canvas fashions and Allow mannequin registry permissions for all customers.
This enables SageMaker Canvas to deploy fashions to endpoints on the SageMaker console. These settings may be configured on the area or person profile stage. Consumer profile settings take priority over area settings.
Create or replace the Salesforce related app
Subsequent, we create a Salesforce related app to allow the OAuth stream from SageMaker Canvas to Salesforce Knowledge Cloud. Full the next steps:
- Log in to Salesforce and navigate to Setup.
- Seek for App Supervisor and create a brand new related app.
- Present the next inputs:
- For Related App Identify, enter a reputation.
- For API Identify, go away as default (it’s robotically populated).
- For Contact E-mail, enter your contact e mail handle.
- Choose Allow OAuth Settings.
- For Callback URL, enter
https://<domain-id>.studio.<area>.sagemaker.aws/canvas/default/lab
, and supply the area ID and Area out of your SageMaker area.
- Configure the next scopes in your related app:
- Handle person knowledge through APIs (
api
). - Carry out requests at any time (
refresh_token
,offline_access
). - Carry out ANSI SQL queries on Salesforce Knowledge Cloud knowledge (Knowledge
Cloud_query_api
). - Handle Knowledge Cloud profile knowledge (
Knowledge Cloud_profile_api
). - Entry the identification URL service (
id
,profile
,e mail
,handle
,telephone
). - Entry distinctive person identifiers (
openid
).
- Handle person knowledge through APIs (
- Set your related app IP Leisure setting to Loosen up IP restrictions.
Configure OAuth settings for the Salesforce Knowledge Cloud connector
SageMaker Canvas makes use of AWS Secrets and techniques Supervisor to securely retailer connection info from the Salesforce related app. SageMaker Canvas permits directors to configure OAuth settings for a person person profile or on the area stage. Be aware you can add a secret to each a website and person profile, however SageMaker Canvas seems for secrets and techniques within the person profile first.
To configure your OAuth settings, full the next steps:
- Navigate to edit Area or Consumer Profile Settings in SageMaker Console.
- Select Canvas Settings within the navigation pane.
- Underneath OAuth settings, for Knowledge Supply, select Salesforce Knowledge Cloud.
- For Secret setup, you’ll be able to create a brand new secret or use an current secret. For this instance, we create a brand new secret and enter the shopper ID and shopper secret from the Salesforce related app.
For extra particulars on enabling OAuth in SageMaker Canvas, consult with Arrange OAuth for Salesforce Knowledge Cloud.
This completes the setup to allow knowledge entry from Salesforce Knowledge Cloud to SageMaker Canvas to construct AI and ML fashions.
Import knowledge from Salesforce Knowledge Cloud
To import your knowledge, full the next steps:
- From the person profile you created along with your SageMaker area, select Launch and choose Canvas.
The primary time you entry your Canvas app, it should take about 10 minutes to create.
- Select Knowledge Wrangler within the navigation pane.
- On the Create menu, select Tabular to create a tabular dataset.
- Identify the dataset and select Create.
- For Knowledge Supply, select Salesforce Knowledge Cloud and Add Connection to import the info lake object.
Should you’ve beforehand configured a connection to Salesforce Knowledge Cloud, you will notice an choice to make use of that connection as an alternative of making a brand new one.
- Present a reputation for a brand new Salesforce Knowledge Cloud connection and select Add connection.
It is going to take a couple of minutes to finish.
- You may be redirected to the Salesforce login web page to authorize the connection.
After the login is profitable, the request will likely be redirected again to SageMaker Canvas with the info Lake object itemizing.
- Choose the dataset that comprises the options for mannequin coaching that was uploaded through Amazon S3.
- Drag and drop the file, then select Edit in SQL.
Salesforce provides a “__c
“ to all of the Knowledge Cloud object fields. As per SageMaker Canvas naming conference, ”__“
shouldn’t be allowed within the subject names.
- Edit the SQL to rename the columns and drop metadata that isn’t related for mannequin coaching. Substitute the desk title along with your object title.
- Select Run SQL after which Create dataset.
- Choose the dataset and select Create a mannequin.
- To create a mannequin to foretell a product suggestion, present a mannequin title, select Predictive evaluation for Downside sort, and select Create.
Construct and practice the mannequin
Full the next steps to construct and practice your mannequin:
- After the mannequin is launched, set the goal column to
product_purchased
.
SageMaker Canvas shows key statistics and correlations of every column to the goal column. SageMaker Canvas supplies you with instruments to preview your mannequin and validate knowledge earlier than you start constructing.
- Use the preview mannequin characteristic to see the accuracy of your mannequin and validate your dataset to stop points whereas constructing the mannequin.
- After reviewing your knowledge and making any modifications to your dataset, select your construct sort. The Fast construct choice could also be sooner, however it should solely use a subset of your knowledge to construct a mannequin. For the aim of this submit, we chosen the Normal construct choice.
A typical construct can take 2–4 hours to finish.
SageMaker Canvas robotically handles lacking values in your dataset whereas it builds the mannequin. It is going to additionally apply different knowledge prep transformations so that you can get the info prepared for ML.
- After your mannequin begins constructing, you’ll be able to go away the web page.
When the mannequin reveals as Prepared on the My fashions web page, it’s prepared for evaluation and predictions.
- After the mannequin is constructed, navigate to My fashions, select View to view the mannequin you created, and select the newest model.
- Go to the Analyze tab to see the affect of every characteristic on the prediction.
- For extra info on the mannequin’s predictions, navigate to the Scoring tab.
- Select Predict to provoke a product prediction.
Deploy the mannequin and make predictions
Full the next steps to deploy your mannequin and begin making predictions:
- You’ll be able to select to make both batch or single predictions. For the aim of this submit, we select Single prediction.
Whenever you select Single prediction, SageMaker Canvas shows the options you can present inputs for.
- You’ll be able to change the values by selecting Replace and examine the real-time prediction.
The accuracy of the mannequin in addition to the affect of every characteristic for that particular prediction will likely be displayed.
- To deploy the mannequin, present a deployment title, choose an occasion sort and occasion depend, and select Deploy.
Mannequin deployment will take a couple of minutes.
Mannequin standing is up to date to In Service after the deployment is profitable.
SageMaker Canvas supplies an choice to check the deployment.
- Select View particulars.
The Particulars tab supplies the mannequin endpoint particulars. Occasion sort, depend, enter format, response content material, and endpoint are a few of key particulars displayed.
- Select Take a look at deployment to check the deployed endpoint.
Just like single prediction, the view shows the enter options and supplies an choice to replace and check the endpoint in actual time.
The brand new prediction together with the endpoint invocation result’s returned to the person.
Create API to show SageMaker Endpoint
To generate predictions that energy enterprise functions in Salesforce, you’ll want to expose the SageMaker inference endpoint created by your SageMaker Canvas deployment through API Gateway and register it in Salesforce Einstein.
The request and response codecs fluctuate between Salesforce Einstein and SageMaker inference endpoint. You would both use API Gateway to carry out the transformation or use AWS Lambda to rework the request and map the response. Confer with Name an Amazon SageMaker mannequin endpoint utilizing Amazon API Gateway and AWS Lambda to show a SageMaker endpoint through Lambda and API Gateway.
The next code snippet is a Lambda operate to rework the request and the response
Replace the endpoint
and prediction_label
values within the Lambda operate primarily based in your configuration.
- Add an setting variable
SAGEMAKER_ENDPOINT_NAME
to seize the SageMaker inference endpoint. - Set the prediction label to match the mannequin output JSON key that’s registered in Einstein Studio.
The default timeout for a Lambda operate is 3 seconds. Relying on the prediction request enter dimension, the SageMaker real-time inference API might take greater than 3 seconds to reply.
- Improve the Lambda operate timeout however preserve it under the API Gateway default integration timeout, which is 29 seconds.
Register the mannequin in Salesforce Einstein Studio
To register the API Gateway endpoint in Einstein Studio, consult with Deliver Your Personal AI Fashions to Knowledge Cloud.
Conclusion
On this submit, we defined how you should utilize SageMaker Canvas to connect with Salesforce Knowledge Cloud and generate predictions by means of automated ML options with out writing a single line of code. We demonstrated the SageMaker Canvas mannequin construct functionality to conduct an early preview of your mannequin efficiency earlier than working the usual construct that trains the mannequin with the total dataset. We additionally showcased post-model creation actions like utilizing the only predictions interface inside SageMaker Canvas and understanding your predictions utilizing characteristic significance. Subsequent, we used the SageMaker endpoint created in SageMaker Canvas and made it out there as an API so you’ll be able to combine it with Salesforce Einstein Studio and create highly effective Salesforce functions.
In an upcoming submit, we’ll present you the way to use knowledge from Salesforce Knowledge Cloud in SageMaker Canvas to make knowledge insights and preparation much more easy by utilizing a visible interface and easy pure language prompts.
To get began with SageMaker Canvas, see SageMaker Canvas immersion day and consult with Getting began with Amazon SageMaker Canvas.
In regards to the authors
Daryl Martis is the Director of Product for Einstein Studio at Salesforce Knowledge Cloud. He has over 10 years of expertise in planning, constructing, launching, and managing world-class options for enterprise prospects, together with AI/ML and cloud options. He has beforehand labored within the monetary companies business in New York Metropolis. Observe him on Linkedin.
Rachna Chadha is a Principal Options Architect AI/ML in Strategic Accounts at AWS. Rachna is an optimist who believes that moral and accountable use of AI can enhance society sooner or later and convey financial and social prosperity. In her spare time, Rachna likes spending time along with her household, mountaineering, and listening to music.
Ife Stewart is a Principal Options Architect within the Strategic ISV phase at AWS. She has been engaged with Salesforce Knowledge Cloud during the last 2 years to assist construct built-in buyer experiences throughout Salesforce and AWS. Ife has over 10 years of expertise in expertise. She is an advocate for variety and inclusion within the expertise subject.
Ravi Bhattiprolu is a Sr. Associate Options Architect at AWS. Ravi works with strategic companions, Salesforce and Tableau, to ship revolutionary and well-architected merchandise and options that assist joint prospects notice their enterprise goals.
Miriam Lebowitz is a Options Architect within the Strategic ISV phase at AWS. She is engaged with groups throughout Salesforce, together with Salesforce Knowledge Cloud, and focuses on knowledge analytics. Outdoors of labor, she enjoys baking, touring, and spending high quality time with family and friends.