Skip to content

Getting Started with TIM in Qlik

This section takes you through the different steps in setting up a forecasting app and an anomaly detection app in Qlik Sense. Before continuing, make sure you meet following assumptions:

  • You have installed the TIM SSE.
  • You have created a new app in Qlik Sense.
  • You have added your data to the new app.

Setting up a forecasting app

When the assumptions above are met, proceed with the following steps:

  1. Click "Edit sheet" and drag a Line chart to the worksheet. Select the variable containing the timestamp as dimension and the variable containing the desired target as measure. The aggregation level of the measure (target variable) should be Sum( ).

  2. You can now either use the function parameters directly to communicate your desired forecast request(s), or you can set up a dashboard interface with buttons and input fields to manipulate the request(s), as in the example. Decide which approach you want to take, and follow along the appropriate section below.

The direct approach

Forecasting

  1. Select Add to add a new measure to the line chart and click on the function button image.png to open the Expression editor.

  2. To call the SSE's forecasting function, you first need to make it clear to Qlik that you're communicating to the SSE. You do so by typing in the name you have given the SSE in your environment, ex.g. "TIMSSE". Then, you call the desired function - "F_Forecast" - on this SSE. The text in your editor should now look similar to this: TIMSSE.F_Forecast().

  3. Now, add all the parameters this function expects. For more information on these parameters, go to the section of the documentation on the functions of the TIM SSE. Parameters should be separated by commas.

  4. The first parameter is a string containing all variables to be included. Start by referencing the variable containing the timestamp. Then add & '|' & to separate it from the target and reference the variable containing the target. Again, this variable should be called with the aggregation level Sum( ). After this, you can add all other variables you want to include as predictors, separated by & '|' & and with the aggregation level Sum( ).

    • The second parameter is the start date of the forecast, in the YYYY-MM-DD hh:mm:ss format.
    • The third parameter is the number of samples to forecast.
    • The fourth parameter is a boolean indicating if a new model is should be built or not. Setting this to "1" allows to make changes to the input parameters, without triggering a new forecasting model to be built on these new inputs.
    • The fifth parameter is a list of the names (and optionally availabilities) of all included variables, including the timestamp and the target variable. The variable names should be separated by commas. If no availabilities are set, the default data availability will be assumed: all variables are available until the end of the target variable, i.e. the last timestamp before the start of the forecasting horizon.

    The text in your editor should now look similar to this: =TIMSSE.F_Forecast(Timestamp & '|' & Sum(cnt) & '|' & Sum(holiday) & '|' & Sum(temp_o) & '|' & Sum(atemp_o) & '|' & Sum(humidity) & '|' & Sum(windspeed), '2011-08-04', 168, 1,'Timestamp,Riders,Holiday +168,Temperature -10,Temperature_Deviance +5,Humidity +48, Windspeed -48').

  5. Click "Apply", and the line chart will be updated with the forecast as soon as it's calculated.

