cancel
Showing results for 
Search instead for 
Did you mean: 

PowerApps AI Builder Hands-On Lab Binary Classification

The PowerApps AI Builder product team did a great job of creating Labs for PowerApps AI Builder. The challenge I found is they actually put the content in a couple of different locations: Two different GitHub Repos with two different locations in docs that need to be knit together to get it all working. This post simply brings all that content to a single location until the Team makes the demo an installable component.

PowerApps AI Builder needs a large enough dataset size as to train your models. This being the case to get started you need to import data into your CDS instance.

Data Preparation:

    1. Download the AI Builder sample datasets solution, AIBuilderOnlineShopperIntention_1_0_0_0.zip, from here.
    2. In PowerApps, select Solutions in the left-side navigation pane, then select Import at the top of the screen.
    3. In the pop-up screen, select Choose File, and then select AIBuilderOnlineShopperIntention_1_0_0_0.zip that you downloaded in step 1.
    4. Follow the on-screen instructions to import the solution, and then select Close after you finish.

    Next, import the sample data into the entity. In this example, we use the aib_onlineshopperintention.csv file:

    1. In the list of AI Builder samples, select the aib_onlineshopperintention.csv file, and then select Download to open the raw version of the file.
    2. Copy the URL from the address bar in your browser. In this case, the URL to copy is: https://raw.githubusercontent.com/microsoft/PowerApps-Samples/master/ai-builder/aib_onlineshopperint....
    3. In PowerApps, select Entities in the left-side navigation pane, select Get data > Text/CSV, and then paste the copied URL from the last step into the File path or URL box.
    4. Set the following properties, and then select Next:
      • On-premises data gateway = (none)
      • Authentication kind = Anonymous
    5. On the Map entities screen, make sure Load to existing entity is selected, and under Destination entity, select aib_onlineshopperintention in the drop-down menu.
    6. Select the Delete rows that no longer exist in the query output check box, and then select the Auto-map function that is on the upper right of the Field mapping screen. Select Next.
    7. On the Refresh settings screen, select the Refresh manually check box, and then select Create to start the import process.

    Allow some time for the import to complete. Then, make sure the data is imported correctly.

    1. In PowerApps, go back to Entities under Data and select Online Shopper Intention.
    2. Select Views and then select Active Online Shopper Intention.
    3. Add fields on the left side to validate that all the fields have been imported correctly.
    4. Select Publish to save the current view with the selected fields.

Now that you some data you can use AI Builder!!

This section of the Lab is found in the following Git Repo: https://github.com/microsoft/PowerApps-Samples/blob/master/ai-builder/labs/AIBuilder_Lab.zip

Binary classification

Binary classification uses historical data to predict whether new data falls into one of two categories. You can use these insights to develop actionable intelligence for your business.

In this lab, we will build and train a binary classification model. We will also review the level of influence of the selected criteria. Finally, we will make a model-driven application to review this data prediction.

The data used here will help us predict online shopper intentions. We have details of a shopper’s site visit as well as if that visit resulted in a sale (revenue). Once we have the prediction information, we can use that to help guide marketing plans, website updates, promotional communications, and more.

Note: If you are building the first model in an environment, click on Explore Templates to get started.

Exercise 1

In the first exercise you will build and train your model.

  1. From the left navigation, expand AI Builder and select Build.

  1. Select Binary Classification.

  1. Name your model. Because you are working in a shared environment make sure to include your name as part of the model name. This will make it easier to find later. Click create.

  1. Your screen should look like the following image.

  1. Notice the progress indicator on the left.

  1. You will see Quick tips on the right.

  1. In the center we will build our model. Click in the Entity field and select Online Shopper Intention. This is a custom entity that collects the data we are storing regarding the online shopper’s visit to our site.

  1. From the selected entity we will now see available binary fields for prediction. The only fields we will see here are of type “Two option.” Select Revenue. Click Next.

  1. The next screen will show us available fields on the entity. Each field selected will be evaluated by the model for the fields influence on the end result. By default, all fields will be selected, do not remove any fields. Click Next.
  2. Notice our progress indicator has moved to the next item. Click Train.

  1. Your Binary Classification model will now train. Go to Models.

  1. Locate and open your saved model. If you need help finding it, type your name into the search box.

  1. After each training, AI Builder uses the test data set to evaluate the quality and accuracy of the new model. A summary page for your model shows your model training result, including a Performance score. The score we have is 65% and we should expect it to change over time. And now we can view some details about our trained model. Click on View Details.

  1. Our details report will show the data influencers and how much influence that data has on our prediction model. Close the details.

  1. Publish your model. Once published the data will get scored, and scoring will happen daily for a published model.

