Tutorial Part 5: Visualize predictions with a Power BI report
In this tutorial, you create a Power BI report from the predictions data generated in Part 4: Perform batch scoring and save predictions to a lakehouse.
You'll learn how to:
- Create a semantic model from the predictions data.
- Add new measures to the data from Power BI.
- Create a Power BI report.
- Add visualizations to the report.
Prerequisites
Get a Microsoft Fabric subscription. Or, sign up for a free Microsoft Fabric trial.
Sign in to Microsoft Fabric.
Use the experience switcher on the left side of your home page to switch to the Synapse Data Science experience.
This is part 5 of 5 in the tutorial series. To complete this tutorial, first complete:
- Part 1: Ingest data into a Microsoft Fabric lakehouse using Apache Spark.
- Part 2: Explore and visualize data using Microsoft Fabric notebooks to learn more about the data.
- Part 3: Train and register machine learning models.
- Part 4: Perform batch scoring and save predictions to a lakehouse.
Create a semantic model
Create a new semantic model linked to the predictions data you produced in part 4:
On the left, select your workspace.
On the top left, select Lakehouse as a filter.
Select the lakehouse that you used in the previous parts of the tutorial series.
Select New semantic model on the top ribbon.
Give the semantic model a name, such as "bank churn predictions." Then select the customer_churn_test_predictions dataset.
Select Confirm.
Add new measures
Now add a few measures to the semantic model:
Add a new measure for the churn rate.
Select New measure in the top ribbon. This action adds a new item named Measure to the customer_churn_test_predictions dataset, and opens a formula bar above the table.
To determine the average predicted churn rate, replace
Measure =
in the formula bar with:Churn Rate = AVERAGE(customer_churn_test_predictions[predictions])
To apply the formula, select the check mark in the formula bar. The new measure appears in the data table. The calculator icon shows it was created as a measure.
Change the format from General to Percentage in the Properties panel.
Scroll down in the Properties panel to change the Decimal places to 1.
Add a new measure that counts the total number of bank customers. You'll need it for the rest of the new measures.
Select New measure in the top ribbon to add a new item named Measure to the
customer_churn_test_predictions
dataset. This action also opens a formula bar above the table.Each prediction represents one customer. To determine the total number of customers, replace
Measure =
in the formula bar with:Customers = COUNT(customer_churn_test_predictions[predictions])
To apply the formula, select the check mark in the formula bar.
Add the churn rate for Germany.
Select New measure in the top ribbon to add a new item named Measure to the
customer_churn_test_predictions
dataset. This action also opens a formula bar above the table.To determine the churn rate for Germany, replace
Measure =
in the formula bar with:Germany Churn = CALCULATE(AVERAGE(customer_churn_test_predictions[predictions]),FILTER(customer_churn_test_predictions, customer_churn_test_predictions[Geography_Germany] = TRUE()))
This filters the rows down to the ones with Germany as their geography (Geography_Germany equals one).
To apply the formula, select the check mark in the formula bar.
Repeat the above step to add the churn rates for France and Spain.
Spain's churn rate:
Spain Churn = CALCULATE(AVERAGE(customer_churn_test_predictions[predictions]),FILTER(customer_churn_test_predictions, customer_churn_test_predictions[Geography_Spain] = TRUE()))
France's churn rate:
France Churn = CALCULATE(AVERAGE(customer_churn_test_predictions[predictions]),FILTER(customer_churn_test_predictions, customer_churn_test_predictions[Geography_France] = TRUE()))
Create new report
Once you're done with all operations, move on to the Power BI report authoring page by selecting Create report on the top ribbon.
Once the report page appears, add these visuals:
Select the text box on the top ribbon and enter a title for the report, such as "Bank Customer Churn". Change the font size and background color in the Format panel. Adjust the font size and color by selecting the text and using the format bar.
In the Visualizations panel, select the Card icon. From the Data pane, select Churn Rate. Change the font size and background color in the Format panel. Drag this visualization to the top right of the report.
In the Visualizations panel, select the Line and stacked column chart icon. Select age for the x-axis, Churn Rate for column y-axis, and Customers for the line y-axis.
In the Visualizations panel, select the Line and stacked column chart icon. Select NumOfProducts for x-axis, Churn Rate for column y-axis, and Customers for the line y-axis.
In the Visualizations panel, select the Stacked column chart icon. Select NewCreditsScore for x-axis and Churn Rate for y-axis.
Change the title "NewCreditsScore" to "Credit Score" in the Format panel.
In the Visualizations panel, select the Clustered column chart card. Select Germany Churn, Spain Churn, France Churn in that order for the y-axis.
Note
This report represents an illustrated example of how you might analyze the saved prediction results in Power BI. However, for a real customer churn use-case, the you may have to do more thorough ideation of what visualizations to create, based on your subject matter expertise, and what your firm and business analytics team has standardized as metrics.
The Power BI report shows:
- Bank customers who use more than two of the bank products have a higher churn rate, although few customers had more than two products. The bank should collect more data, but also investigate other features that correlate with more products (review the plot in the bottom left panel).
- Bank customers in Germany have a higher churn rate than in France and Spain (review the plot in the bottom right panel), suggesting that an investigation into what encouraged customers to leave could become helpful.
- There are more middle aged customers (between 25-45), and customers between 45-60 tend to exit more.
- Finally, customers with lower credit scores would most likely leave the bank for other financial institutions. The bank should look for ways to encourage customers with lower credit scores and account balances to stay with the bank.
Next step
This completes the five part tutorial series. See other end-to-end sample tutorials: