Einstein Discovery in Tableau – Try it for Yourself

4.8
(6)

Einstein Discovery empowers businesses to explore patterns, trends, and correlations in their historical data with the help of auto-generated machine learning models. While understanding the past is helpful, Einstein Discovery machine learning models can be deployed and operationalized to predict future outcomes – all without ever writing a single line of code. Starting with the Tableau 2021.1 release, Einstein Discovery predictive models can be consumed in Tableau to help users make smarter decisions with predictive analytics. To build and maintain your models, you need access to Einstein Discovery using a Tableau CRM (formerly known as Einstein Analytics) license in Salesforce. If your company is new to Salesforce or doesn’t already own licenses to use Einstein Discovery, this step-by-step guide will walk through how you can try out the features for free using your very own Trailhead Developer Edition of Salesforce, which includes a Tableau CRM Plus license.

image.png

Step 1 – Visit Einstein Discovery Basics in Trailhead

New to Trailhead? This is Salesforce’s learning platform where you can learn how to use just about any Salesforce feature (as long as you don’t get distracted by all the furry animals).

The Einstein Discovery Basics trail will introduce the product as well as get you set up with creating your first Einstein Discovery Model. Within this trail, you will be able to create your own free Developer Edition Salesforce org, complete with Einstein Discovery, but if you’re too busy to read through the modules, you can just create your org by clicking here (just promise me you’ll go back and take the trails to learn more about the product). Make sure to save your login and password as you’ll use it to authenticate Einstein Discovery in Tableau later in the process.

Step 2 – Create Your Einstein Discovery Model

We all know and love the pre-built Superstore workbook, so to keep things simple, we’re going to use Einstein Discovery to analyze historical product sales by category and month and surface the factors that are driving higher Profit. 

image.png

Before analyzing data with Einstein Discovery, it’s important to get your data at the right grain level. Since the Superstore dataset has daily product sales data, I used a CRM Analytics Recipe to aggregate the sum of profit by category and month. CRM Analytics has a built in data layer that lets you clean and prepare your data before analyzing it with Einstein Discovery. 

While I encourage you to learn more about CRM Analytics Recipes (which you can do in Trailhead), you can simply download this model training dataset which has already been aggregated by Category, State, and Date (Year – Month).

Once you log into your free Developer org (provided in the Trailhead mentioned above), you will need to launch Analytics Studio, which is where you will begin.

Next, upload the model training dataset you downloaded from the link above by clicking Create on the right-hand side in Analytics Studio, and selecting Dataset from the menu.

Choose CSV File and upload the CSV for the Superstore Model Training data.

image.png
image.png

Review what’s included in the dataset to make sure it is accurate, and click Upload File.

Once your dataset has been created, the dataset page will automatically load. Here you will click Create Model on the right side to start your analysis.

For this example, we will be analyzing this dataset to see what is driving higher profit. So we will predict the field “Profit” so we can “Maximize” it. Click the “Next” button to move to the next step of the Model-building wizard.

For simplicity, just choose Automated setup. This is where Einstein Discovery will automatically choose the best fields based on R-squared, but in this case, since there are only 5 fields, all will be selected. Then click Create Model.

The Model should only take a minute or two to complete, and you should see something like this:

Step 3 – Deploy the Model

Feel free to navigate the Data Insights however you want. You will notice that the number variables have all been bucketed into 10 bins. This is done so Einstein Discovery can better explain how numbers impact the overall outcome. Spoiler alert: higher discount buckets mean less profit. Also, if you click into the Performance tab, you’ll see this isn’t exactly the best predictive model, but the purpose of this guide isn’t about building the best model—it’s to show you how to consume a predictive model in Tableau, so we can worry about model tuning later.

In order to use the predictive model in Tableau, you will first need to deploy it in CRM Analytics. Click the Deploy Model button from the overview of the Performance Tab.

You will want to deploy this model as a new Prediction. The Prediction Title that you enter on this page is what users will see in the Tableau Einstein Discovery Extension, so make sure it’s something that will make sense to your users. Click Next to move onto the next step. Note that Einstein Discovery supports up to 10 model segments per Prediction, so if you want to segment your models, let’s say by region or product, you can do that by adding a model to an existing prediction definition (the middle radio button)

Einstein Discovery can be used to make predictions inside or outside Salesforce. Since this model is intended to be used outside of Salesforce, choose the option to Deploy without connecting to a Salesforce Object, then click Next.

As I mentioned above, Einstein Discovery supports multiple model segments per prediction. When you eventually try out that feature, you will need to create a segmentation filter. But since this is just a basic model, keep the selection of “Don’t Segment,” then click Next.

One of my favorite features of Einstein Discovery is the ability to select actionable variables from the model that, should a user change them, would improve the overall predicted result. Both Discount and Quantity are possible variables that could be adjusted by users, so you can check those two for now. For each variable selected, Einstein Discovery will evaluate all categories of that variable during prediction time and offer recommendations based on how to improve the prediction (in this case, how to predict higher profit). Once you select variables, click Next.

You can customize how Einstein Predictions show up in Tableau. So if you don’t like the default way that top predictors or improvements show up in the Tableau Dashboard Extension, you can fix it here, but for simplicity purposes, just click next.

Now just click deploy

After clicking Deploy, you will be taken into CRM Analytics Model Manger where you can see the deployed model.

If you need to edit any of the settings you configured in the deploy wizard, such as adding segmentation filters or changing the Improvement Variables, you can access the model settings from here by clicking the arrow and selecting View Model Details.

To get back to model manager you will see it on the left hand side of the Analytics Studio home page

image.png

Step 4 – Add the Einstein Discovery Extension to Your Tableau Dashboard