About that score

:

Performance score calculations

AI Builder calculates the performance score for your model based on the precision and recall of the prediction results:

Performance score: This is the harmonic mean of precision and recall. It balances both for an imbalanced class distribution. Performance score values are between 0 – 100. Generally, the higher the performance score, the better your model performs.

Precision: The fraction of correct predictions among all the positive predictions.

Recall: The fraction of correct predictions among all true positive cases.

Exercise 2

We will make a small model driven application to view the data. This approach allows us a quick look at the data. You could also make a canvas app that allows users to interact with the data from a mobile device.

  For the purposes of this lab, we have taken some shortcuts in the interest of time. In general, you should always be working in a specific solution, you should rename items with smart names for better team development and more. A full lesson on customization and solution strategy is beyond the scope of these labs. However, Microsoft has many learning choices available. Please ask your instructor if you’d like more information.
  1. In your PowerApps maker portal, from the left side navigation, navigate to Apps and select Create an app and select Model-driven.
  2. If this is your first time connecting to a canvas app in this environment, you might be prompted to choose your region. Select the default.
  3. Give your app a name, remember to include your own name as part of it. Leave all other options as they are and click Done.
  4. You should see something like the image below. 
  5. We will now add our online shopper intention entity to the site map. Click the edit icon on the Site Map.

  1. With focus set on the Area give the area a name such as Online Shopper Intentions. Select and name the Group as well.

  1. With the New Subarea selected select Type of Entity and Online Shopper Intention as the entity. Leave other fields as defaults.

  1. Save your Site Map and go back to the App Designer.
  2. You should now see the assets needed for the Online Shopper Intention entity are included in our model-driven app.
  3. Let’s add a view to our app so we can better see the prediction data. Click on Views and then Create New.

  1. If prompted with unsaved changes, you can dismiss by clicking OK (assuming you’ve followed our steps so far!).

 

  1. Click Column Attributes Primary Entity.
  2. Drag and drop the following fields to the view: revenue-predicted(modelname); revenue-probability(modelname); and revenue.Note:

    You will see fields added for the models of all of the students working in the same environment, look for the ones with your model name in the field name.

  1. Adjust column widths to make them wider and easier to view. With the column selected, increase the width using the options on the right side of the view designer.

  1. Save your view, remember to include your name as part of the view name.

  1. Return to App Designer. Save your app and publish it.

  1. Play your app.

  1. You should now be in your new model-driven app. Select the view you just created.

  1. View the data. You can see the prediction score, and the prediction that follows. With this information you can create automation such as a flow that would trigger based on a customer’s expected revenue and send discount emails to customers likely to complete a purchase. Creating such automation is beyond the scope of this workshop.

 

A “cliff notes version of these direction are also in the docs here: https://docs.microsoft.com/en-us/ai-builder/binary-classification-model-driven-app

  • Sign in to PowerApps, select Apps from the menu, and then select Create an app > Model-driven at the top of the screen.
  • On the Create a New App screen, complete the fields and then select Done.
  • On the App Designer screen, you need to:
    • Create a view of your entity that contains the predicted fields from prediction output.
    • Add the view to the site map.
  • Select Entities on the Components menu, select your entity, and then select Back.
  • Select Save at the top of the screen so that you don’t lose your progress when you create a view, then select Views under Entity view and select Create New on the Components tab.
  • Select Column Attributes – Primary Entity on the Components tab, and then select the fields generated by prediction output.
  • Select Save And Close, give your view a name, and then select the view you just created. Then, select Save again.
  • Select the pencil icon next to Site Map and rename New Group appropriately.
  • Select New Subarea and select Entity as the Type, and then select your entity from the Entity drop-down menu.
  • Select Save And Close and then select Publish.
  • Select Play. Your output should look something like this

Comments

Hi Admin

I am trying to message admin about joining community blog (author) but getting error.

Please help

Screen Shot 2019-08-18 at 2.57.19 pm.png

 

@chass can you please help me with my comment above?

Love to have you blog here!

Can you send me email at chass@microsoft.com

 

Meet Our Blog Authors