Example - What-if analysis with the Qlik Predict analytics connector | Qlik Cloud Help
Skip to main content Skip to complementary content

Example - What-if analysis with the Qlik Predict analytics connector

In this example, you will configure a what-if analysis to simulate how predicted values change when different variables are adjusted. The example involves training and deploying a binary classification model in Qlik Predict, and using it to create predictions with the Qlik Predict analytics connector.

What-if analysis application

What-if analysis result

Before you start

Download example materials

Download the example resources here:

WhatIfAnalysisExample.zip

The materials consist of:

  • A training dataset—data-turnover-employees.xlsx. This dataset is used for both the training and predictions for the example.

  • An application—What-If Analysis.qvf. The application cannot be used to generate predictions without first training and deploying a model.

Prerequisites

Before you start, ensure:

Part 1: Upload the dataset

  1. Go to the Create page of the Analytics activity center and select Dataset.

  2. Click Upload data file.

  3. Drag and drop the data-turnover-employees.xlsx data file into the Add file dialog.

  4. Select a destination space for the file. It can be your personal space or a shared space. Use the same space for all tutorial assets.

  5. Click Upload.

Part 2: Train the experiment

Create, configure, and run an experiment to train a binary classification model. All available features will be included by default.

  1. Go to the Create page of the Analytics activity center and select ML experiment.

  2. Enter a name for your experiment, for example, Employee turnover analysis.

  3. Choose a space for the experiment (use the same space you used in Part 1: Upload the dataset).

  4. Click Create.

  5. Select the training dataset file data-turnover-employees.xlsx.

  6. Select the left column as the target. This is a column indicating whether or not an employee left the company.

  7. Click Run experiment.

Part 3: Deploy and activate the top-performing model

Deployment

After experiment training completed, you land on the Models tab. Deploy the top-performing model as an ML deployment.

  1. Click Three-dot menu next to the model that has a Trophy icon next to it.

  2. Click ML deployment Deploy.

  3. Select the option to deploy the model to A new deployment.

  4. Type a name for your deployment, such as Employee Turnover Predictions.

  5. If needed, adjust the space, description, and tags.

  6. Turn on Enable real-time API access. This is required for running predictions with the Qlik Predict analytics connector.

  7. Click Create.

Activation

Open the newly created deployment.

At the top of the ML deployment interface, a banner indicates that a model approver needs to activate the default model for making predictions.

  1. In the banner at the top of the ML deployment, click Activate model.

  2. In the dialog that opens, click Activate model to confirm.

Part 4: Create a connection to the Qlik Predict analytics connector

Next, create a connection to the Qlik Predict analytics connector. This will allow you to generate predictions on the fly within the analytics application.

  1. Go to the Create page of the Analytics activity center and select Data connection.

  2. Under Space, select the same space you used in Part 1: Upload the dataset.

  3. Select the Qlik Predict connector.

  4. Select the ML deployment that you created in Part 3: Deploy and activate the top-performing model.

  5. Enter the following Name: MLModel.

  6. Click Create.

Part 5: Upload the analytics application

Upload the analytics application you downloaded in Download example materials.

  1. Go to the Create page of the Analytics activity center.

  2. Under Data and upload, select Upload.

  3. Drop the What-If Analysis.qvf application into the dialog.

  4. Under Space, select the same space you used in Part 1: Upload the dataset and Part 4: Create a connection to the Qlik Predict analytics connector.

  5. Click Upload.

After uploading the application, open it, and then open the What-If Analysis sheet.

Information noteThe application is pre-configured so you do not need to add sheets and expressions. However, each step is detailed in Understanding the application.

Explore the results

You now have the What-If Analysis sheet opened in the application.

  1. Select a single employee value in the employee_number field. A value appears in the Risk of Turnover KPI.

  2. Adjust the sliders below the KPI. With each adjustment, a simulation is performed to predict the risk of employee churn.

What-if analysis with a single employee selected, and variables adjusted.

What-if analysis result

Understanding the application

Loaded data

The training dataset used in Part 2: Train the experiment is used as the application data. In real-world scenarios, this might not always be the case.

Sheet variables

The following variables were created, each with a blank default definition. The definition is left blank because the variable values are updated on the fly during analysis instead.

Variables for what-if analysis
Variable name Model feature it represents Variable default definition
vSatisfactionLevel satisfaction_level -
vTimeSpent time_spend_company -
vNumberOfProjects number_project -
vAvgMonthlyHoursWorked average_monthly_hours -

KPI and expression

A KPI was added to the sheet. The following chart expression is used:

endpoints.ScriptEvalStr('{"RequestType":"endpoint", "endpoint":{"connectionname":":MLModel","column":"left_yes"}}',
	vSatisfactionLevel as satisfaction_level,
	vTimeSpent as time_spend_company,
	last_evaluation,
	vNumberOfProjects as number_project,
	vAvgMonthlyHoursWorked as average_monthly_hours)

The calculation represents the risk of turnover for the selected employee.

The sections below outline how this expression uses server-side extensions syntax to call the Machine Learning API for real-time predictions.

Breaking down the expression

The expression uses server-side extensions (SSE) syntax to generate predictions on the fly.

Variable input objects

Four variable input controls were added to the sheet—one for each variable. The following configurations have been done:

  • The variable to use was selected.

  • The type of input was selected as Slider.

  • Minimum and maximum ranges for each variable were configured, based on values that could reasonably occur as per the original data.

For more information about variable input objects, see Creating variable input controls.

Filter pane

A filter pane was added to allow easy selection of the employee on which to focus.

Table with the original data

A straight table was also added at the bottom of the sheet, to make it easy to see the original data—before it was altered during the what-if analysis.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!