Retrieving predictor importances

  1. Drag a Table to the worksheet and select the variable containing the timestamp as dimension. Set the Label to =' ' and the Text color expression to white(). This will create a table with the desired structure, without negatively impacting the table's look.

  2. Click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "F_PredictorImportances" function on this SSE. The text in your editor should now look similar to this: TIMSSE.F_PredictorImportances().

  4. Add the same parameters as you did in the "F_Forecast" function. Add an additional parameter with the value 'predictor_name'. This indicates that you want to retrieve the names of the predictors that were used in the forecasting model. The text in your editor should now look similar to this:

    TIMSSE.F_PredictorImportances(Timestamp & '|' & Sum(cnt) & '|' & Sum(holiday) & '|' & Sum(temp_o) & '|' & Sum(atemp_o) & '|' & Sum(humidity) & '|' & Sum(windspeed), '2011-08-04', 168, 1,'Timestamp,Riders,Holiday +168,Temperature -10,Temperature_Deviance +5,Humidity +48, Windspeed -48, 'predictor_name').

  5. Click "Apply", and the table will be updated with the predictor names as soon as they're returned.

  6. Set the Label to Predictor name.

  7. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  8. Add the exact same function call, this time replacing 'predictor_name' with 'importance'. This indicates that you cant to retrieve each predictor's importance. The text in your editor should look similar to this:

    TIMSSE.F_PredictorImportances(Timestamp & '|' & Sum(cnt) & '|' & Sum(holiday) & '|' & Sum(temp_o) & '|' & Sum(atemp_o) & '|' & Sum(humidity) & '|' & Sum(windspeed), '2011-08-04', 168, 1,'Timestamp,Riders,Holiday +168,Temperature -10,Temperature_Deviance +5,Humidity +48, Windspeed -48, 'importance').

  9. Click "Apply", and the table will be updated with the predictor importances as soon as they're returned.

  10. Set the Label to Importance.

Retrieving feature importances

  1. Drag another Table to the worksheet and select the variable containing the timestamp as dimension. Set the Label to =' ' and the Text color expression to white(). This will again create a table with the desired structure, without negatively impacting the table's look.

  2. Click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "F_FeatureImportances" function on this SSE. The text in your editor should now look similar to this: TIMSSE.F_FeatureImportances().

  4. Add the same parameters as you did in the "F_Forecast" function. Add an additional parameter with the value 'time'. This indicates that you want to retrieve the times to which each of the feature's importances apply. The text in your editor should now look similar to this:

    TIMSSE.F_FeatureImportances(Timestamp & '|' & Sum(cnt) & '|' & Sum(holiday) & '|' & Sum(temp_o) & '|' & Sum(atemp_o) & '|' & Sum(humidity) & '|' & Sum(windspeed), '2011-08-04', 168, 1,'Timestamp,Riders,Holiday +168,Temperature -10,Temperature_Deviance +5,Humidity +48, Windspeed -48, 'time').

  5. Click "Apply", and the table will be updated with the times as soon as they're returned.

  6. Set the Label to Time.

  7. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  8. Add the exact same function call, this time replacing 'time' with 'term_name'. This indicates that you want to retrieve the names of the features that were used in the forecasting model. The text in your editor should look similar to this:

    TIMSSE.F_FeatureImportances(Timestamp & '|' & Sum(cnt) & '|' & Sum(holiday) & '|' & Sum(temp_o) & '|' & Sum(atemp_o) & '|' & Sum(humidity) & '|' & Sum(windspeed), '2011-08-04', 168, 1,'Timestamp,Riders,Holiday +168,Temperature -10,Temperature_Deviance +5,Humidity +48, Windspeed -48, 'term_name').

  9. Click "Apply", and the table will be updated with the feature names as soon as they're returned.

  10. Set the Label to Feature name.

  11. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  12. Add the exact same function call, this time replacing 'term_name' with 'type'. This indicates that you cant to retrieve each feature's type. The text in your editor should look similar to this:

    TIMSSE.F_FeatureImportances(Timestamp & '|' & Sum(cnt) & '|' & Sum(holiday) & '|' & Sum(temp_o) & '|' & Sum(atemp_o) & '|' & Sum(humidity) & '|' & Sum(windspeed), '2011-08-04', 168, 1,'Timestamp,Riders,Holiday +168,Temperature -10,Temperature_Deviance +5,Humidity +48, Windspeed -48, 'type').

  13. Click "Apply", and the table will be updated with the feature types as soon as they're returned.

  14. Set the Label to Type.

  15. Again, click "Add column" and select measure, then click on the function button (image.png ) to open the Expression editor.

  16. Add the exact same function call, this time replacing 'type' with 'importance'. This indicates that you cant to retrieve each feature's importance. The text in your editor should look similar to this:

    TIMSSE.F_FeatureImportances(Timestamp & '|' & Sum(cnt) & '|' & Sum(holiday) & '|' & Sum(temp_o) & '|' & Sum(atemp_o) & '|' & Sum(humidity) & '|' & Sum(windspeed), '2011-08-04', 168, 1,'Timestamp,Riders,Holiday +168,Temperature -10,Temperature_Deviance +5,Humidity +48, Windspeed -48, 'importance').

  17. Click "Apply", and the table will be updated with the feature importances as soon as they're returned.

  18. Set the Label to Importance.

The interface approach

This approach assumes that you have installed/enabled the Qlik Dashboard bundle.

Setting up the buttons and input fields

  1. Click the Variables button at the bottom left of your screen image.png.

  2. For each variable you want to include in your dashboard as a potential predictor, repeat the following step: click "Create new" to create a variable coupled to the state of the button that you will create for this predictor, and give the new variable a relevant name (ex.g. 'temperature_tog'). Set its value to 0 (not included) or 1 (included) in the Definition field.

    Once such a variable is set up for each of the potential predictors, continue to the next steps. For each potential predictor, repeat the steps below.

    Hint: you can copy and paste the first button and update each instance of <relevant variable>, as well as the <predictor name>, instead of creating a new button from scratch.

  3. Drag a Button to the worksheet and open the Actions and navigation tab in the menu on the right.

  4. Click "Add action" and give the action a Label, ex.g. Toggle.

  5. Select the Action "Set variable value".

  6. In the Variable field that appears below, add the relevant newly created variable you want to link to this button. The text in the expression editor could look like this: ='temperature_tog'. Note: make sure to include the quotation marks.

  7. In the Value field below, add the =Not( ) expression with the variable as argument (ex.g. =Not(temperature_tog)).

  8. Open the Appearance tab in the menu on the right.

  9. In the General section, set the Label to ='<Predictor name> ' & If(<relevant variable>, CHR(9745), CHR(9746)), where

    • <Predictor name> should be replaced by the name of the relevant potential predictor (ex.g. "Temperature"),
    • <relevant variable> should be replacced by the relevant newly created variable (ex.g. "temperature_tog"), and
    • CHR(9745) and CHR(9746) refer to checkbox symbols.
  10. In the Background section, set the Background color to "By expression" and set the Expression to =If(<relevant variable>,'#1D0C5F','#C0BBD3'), where

    • <relevant variable> should be replaced by the relevant newly created variable (ex.g. "temperature_tog"), and
    • the HEX codes can be adjusted to match the desired look of your dashboard. They represent the color of the button when the toggle is set to selected and deselected, respectively.

    When you've created buttons for each of the potential predictors you want to include in the dashboard, you can proceed to the next steps.

  11. Click the Variables button at the bottom left of your screen image.png.

  12. Click "Create new" and create a new variable called "forecast_start".

  13. From the Qlik Dashboard bundle, drag a Variable input to the worksheet. Give it the title "Forecast start". When using the dashboard, this field should contain the timestamp desired to correspond to the first value of the forecast in the YYYY-MM-DD hh:mm:ss format.

  14. In the Appearance tab in the menu on the right, open the Variable section. In the Name selection panel, select the newly created "forecast_start" variable.

  15. Click the Variables button at the bottom left of your screen image.png.

  16. Click "Create new" and create a new variable called "forecast_length".

  17. From the Qlik Dashboard bundle, drag a Variable input to the worksheet. Give it the title "Forecast length".

  18. In the Appearance tab in the menu on the right, open the Variable section. In the Name selection panel, select the newly created "forecast_length" variable.

  19. Click the Variables button at the bottom left of your screen image.png.

  20. Click "Create new" and create a new variable called "model_activation".

  21. Drag a Button to the worksheet and open the Actions and navigation tab in the menu on the right.

  22. Click "Add action" and give the action a Label, ex.g. Toggle.

  23. Select the Action "Set variable value".

  24. In the Variable field that appears below, add the newly created "model_activation" variable to link it to this button. The text in the expression editor should look like this: ='model_activation'. Note: make sure to include the quotation marks.

  25. In the Value field below, insert =Not(model_activation).

  26. Open the Appearance tab in the menu on the right.

  27. In the General section, set the Label to =If(model_activation, 'Deactivate model ', 'Activate model ') & If(model_activation, CHR(9745), CHR(9746)), where CHR(9745) and CHR(9746) refer to checkbox symbols.

  28. In the Background section, set the Background color to "By expression" and set the Expression to =if(model_activation,'#1D0C5F','#C0BBD3'), where the HEX codes can be adjusted to match the desired look of your dashboard. They represent the color of the button when the toggle is set to selected and deselected, respectively.

Now, the user controls for setting the forecasting configuration are set up. The next part makes sure they can be correctly interpreted by the functions.

Creating the function parameter variables

  1. Click the Variables button at the bottom left of your screen image.png.

For each variable you have included in your dashboard as a potential predictor, repeat the following steps:

  1. Click "Create new" to create a variable that will optionally contain this predictor, and give the new variable a relevant name (ex.g. "temperature_var").

  2. Set the variable's value in the Definition field to the following expression: If(<relevant variable toggle>, '|' & Sum(<relevant variable>), ''), where

    • <relevant variable toggle> should be replaced by the variable coupled to the relevant predictor's button (ex.g. "temperature_tog"), and
    • <relevant variable> should be replaced by the variable containing the relevant predictor (ex.g. "Temperature").
  3. Click "Create new" to create a variable that will contain the list of predictor names and optionally their availabilities, and give the new variable the name "variable_names".

  4. This variable will need to contain some conditional elements, to make sure only the names of those predictors that are selected through the buttons are included. Set the variable's value in the Definition field to the following expression:

    ='<timestamps>,<target variable>,' & If(<relevant variable toggle>, '<relevant variable name and optionally its availability>,', '')<potential additional conditional statements>, where

    • <timestamps> is replaced by the name of the variable containing the timestamps,
    • <target variable> is replaced by the name of the variable containing the target,
    • <relevant variable toggle> is replaced by the relevant variable toggle (ex.g. "temperature_tog"),
    • <relevant variable name and optionally its availability> is replaced by the name of the variable the toggle corresponds to (ex.g. "Temperature"), optionally followed by the corresponding availability, and
    • <potential additional conditional statements> is replaced by any other variables to potentially include, in the same conditional format as the example preceeding this argument. Different conditional statements should be separated by &.

    In case the default availability is used (all variables are available until the end of the target variable, i.e. the last timestamp before the start of the forecasting horizon), the expression should now look similar to this:

    ='Timestamp,Riders' & If(isholiday_tog, ',Holiday', '') & If(temp_o_tog, ',Temperature', '') & If(atemp_o_tog, ',Temperature_Deviance', '') & If(hum_p_tog, ',Humidity','') & If(windspeed_tog, ',Windspeed', '').

    In case the availabilities are also set, the expression should now look similar to this:

    ='Timestamp,Riders' & If(isholiday_tog, ',Holiday ' & (forecastlength), '') & If(temp_o_tog, ',Temperature ' & (-10), '') & If(atemp_o_tog, ',Temperature_Deviance ' & (+5), '') & If(hum_p_tog, ',Humidity ' & (forecastlength-1), '') & If(windspeed_tog, ',Windspeed ' & (-24) , '').

    In this example, the temperature is only available up until 10 samples before the start of the forecasting horizon (i.e. two days ago earlier hourly data), but the temperature deviance is available for the first 5 samples of the forecasting horizon. The humidity is available until 1 sample before the end of the forecasting horizon, and the windspeed is available up until 24 samples before the start of the forecasting horizon. Since it's easy to know in advance which days will be public holidays, this variable is available for the entire forecasting horizon.

    Now, the variables to use as parameters in the SSE's functions are ready for use. The next part will take you through setting up these function calls correctly (i.e. so they listen to the UI elements you set up).

Using the variables in the function calls

Forecasting
  1. In the line chart that is already in your worksheet, select Add to add a new measure to the line chart and set the Label to "Forecast".

  2. Click on the function button image.png to open the Expression editor.

  3. To call the SSE's forecasting function, you first need to make it clear to Qlik that you're communicating to the SSE. You do so by typing in the name you have given the SSE in your environment, ex.g. "TIMSSE". Then, you call the desired function - "F_Forecast" - on this SSE. The text in your editor should now look similar to this: TIMSSE.F_Forecast().

  4. Now, add all the parameters this function expects. For more information on these parameters, go to the section of the documentation on the functions of the TIM SSE. Parameters should be separated by commas.

    • The first parameter is a string containing all variables to be included. Start by referencing the variable containing the timestamp. Then add & '|' & to separate it from the target and reference the variable containing the target. This variable should be called with the aggregation level Sum( ). After this, add & followed by all other variables you want to include as potential predictors, i.e. those created in the previous section. You can refer to these variables like this: $(<variable name>), where <variable name> is replaced by the name of the relevant variable.
    • The second parameter is the start date of the forecast, which should be linked to the Variable input of the element titled "Forecast start". The relevant variable that should be included here is forecast_start.
    • The third parameter is the number of samples to forecast, which should be linked to the Variable input of the element titled "Forecast length". The relevant variable that should be included here is forecast_length.
    • The fourth parameter is the boolean indicating if a new model should be built or not. The relevant variable that should be included here is model_activation.
    • The fifth parameter is a list of the names (and optionally availabilities) of all included variables, including the timestamp and the target variable. The relevant variable that should be included here is variable_names.

    The text in your editor should now look similar to this:

    =TIMSSE.F_Forecast(Timestamp & '|' & Sum(cnt) & $(isholiday_var) & $(temp_o_var) & $(atemp_o_var) & $(hum_p_var) & $(windspeed_var), forecast_start, forecastlength, model_activation, variable_names).

  5. Click "Apply", and the line chart is set up to be updated correctly with any changes to the dashboard. To receive a forecast, the "Forecast start" and "Forecast length" Variable inputs should contain actual values, ex.g. 2014-12-01 and 168 respectively.

Retrieving predictor importances
  1. Drag a Table to the worksheet and select the variable containing the timestamp as dimension. Set the Label to =' ' and the Text color expression to white(). This will create a table with the desired structure, without negatively impacting the table's look.

  2. Click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "F_PredictorImportances" function on this SSE. The text in your editor should now look similar to this: TIMSSE.F_PredictorImportances().

  4. Add the same parameters as you did in the "F_Forecast" function. Add an additional parameter with the value 'predictor_name'. This indicates that you want to retrieve the names of the predictors that were used in the forecasting model. The text in your editor should now look similar to this:

    =TIMSSE.F_PredictorImportances(Timestamp & '|' & Sum(cnt) & $(isholiday_var) & $(temp_o_var) & $(atemp_o_var) & $(hum_p_var) & $(windspeed_var), forecast_start, forecastlength, model_activation, variable_names, 'predictor_name').

  5. Click "Apply", and the table will be updated with the predictor names as soon as they're returned.

  6. Set the Label to Predictor name.

  7. Again, click "Add column" and select measure, then click on the function button (image.png ) to open the Expression editor.

  8. Add the exact same function call, this time replacing 'predictor_name' with 'importance'. This indicates that you cant to retrieve each predictor's importance. The text in your editor should look similar to this:

    =TIMSSE.F_PredictorImportances(Timestamp & '|' & Sum(cnt) & $(isholiday_var) & $(temp_o_var) & $(atemp_o_var) & $(hum_p_var) & $(windspeed_var), forecast_start, forecastlength, model_activation, variable_names, 'importance').

  9. Click "Apply", and the table will be updated with the predictor importances as soon as they're returned.

  10. Set the Label to Importance.

Retrieving feature importances
  1. Drag another Table to the worksheet and select the variable containing the timestamp as dimension. Set the Label to =' ' and the Text color expression to white(). This will again create a table with the desired structure, without negatively impacting the table's look.

  2. Click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "F_FeatureImportances" function on this SSE. The text in your editor should now look similar to this: TIMSSE.F_FeatureImportances().

  4. Add the same parameters as you did in the "F_Forecast" function. Add an additional parameter with the value 'time'. This indicates that you want to retrieve the times to which each of the feature's importances apply. The text in your editor should now look similar to this:

    =TIMSSE.F_FeatureImportances(Date & '|' & Sum(Load) & $(temperature_var) & $(cloudiness_var) & $(irradiation_var) & $(publicHolidays_var), forecast_start, forecast_length, model_activation, variable_names, 'time').

  5. Click "Apply", and the table will be updated with the times as soon as they're returned.

  6. Set the Label to Time.

  7. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  8. Add the exact same function call, this time replacing 'time' with 'term_name'. This indicates that you want to retrieve the names of the features that were used in the forecasting model. The text in your editor should look similar to this:

    =TIMSSE.F_FeatureImportances(Date & '|' & Sum(Load) & $(temperature_var) & $(cloudiness_var) & $(irradiation_var) & $(publicHolidays_var), forecast_start, forecast_length, model_activation, variable_names, 'term_name').

  9. Click "Apply", and the table will be updated with the feature names as soon as they're returned.

  10. Set the Label to Feature name.

  11. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  12. Add the exact same function call, this time replacing 'term_name' with 'type'. This indicates that you cant to retrieve each feature's type. The text in your editor should look similar to this:

    =TIMSSE.F_FeatureImportances(Date & '|' & Sum(Load) & $(temperature_var) & $(cloudiness_var) & $(irradiation_var) & $(publicHolidays_var), forecast_start, forecast_length, model_activation, variable_names, 'type').

  13. Click "Apply", and the table will be updated with the feature types as soon as they're returned.

  14. Set the Label to Type.

  15. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  16. Add the exact same function call, this time replacing 'type' with 'importance'. This indicates that you cant to retrieve each feature's importance. The text in your editor should look similar to this:

    =TIMSSE.F_FeatureImportances(Date & '|' & Sum(Load) & $(temperature_var) & $(cloudiness_var) & $(irradiation_var) & $(publicHolidays_var), forecast_start, forecast_length, model_activation, variable_names, 'importance').

  17. Click "Apply", and the table will be updated with the feature importances as soon as they're returned.

  18. Set the Label to Importance.

Now, your dashboard is ready for use! Of course, you can still add titles to the different elements and organize them as you want.

Setting up an anomaly detection app

When the assumptions above are met, proceed with the following steps:

  1. Click "Edit sheet" and drag a Line chart to the worksheet. Select the variable containing the timestamp as dimension and the variable containing the desired target as measure. The aggregation level of the measure (target variable) should be Sum( ).

  2. You can now either use the function parameters directly to communicate your desired forecast request(s), or you can set up a dashboard interface with buttons and input fields to manipulate the request(s), as in the example. Decide which approach you want to take, and follow along the appropriate section below.

Sections indicated with an * should only be executed if you wish to include the SSE's out-of-sample anomaly detection capabilities to your app.

The direct approach

Retrieving in-sample normal behavior

  1. Select Add to add a new measure to the line chart and click on the function button image.png to open the Expression editor.

  2. To call the SSE's anomaly detection function, you first need to make it clear to Qlik that you're communicating to the SSE. You do so by typing in the name you have given the SSE in your environment, ex.g. "TIMSSE". Then, you call the desired function - "AD_Detect" - on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_Detect().

  3. Now, add all the parameters this function expects. For more information on these parameters, go to the section of the documentation on the functions of the TIM SSE. Parameters should be separated by commas.

  4. The first parameter is a string containing all variables to be included. Start by referencing the variable containing the timestamp. Then add & '|' & to separate it from the target and reference the variable containing the target. Again, this variable should be called with the aggregation level Sum( ). After this, you can add all other variables you want to include as predictors, separated by & '|' & and with the aggregation level Sum( ).

    • The second parameter is the start timestamp of the in-sample period, in the YYYY-MM-DD hh:mm:ss format.
    • The third parameter is the end timestamp of the in-sample period, also in the YYYY-MM-DD hh:mm:ss format.
    • The fourth parameter is a boolean indicating if a new model is should be built or not. Setting this to "1" allows to make changes to the input parameters, without triggering a new anomaly detection model to be built on these new inputs.
    • The fifth parameter is a list of the names (and optionally availabilities) of all included variables, including the timestamp and the target variable. The variable names should be separated by commas. If no availabilities are set, the default data availability will be assumed: all variables are available until the end of the target variable, i.e. the last timestamp of the in-sample period, indicated in the third parameter.
    • The sixth parameter indicates what you want the function to return, in this case the normal behavior.
    • The seventh parameter is an identifying key for the model that will be built. This key serves as the link between the model that is built in this request and any out-of-sample detection that should be done with the same model. This is an optional parameter; if you do not wish to use the model for out-of-sample detection, an empty string can be passed.
    • The eighth parameter is the desired sensitivity of the anomaly detection model. This is an optional parameter; if it is left empty, automatic sensitivity estimation is applied.
    • The ninth parameter is a list of the anomaly detection features to include in the model configuration. This is an optional parameter; if an empty string is passed, the default configuration ('Residuals, Imbalance') is used.

    The text in your editor should now look similar to this: =TIMSSE.AD_Detect(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'normal_behavior', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  5. Click "Apply", and the line chart will be updated with the in-sample normal behavior as soon as it's calculated.

Indicating the anomalies on the historical (in-sample) target values

  1. Select Add to add a new measure to the line chart and click on the function button image.png to open the Expression editor.

  2. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_Detect" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_Detect().

  3. Add the same parameters as you did when retrieving the normal behavior, but replace 'normal_behavior' with 'anomalies'. The text in your editor should now look similar to this: =TIMSSE.AD_Detect(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'anomalies', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  4. Click "Apply", and the line chart will be updated with the in-sample anomalies as soon as they're calculated.

Retrieving out-of-sample normal behavior*

  1. Select Add to add a new measure to the line chart and click on the function button image.png to open the Expression editor.

  2. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_DetectOutSample" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_DetectOutSample().

  3. Now, add all the parameters this function expects. For more information on these parameters, go to the section of the documentation on the functions of the TIM SSE. Parameters should be separated by commas.

  4. The first parameter is a string containing all variables to be included. Start by referencing the variable containing the timestamp. Then add & '|' & to separate it from the target and reference the variable containing the target. Again, this variable should be called with the aggregation level Sum( ). After this, you can add all other variables you want to include as predictors, separated by & '|' & and with the aggregation level Sum( ).

    • The second parameter is the start timestamp of the out-of-sample period, in the YYYY-MM-DD hh:mm:ss format.
    • The third parameter is the end timestamp of the out-of-sample period, also in the YYYY-MM-DD hh:mm:ss format.
    • The fourth parameter is a boolean indicating if a new request should be made or not. Setting this to "1" allows to make changes to the input parameters, without triggering a new anomaly detection model to be built on these new inputs.
    • The fifth parameter is a list of the names (and optionally availabilities) of all included variables, including the timestamp and the target variable. The variable names should be separated by commas. If no availabilities are set, the default data availability will be assumed: all variables are available until the end of the target variable, i.e. the last timestamp of the in-sample period, indicated in the third parameter.
    • The sixth parameter indicates what you want the function to return, in this case the normal behavior.
    • The seventh parameter is an identifying key for the model that should be applied. This key serves as the link between the model that is built in an in-sample request and and any out-of-sample detection (such as the one linked to this request) that should be done with the same model.

    The text in your editor should now look similar to this: =TIMSSE.AD_DetectOutSample(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-12-01', '2019-01-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'normal_behavior', 'key').

  5. Click "Apply", and the line chart will be updated with the out-of-sample normal behavior as soon as it's calculated.

Indicating the anomalies on the out-of-sample target values*

  1. Select Add to add a new measure to the line chart and click on the function button image.png to open the Expression editor.

  2. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_DetectOutSample" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_DetectOutSample().

  3. Add the same parameters as you did when retrieving the out-of-sample normal behavior, but replace 'normal_behavior' with 'anomalies'. The text in your editor should now look similar to this: =TIMSSE.AD_DetectOutSample(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-12-01', '2019-01-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'anomalies', 'key', 1).

  4. Click "Apply", and the line chart will be updated with the out-of-sample anomalies as soon as they're calculated.

Retrieving the in-sample residuals

  1. Select Add to add a new measure to the line chart and click on the function button image.png to open the Expression editor.

  2. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_DetectOutSample" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_DetectOutSample().

  3. Add the same parameters as you did when retrieving the in-sample anomalies, but replace 'anomalies' with 'residuals'. The text in your editor should now look similar to this: =TIMSSE.AD_Detect(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'residuals', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  4. Click "Apply", and the line chart will be updated with the in-samples residuals as soon as they're calculated.

Retrieving the out-of-sample residuals*

  1. Drag a Line chart to the worksheet and select the variable containing the timestamp as dimension.

  2. Select Add measure to add a measure to the line chart and click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_DetectOutSample" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_DetectOutSample().

  4. Add the same parameters as you did when retrieving the out-of-sample anomalies, but replace 'anomalies' with 'residuals'. The text in your editor should now look similar to this: =TIMSSE.AD_DetectOutSample(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-12-01', '2019-01-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'residuals', 'key').

  5. Click "Apply", and the line chart will be updated with the out-of-sample residuals as soon as they're calculated.

Adding the predictors to the dashboard

  1. Drag a Line chart to the worksheet. Select the variable containing the timestamp as dimension and any variable containing the additional predictors as measures. The aggregation level of the measures (predictor variable) should be Sum( ).

Retrieving the in-sample anomaly indicator

  1. Drag a Line chart to the worksheet and select the variable containing the timestamp as dimension.

  2. Select Add measure to add a measure to the line chart and click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_Detect" function on the SSE again. The text in your editor should now look similar to this: TIMSSE.AD_Detect().

  4. Add the same parameters as you did when retrieving the in-sample residuals, but replace 'residuals' with 'anomaly_indicator'. The text in your editor should now look similar to this: =TIMSSE.AD_Detect(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'anomaly_indicator', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  5. Click "Apply", and the line chart will be updated with the in-sample anomaly indicator as soon as it's calculated.

  6. Open the Add-ons tab in the menu on the right.

  7. In the Reference lines section, click "Add reference line" and in the Reference line expression field, insert 1. Change the HEX code to #8e477d, or adjust it to match the desired look of your dashboard. This will add a threshold to the line chart, making it easier to distinguish anomalous observations.

Retrieving the out-of-sample anomaly indicator*

  1. Select Add measure to add a measure to the line chart and click on the function button image.png to open the Expression editor.

  2. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_DetectOutSample" function on the SSE again. The text in your editor should now look similar to this: TIMSSE.AD_DetectOutSample().

  3. Add the same parameters as you did when retrieving the out-of-sample residuals, but replace 'residuals' with 'anomaly_indicator'. The text in your editor should now look similar to this: =TIMSSE.AD_DetectOutSample(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-12-01', '2019-01-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'anomaly_indicator', 'key').

  4. Click "Apply", and the line chart will be updated with the out-of-sample anomaly indicator as soon as it's calculated.

Retrieving predictor importances

  1. Drag a Table to the worksheet and select the variable containing the timestamp as dimension. Set the Label to =' ' and the Text color expression to white(). This will create a table with the desired structure, without negatively impacting the table's look.

  2. Click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "F_PredictorImportances" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_PredictorImportances().

  4. Add the same parameters as you did in the "AD_Detect" function. Add an additional parameter with the value 'predictor_name'. This indicates that you want to retrieve the names of the predictors that were used in the anomaly detection model. The text in your editor should now look similar to this:

    =TIMSSE.AD_PredictorImportances(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'predictor_name', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  5. Click "Apply", and the table will be updated with the predictor names as soon as they're returned.

  6. Set the Label to Predictor name.

  7. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  8. Add the exact same function call, this time replacing 'predictor_name' with 'importance'. This indicates that you cant to retrieve each predictor's importance. The text in your editor should look similar to this:

    =TIMSSE.AD_PredictorImportances(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'importance', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  9. Click "Apply", and the table will be updated with the predictor importances as soon as they're returned.

  10. Set the Label to Importance.

Retrieving feature importances

  1. Drag another Table to the worksheet and select the variable containing the timestamp as dimension. Set the Label to =' ' and the Text color expression to white(). This will again create a table with the desired structure, without negatively impacting the table's look.

  2. Click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "F_FeatureImportances" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_FeatureImportances().

  4. Add the same parameters as you did in the "AD_Detect" function. Change the value of the last parameter to 'time'. This indicates that you want to retrieve the times to which each of the feature's importances apply. The text in your editor should now look similar to this:

    =TIMSSE.AD_FeatureImportances(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'time', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  5. Click "Apply", and the table will be updated with the times as soon as they're returned.

  6. Set the Label to Time.

  7. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  8. Add the exact same function call, this time replacing 'time' with 'term_name'. This indicates that you want to retrieve the names of the features that were used in the anomal detection model. The text in your editor should look similar to this:

    =TIMSSE.AD_FeatureImportances(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'term_name', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  9. Click "Apply", and the table will be updated with the feature names as soon as they're returned.

  10. Set the Label to Feature name.

  11. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  12. Add the exact same function call, this time replacing 'term_name' with 'type'. This indicates that you cant to retrieve each feature's type. The text in your editor should look similar to this:

    =TIMSSE.AD_FeatureImportances(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'type', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  13. Click "Apply", and the table will be updated with the feature types as soon as they're returned.

  14. Set the Label to Type.

  15. Again, click "Add column" and select measure, then click on the function button (image.png ) to open the Expression editor.

  16. Add the exact same function call, this time replacing 'type' with 'importance'. This indicates that you cant to retrieve each feature's importance. The text in your editor should look similar to this:

    =TIMSSE.AD_FeatureImportances(Timestamp & '|' & Sum([Temp. gearbox]) & '|' & Sum([Ambient temperature]) & '|' & Sum([Rotor speed]) & '|' & Sum([Temp. shaft bearing]), '2018-01-01', '2018-10-01', 1, 'Timestamp,temp_gearbox,ambient_temperature -5,rotor_speed -1,temp_shaft_bearing', 'importance', 'key', 1, 'Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange').

  17. Click "Apply", and the table will be updated with the feature importances as soon as they're returned.

  18. Set the Label to Importance.

The interface approach

This approach assumes that you have installed/enabled the Qlik Dashboard bundle.

Setting up the buttons and input fields

  1. Click the Variables button at the bottom left of your screen image.png.

  2. For each variable you want to include in your dashboard as a potential predictor, repeat the following step: click "Create new" to create a variable coupled to the state of the button that you will create for this predictor, and give the new variable a relevant name (ex.g. 'ambient_temperature_tog'). Set its value to 0 (not included) or 1 (included) in the Definition field.

    Once such a variable is set up for each of the potential predictors, continue to the next steps. For each potential predictor, repeat the steps below.

    Hint: you can copy and paste the first button and update each instance of <relevant variable>, as well as the <predictor name>, instead of creating a new button from scratch.

  3. Drag a Button to the worksheet and open the Actions and navigation tab in the menu on the right.

  4. Click "Add action" and give the action a Label, ex.g. Toggle.

  5. Select the Action "Set variable value".

  6. In the Variable field that appears below, add the relevant newly created variable you want to link to this button. The text in the expression editor could look like this: ='ambient_temperature_tog'. Note: make sure to include the quotation marks.

  7. In the Value field below, add the =Not( ) expression with the variable as argument (ex.g. =Not(ambient_temperature_tog)).

  8. Open the Appearance tab in the menu on the right.

  9. In the General section, set the Label to ='<Predictor name> ' & If(<relevant variable>, CHR(9745), CHR(9746)), where

    • <Predictor name> should be replaced by the name of the relevant potential predictor (ex.g. "Ambient temperature"),
    • <relevant variable> should be replacced by the relevant newly created variable (ex.g. "ambient_temperature_tog"), and
    • CHR(9745) and CHR(9746) refer to checkbox symbols.
  10. In the Background section, set the Background color to "By expression" and set the Expression to =If(<relevant variable>,'#1D0C5F','#C0BBD3'), where

    • <relevant variable> should be replaced by the relevant newly created variable (ex.g. "ambient_temperature_tog"), and
    • the HEX codes can be adjusted to match the desired look of your dashboard. They represent the color of the button when the toggle is set to selected and deselected, respectively.

    When you've created buttons for each of the potential predictors you want to include in the dashboard, you can proceed to the next steps.

  11. Click the Variables button at the bottom left of your screen image.png.

  12. Click "Create new" and create a new variable called "build_from".

  13. From the Qlik Dashboard bundle, drag a Variable input to the worksheet. Give it the title "Build from". When using the dashboard, this field should contain the timestamp desired to correspond to the date of the first observation of the sample to train and detect on in the YYYY-MM-DD hh:mm:ss format.

  14. In the Appearance tab in the menu on the right, open the Variable section. In the Name selection panel, select the newly created "build_from" variable.

  15. Click the Variables button at the bottom left of your screen image.png.

  16. Click "Create new" and create a new variable called "build_until".

  17. From the Qlik Dashboard bundle, drag a Variable input to the worksheet. Give it the title "Build until". When using the dashboard, this field should contain the timestamp desired to correspond to the date of the last observation of the sample to train and detect on in the YYYY-MM-DD hh:mm:ss format.

  18. In the Appearance tab in the menu on the right, open the Variable section. In the Name selection panel, select the newly created "build_until" variable.

  19. Click the Variables button at the bottom left of your screen image.png.

  20. Click the Variables button at the bottom left of your screen image.png.

    *The next few steps should only be executed if you wish to include the SSE's out-of-sample anomaly detection capabilities in your app.

  21. Click "Create new" and create a new variable called "detect_from".

  22. From the Qlik Dashboard bundle, drag a Variable input to the worksheet. Give it the title "Build until". When using the dashboard, this field should contain the timestamp desired to correspond to the date of the first observation of the sample to apply the previously built model on in the YYYY-MM-DD hh:mm:ss format.

  23. In the Appearance tab in the menu on the right, open the Variable section. In the Name selection panel, select the newly created "detect_from" variable.

  24. Click the Variables button at the bottom left of your screen image.png.

  25. Click "Create new" and create a new variable called "detect_until".

  26. From the Qlik Dashboard bundle, drag a Variable input to the worksheet. Give it the title "Build until". When using the dashboard, this field should contain the timestamp desired to correspond to the date of the last observation of the sample apply the previously built model on in the YYYY-MM-DD hh:mm:ss format.

  27. In the Appearance tab in the menu on the right, open the Variable section. In the Name selection panel, select the newly created "detect_until" variable.

    *Continue from this point if you do not wish to include the SSE's out-of-sample anomaly detection capabilities in your app.

  28. Click "Create new" and create a new variable called "sensitivity".

  29. From the Qlik Dashboard bundle, drag a Variable input to the worksheet. Give it the title "Sensitivity". When using the dashboard, this field should contain the desired sensitivity for the anomaly detection model. This is an optional parameter; if it is left empty, automatic sensitivity estimation is applied.

  30. In the Appearance tab in the menu on the right, open the Variable section. In the Name selection panel, select the newly created "sensitivity" variable.

  31. Click the Variables button at the bottom left of your screen image.png.

  32. Click "Create new" and create a new variable called "model_activation".

  33. Drag a Button to the worksheet and open the Actions and navigation tab in the menu on the right.

  34. Click "Add action" and give the action a Label, ex.g. Toggle.

  35. Select the Action "Set variable value".

  36. In the Variable field that appears below, add the newly created "model_activation" variable to link it to this button. The text in the expression editor should look like this: ='model_activation'. Note: make sure to include the quotation marks.

  37. In the Value field below, insert =Not(model_activation).

  38. Open the Appearance tab in the menu on the right.

  39. In the General section, set the Label to =If(model_activation, 'Deactivate model ', 'Activate model ') & If(model_activation, CHR(9745), CHR(9746)), where CHR(9745) and CHR(9746) refer to checkbox symbols.

  40. In the Background section, set the Background color to "By expression" and set the Expression to =if(model_activation,'#1D0C5F','#C0BBD3'), where the HEX codes can be adjusted to match the desired look of your dashboard. They represent the color of the button when the toggle is set to selected and deselected, respectively.

Now, the user controls for setting the anomaly detection configuration are set up. The next part makes sure they can be correctly interpreted by the functions.

Creating the function parameter variables

  1. Click the Variables button at the bottom left of your screen image.png.

For each variable you have included in your dashboard as a potential predictor, repeat the following steps:

  1. Click "Create new" to create a variable that will optionally contain this predictor, and give the new variable a relevant name (ex.g. "ambient_temperature_var").

  2. Set the variable's value in the Definition field to the following expression: If(<relevant variable toggle>, '|' & Sum(<relevant variable>), ''), where

    • <relevant variable toggle> should be replaced by the variable coupled to the relevant predictor's button (ex.g. "ambient_temperature_tog"), and
    • <relevant variable> should be replaced by the variable containing the relevant predictor (ex.g. "[Ambient temperature]").
  3. Click "Create new" to create a variable that will contain the list of predictor names and optionally their availabilities, and give the new variable the name "variable_names".

  4. This variable will need to contain some conditional elements, to make sure only the names of those predictors that are selected through the buttons are included. Set the variable's value in the Definition field to the following expression:

    ='<timestamps>,<target variable>' & If(<relevant variable toggle>, ',<relevant variable name and optionally its availability>', '')<potential additional conditional statements>, where

    • <timestamps> is replaced by the name of the variable containing the timestamps,
    • <target variable> is replaced by the name of the variable containing the target,
    • <relevant variable toggle> is replaced by the relevant variable toggle (ex.g. "temperature_tog"),
    • <relevant variable name and optionally its availability> is replaced by the name of the variable the toggle corresponds to (ex.g. "ambient_temperature"), optionally followed by the corresponding availability, and
    • <potential additional conditional statements> is replaced by any other variables to potentially include, in the same conditional format as the example preceeding this argument. Different conditional statements should be separated by &.

    In case the default availability is used (all variables are available until the end of the target variable, i.e. the last timestamp before the start of the forecasting horizon), the expression should now look similar to this:

    ='Timestamp,temp_gearbox' & If(ambient_temperature_tog, ',ambient_temperature', '') & If(rotor_speed_tog, ',rotor_speed', '') & If(temp_shaft_bearing_tog, ',temp_shaft_bearing', '').

    In case the availabilities are also set, the expression should now look similar to this:

    ='Timestamp,temp_gearbox' & If(ambient_temperature_tog, ',ambient_temperature -5', '') & If(rotor_speed_tog, ',rotor_speed -1', '') & If(temp_shaft_bearing_tog, ',temp_shaft_bearing', '').

    In this example, the ambient temperature is available up until 5 samples before the last in-sample observation of the target variable (the temperature of the gearbox). The rotor speed is available up until 1 sample before the the last in-sample observation of the target variable (the temperature of the gearbox). The availability of the variable called temp_shaft_bearing is not specified, thus the default availability is used: it is available up until the end of the in-sample period.

    Now, the variables to use as parameters in the SSE's functions are ready for use. The next part will take you through setting up these function calls correctly (i.e. so they listen to the UI elements you set up).

  5. Click "Create new" to create a variable that will contain the list of anomaly detection features to be included in the model configuration, and give the new variable the name "detection_features".

  6. This is an optional parameter; if an empty string is passed, the default configuration ('Residuals, Imbalance') is used. The options are 'Residual', 'ResidualChange', 'Fluctuation', 'FluctuationChange', Imbalance, 'ImbalanceChange', or an arbitrary combination of them, separated by commas. Set the desired configuration in the Definition field as a string, the expression should now look similar to this:

    ='Residual, ResidualChange, Fluctuation, FluctuationChange, Imbalance, ImbalanceChange'.

  7. Click "Create new" to create a variable that will contain an identifying key for the anomaly detection model. This key serves as the link between the model that is built following the in-sample request and any out-of-sample detection that should be done with the same model. This is an optional parameter; if you do not wish to use the model for out-of-sample detection, an empty string can be passed. Give the new variable the name "key".

  8. Set its value to ='key', or any other identifying string you would like to use, in the Definition field.

Adding the predictors to the dashboard

  1. Drag a Line chart to the worksheet. Select the variable containing the timestamp as dimension and any variable containing the additional predictors as measures. The aggregation level of the measures (predictor variable) should be Sum( ).

Using the variables in the function calls

Retrieving the in-sample normal behavior
  1. In the first line chart that was added to your worksheet, select Add to add a new measure to the line chart and set the Label to "Forecast".

  2. Click on the function button image.png to open the Expression editor.

  3. To call the SSE's forecasting function, you first need to make it clear to Qlik that you're communicating to the SSE. You do so by typing in the name you have given the SSE in your environment, ex.g. "TIMSSE". Then, you call the desired function - "AD_Detect" - on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_Detect().

  4. Now, add all the parameters this function expects. For more information on these parameters, go to the section of the documentation on the functions of the TIM SSE. Parameters should be separated by commas.

    • The first parameter is a string containing all variables to be included. Start by referencing the variable containing the timestamp. Then add & '|' & to separate it from the target and reference the variable containing the target. This variable should be called with the aggregation level Sum( ). After this, add & followed by all other variables you want to include as potential predictors, i.e. those created in the previous section. You can refer to these variables like this: $(<variable name>), where <variable name> is replaced by the name of the relevant variable.
    • The second parameter is the start date of the forecast, which should be linked to the Variable input of the element titled "Forecast start". The relevant variable that should be included here is forecast_start.
    • The third parameter is the number of samples to forecast, which should be linked to the Variable input of the element titled "Forecast length". The relevant variable that should be included here is forecast_length.
    • The fourth parameter is the boolean indicating if a new model should be built or not. The relevant variable that should be included here is model_activation.
    • The fifth parameter is a list of the names (and optionally availabilities) of all included variables, including the timestamp and the target variable. The relevant variable that should be included here is variable_names.
    • The sixth parameter indicates what you want the function to return, in this case the normal behavior.
    • The seventh parameter is an identifying key for the model that will be built. This key serves as the link between the model that is built in this request and any out-of-sample detection that should be done with the same model. This is an optional parameter; if you do not wish to use the model for out-of-sample detection, an empty string can be passed.
    • The eighth parameter is the desired sensitivity of the anomaly detection model. This is an optional parameter; if it is left empty, automatic sensitivity estimation is applied.
    • The ninth parameter is a list of the anomaly detection features to include in the model configuration. This is an optional parameter; if an empty string is passed, the default configuration ('Residuals, Imbalance') is used.

    The text in your editor should now look similar to this:

    =TIMSSE.AD_Detect(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'normal_behavior', 'key', sensitivity, detection_features).

  5. Click "Apply", and the line chart is set up to be updated correctly with any changes to the dashboard. To retrieve the in-sample normal behavior, the "build_from" and "build_until" Variable inputs should contain actual values, ex.g. 2018-01-01 and 2018-10-01 respectively.

  6. Set the Label to Normal behavior.

Indicating the anomalies on the historical (in-sample) target values

  1. Select Add to add a new measure to the line chart and click on the function button image.png to open the Expression editor.

  2. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_Detect" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_Detect().

  3. Add the same parameters as you did when retrieving the normal behavior, but replace 'normal_behavior' with 'anomalies'. The text in your editor should now look similar to this:

    =TIMSSE.AD_Detect(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'anomalies', 'key', sensitivity, detection_features).

  4. Click "Apply", and the line chart will be updated with the anomaly indicator as soon as it's calculated.

  5. Set the Label to Anomalies.

Retrieving out-of-sample normal behavior*

  1. Select Add to add a new measure to the line chart and click on the function button image.png to open the Expression editor.

  2. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_DetectOutSample" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_DetectOutSample().

  3. Now, add all the parameters this function expects. For more information on these parameters, go to the section of the documentation on the functions of the TIM SSE. Parameters should be separated by commas.

  4. The first parameter is a string containing all variables to be included. Start by referencing the variable containing the timestamp. Then add & '|' & to separate it from the target and reference the variable containing the target. Again, this variable should be called with the aggregation level Sum( ). After this, you can add all other variables you want to include as predictors, separated by & '|' & and with the aggregation level Sum( ).

    • The second parameter is the start timestamp of the out-of-sample period, in the YYYY-MM-DD hh:mm:ss format.
    • The third parameter is the end timestamp of the out-of-sample period, also in the YYYY-MM-DD hh:mm:ss format.
    • The fourth parameter is a boolean indicating if a new request should be made or not. Setting this to "1" allows to make changes to the input parameters, without triggering a new anomaly detection model to be built on these new inputs.
    • The fifth parameter is a list of the names (and optionally availabilities) of all included variables, including the timestamp and the target variable. The variable names should be separated by commas. If no availabilities are set, the default data availability will be assumed: all variables are available until the end of the target variable, i.e. the last timestamp of the in-sample period, indicated in the third parameter.
    • The sixth parameter indicates what you want the function to return, in this case the normal behavior.
    • The seventh parameter is an identifying key for the model that should be applied. This key serves as the link between the model that is built in an in-sample request and and any out-of-sample detection (such as the one linked to this request) that should be done with the same model.

    The text in your editor should now look similar to this: =TIMSSE.AD_DetectOutSample(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), detect_from, detect_until, model_activation, variable_names, 'normal_behavior', 'key').

  5. Click "Apply", and the line chart is set up to be updated correctly with any changes to the dashboard. To retrieve the out-of-sample normal behavior, the "detect_from" and "detect_until" Variable inputs should contain actual values, ex.g. 2018-12-01 and 2019-01-01 respectively.

  6. Set the Label to Out-of-sample normal behavior.

Indicating the anomalies on the out-of-sample target values*

  1. Select Add to add a new measure to the line chart and click on the function button image.png to open the Expression editor.

  2. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_DetectOutSample" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_DetectOutSample().

  3. Add the same parameters as you did when retrieving the out-of-sample normal behavior, but replace 'normal_behavior' with 'anomalies'. The text in your editor should now look similar to this: =TIMSSE.AD_DetectOutSample(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), detect_from, detect_until, model_activation, variable_names, 'anomalies', 'key').

  4. Click "Apply", and the line chart will be updated with the out-of-sample anomalies as soon as they're calculated.

  5. Set the Label to Out-of-sample anomalies.

Retrieving the in-sample residuals

  1. Drag a Line chart to the worksheet. Select the variable containing the timestamp as dimension.

  2. Select Add measure to add a measure to the line chart and click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_Detect" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_Detect().

  4. Add the same parameters as you did when retrieving the anomalies, but replace 'anomalies' with 'residuals'. The text in your editor should now look similar to this:

    =TIMSSE.AD_Detect(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'residuals', 'key', sensitivity, detection_features).

  5. Click "Apply", and the line chart will be updated with the anomaly indicator as soon as it's calculated.

  6. Set the Label to Residuals.

Retrieving out-of-sample residuals*

  1. Drag a Line chart to the worksheet and select the variable containing the timestamp as dimension.

  2. Select Add measure to add a measure to the line chart and click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_DetectOutSample" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_DetectOutSample().

  4. Add the same parameters as you did when retrieving the out-of-sample anomalies, but replace 'anomalies' with 'residuals'. The text in your editor should now look similar to this: =TIMSSE.AD_DetectOutSample(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), detect_from, detect_until, model_activation, variable_names, 'residuals', 'key').

  5. Click "Apply", and the line chart will be updated with the out-of-sample residuals as soon as they're calculated.

  6. Set the Label to Out-of-sample residuals.

Retrieving the in-sample anomaly indicator
  1. Drag a Line chart to the worksheet. Select the variable containing the timestamp as dimension.

  2. Select Add measure to add a measure to the line chart and click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_Detect" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_Detect().

  4. Add the same parameters as you did when retrieving the residuals, but replace 'residuals' with 'anomaly_indicator'. The text in your editor should now look similar to this:

    =TIMSSE.AD_Detect(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'anomaly_indicator', 'key', sensitivity, detection_features).

  5. Click "Apply", and the line chart will be updated with the anomaly indicator as soon as it's calculated.

  6. Set the Label to Anomaly indicator.

  7. Open the Add-ons tab in the menu on the right.

  8. In the Reference lines section, click "Add reference line" and in the Reference line expression field, insert 1. Change the HEX code to #8e477d, or adjust it to match the desired look of your dashboard. This will add a threshold to the line chart, making it easier to distinguish anomalous observations.

Retrieving the out-of-sample anomaly indicator*

  1. Select Add measure to add a measure to the line chart and click on the function button image.png to open the Expression editor.

  2. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_DetectOutSample" function on the SSE again. The text in your editor should now look similar to this: TIMSSE.AD_DetectOutSample().

  3. Add the same parameters as you did when retrieving the out-of-sample residuals, but replace 'residuals' with 'anomaly_indicator'. The text in your editor should now look similar to this: =TIMSSE.AD_DetectOutSample(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), detect_from, detect_until, model_activation, variable_names, 'anomaly_indicator', 'key').

  4. Click "Apply", and the line chart will be updated with the out-of-sample anomaly indicator as soon as it's calculated.

  5. Set the Label to Out-of-sample anomaly indicator.

Retrieving predictor importances
  1. Drag a Table to the worksheet and select the variable containing the timestamp as dimension. Set the Label to =' ' and the Text color expression to white(). This will create a table with the desired structure, without negatively impacting the table's look.

  2. Click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_PredictorImportances" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_PredictorImportances().

  4. Add the same parameters as you did in the "AD_Detect" function. Add an additional parameter with the value 'predictor_name'. This indicates that you want to retrieve the names of the predictors that were used in the forecasting model. The text in your editor should now look similar to this:

    =TIMSSE.AD_PredictorImportances(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'predictor_name', 'key', sensitivity, detection_features).

  5. Click "Apply", and the table will be updated with the predictor names as soon as they're returned.

  6. Set the Label to Predictor name.

  7. Again, click "Add column" and select measure, then click on the function button (image.png ) to open the Expression editor.

  8. Add the exact same function call, this time replacing 'predictor_name' with 'importance'. This indicates that you cant to retrieve each predictor's importance. The text in your editor should look similar to this:

    =TIMSSE.AD_PredictorImportances(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'importance', 'key', sensitivity, detection_features).

  9. Click "Apply", and the table will be updated with the predictor importances as soon as they're returned.

  10. Set the Label to Importance.

Retrieving feature importances
  1. Drag another Table to the worksheet and select the variable containing the timestamp as dimension. Set the Label to =' ' and the Text color expression to white(). This will again create a table with the desired structure, without negatively impacting the table's look.

  2. Click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  3. Again, type in the name you have given the SSE in your environment (ex.g. "TIMSSE"). Then, call the "AD_FeatureImportances" function on this SSE. The text in your editor should now look similar to this: TIMSSE.AD_FeatureImportances().

  4. Add the same parameters as you did in the "AD_FeatureImportances" function. Add an additional parameter with the value 'time'. This indicates that you want to retrieve the times to which each of the feature's importances apply. The text in your editor should now look similar to this:

    =TIMSSE.AD_FeatureImportances(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'time', 'key', sensitivity, detection_features).

  5. Click "Apply", and the table will be updated with the times as soon as they're returned.

  6. Set the Label to Time.

  7. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  8. Add the exact same function call, this time replacing 'time' with 'term_name'. This indicates that you want to retrieve the names of the features that were used in the forecasting model. The text in your editor should look similar to this:

    =TIMSSE.AD_FeatureImportances(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'term_name', 'key', sensitivity, detection_features).

  9. Click "Apply", and the table will be updated with the feature names as soon as they're returned.

  10. Set the Label to Feature name.

  11. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  12. Add the exact same function call, this time replacing 'term_name' with 'type'. This indicates that you cant to retrieve each feature's type. The text in your editor should look similar to this:

    =TIMSSE.AD_FeatureImportances(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'type', 'key', sensitivity, detection_features).

  13. Click "Apply", and the table will be updated with the feature types as soon as they're returned.

  14. Set the Label to Type.

  15. Again, click "Add column" and select measure, then click on the function button image.png to open the Expression editor.

  16. Add the exact same function call, this time replacing 'type' with 'importance'. This indicates that you cant to retrieve each feature's importance. The text in your editor should look similar to this:

    =TIMSSE.AD_FeatureImportances(Timestamp & '|' & Sum([Temp. gearbox]) & $(ambient_temperature_var) & $(rotor_speed_var) & $(temp_shaft_bearing_var), build_from, build_until, model_activation, variable_names, 'importance', 'key', sensitivity, detection_features).

  17. Click "Apply", and the table will be updated with the feature importances as soon as they're returned.

  18. Set the Label to Importance.

Now, your dashboard is ready for use! Of course, you can still add titles to the different elements and organize them as you want.