Now it’s time to add the Einstein Discovery Extension to your dashboard so that users can consume the model within their Tableau workflow. This step requires, at a minimum, Tableau version 2021.1 (Desktop, Server or Online). If you’re using Tableau Server or Online, you may need to speak with your admin first as there are a few additional security steps required such as setting up Cross-Origin Resource Sharing (CORS) in your Salesforce org as well as setting up Saved Credentials in Tableau. 

The Einstein Discovery Extension supports making bulk predictions on table data, as well as performing what-if scenarios using parameters. In this example, I will be showing you how to connect the Extension to parameters. I had to modify the Superstore dashboard and include parameters for Discount, Quantity, State, Category, and Month (because these are the fields I used to build the predictive model). I know it’s not hard to create these, but if you want a workbook where it’s already been done, feel free to download this.

image.png

Start by dragging and dropping the Extension object onto your Tableau dashboard.

This automatically launches the new In-App Extension Gallery. You can search for the Einstein Discovery Extension and click the Add to Dashboard button.

image.png
image.png

Upon adding this to your dashboard, your default browser will launch with a login page to Salesforce. Here is where you can log into the same Trailhead Developer Salesforce org you used to build and deploy the model.

image.png

Once authenticating, you will need to allow Tableau to access your Salesforce data, as that’s where you’ve built your models. 

image.png

Return to Tableau Desktop and you can start configuring the extension. Click the Search Predictions field and select the title of the Prediction you created in Step 3. Next, change the radio button from Worksheet to Parameters, and click Proceed.

Make sure all model fields are mapped appropriately to your parameters. If you are using the workbook you downloaded above, all parameters should automatically map, but if you created them yourself, the names might not match exactly. Then click Next. 

image (11).png
image.png

Lastly, you have some options for how the prediction shows up, including changing the title, adding units, and deciding how many top factors and improvements you want to show. Then click Done.

image.png

That’s it! Now every time you change a parameter, the Einstein Discovery Extension will pass the parameter values to Salesforce and evaluate a new prediction. 

Notice the recommendations under the “How To Improve This“ section at the bottom. As mentioned in Step 3, Einstein Discovery will evaluate other values of certain variables and offer recommendations on how to improve the predicted outcome. In the screenshot here, predicted profit would improve simply by lowering the Discount from its current value of .25 to somewhere between 0.04 and 0.18.

Step 5 – Customization and Maintenance

Now that you have completed a simple example, it’s time to explore all the ways to customize.

Customize the Dashboard Extension
There are several options you can tweak in the Dashboard Extension configuration page to customize what is shown to users. For example:

  • Increase or decrease the number of top factors or improvements shown
  • Hide the impact value for each factor or improvement
  • Choose a threshold that determines which improvements are shown. For instance, only show the improvement if it improves the overall prediction by at least 20%
  • Disable Top Factors or Improvements if you don’t want to show them

Customize the Predictive Model
There are plenty of things you can do to customize the predictive model back in Salesforce to tailor it to your business’s changing needs. For example:

Customize the Prediction Text:
Maybe you want to change the text that shows up in the How to Improve This section so business users can understand better what Einstein Discovery is suggesting to them.

  1. Find and open the Prediction in the Model Manager in CRM Analytics
  2. Click View Model Details on the model
  3. Click on the pencil next to Prediction Customization
  4. Select the “Customize” radio button. 

You will have access to the certain key words which you can embed within any text you want. Note that this text will only show up in a single language. Once you save, you may need to reload your dashboard component in Tableau to see the changes as some of the data will have been cached.

Choose different Action Variables:
Within the Model Settings panel click the pencil next to the Action Variables. You can choose to include different Action Variables for users. Note that the more variables you select, the slower the performance may be on the Extension because the Prediction will take longer to complete.

Engineer features with Recipes:
Need to calculate, aggregate, or provide some structure to your unstructured data? Tableau CRM Recipes will let you do just that. Just pop on over to the Data Manager from Analytics Studio in Tableau CRM, and get access to a huge toolkit of transformations that will empower you to build better models.

image.png

Build a new Model Version:
Model building is an iterative process. When you edit a Model, you can configure settings such as the bucket ranges used for number fields as well as filtering out outliers. Bring in new fields and more rows of data (just update the dataset with a new CSV) if you can. Every time you click Train Model, a new model version will be created. 

Try different model algorithm:
By default, models are run using General Linear Models (GLM) because they have the best explainability and are the fastest at making predictions. However, tree-based models like Gradient Boosting Machines (GBM), Extreme Gradient Boosting (XGBoost), and Random Forest may provide more accurate predictions. Not sure which algorithm is best? Just select Model Tournament and let Einstein choose the best model for you. Note that both XGBoost and Random Forest may perform significantly slower when making predictions in bulk, especially when improvement variables are selected.

Deploy a new Model Version:
If you do make changes to your Model, you will need to deploy the new model updates. When doing this, make sure to select the radio button “Add or replace a model in an existing prediction” within the deploy wizard, choose the prediction that is already connected to your Tableau dashboard, and check the box to “Replace model”.

Conclusion

In just a few steps, you can get going and quickly build predictive models using Einstein Discovery, consuming them within Tableau. By getting predictions and recommendations at the point of decision making, your users can make more intelligent, data driven decisions.

How useful was this post?

Click on a star to rate useful the post is!

Written by


1 thought on “Einstein Discovery in Tableau – Try it for Yourself”

  • 1
    Reinhard on April 13, 2021 Reply

    Thank you for the great walkthrough Bobby! Excited to use this new integration feature to bring ML to Tableau Dashboards

Leave a Reply to Reinhard Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.