Skip to Content
Author's profile photo HARIKRISHNAN S

Predictive analytics using SAP Design Studio and SAP HANA – Part 2

Thanks to Radha D for her contributions in building the model.

In part 1, we discussed the 101 of predictive analytics in SAP HANA using SAP HANA PAL and HANA flowgraph modelling. The drag and drop interface allows us to focus on the analysis without spending too much time writing out complex SQL scripts.

In this blog, we will understand how we can integrate flowgraphs with SAP Design Studio and provide a readily consumable output to the decision makers.

Extending our example from the previous blog, we would like to select different store and product combinations, to be able to view the sales forecast at a granular level. This kind of analysis will help in inventory planning, promotional offers for low selling products and so on. We would also like to choose the number of periods of forecast as well as be able to modify the forecast parameters to ensure a good fit.

Image-1: Visualizing SAP HANA Flowgraph output using SAP Design Studio

Part2-Image1Visualizing SAP HANA Flowgraph output using SAP Design Studio.png

Above is a sample application built using SAP Design Studio to present our case, with text inputs, dropdowns and radio buttons to pass the parameters. This application must be able to interact with the predictive algorithms running on HANA and pass the various parameters to the Prediction model.

Solution -1

A simple approach to do this would be to include a filter node in the flow graph created in part 1 and iterate the steps over all store and product combinations. We can then write the results back to a table and consume it in Design Studio using a Calculation View. This approach can be tedious and also has to be scheduled to run during downtime hours. Also, this would apply the same model parameters to all the store and product combinations which may not yield the best of results.

Image-2: Using filter node to select a particular store and product

Part2Image2Using filter node to select a particular store and product.PNG

Solution2- Doing things on the fly

To visualize something in SAP Design Studio, it should be a column view (from SAP HANA perspective). From our sample application shown above, it is clear that we would need to pass the various parameters as variable values to this column view. The drawbacks of solution1 tells us that this column view cannot be built on just tables as we would like to run the prediction algorithm and the flow graph procedure each time there is a change in the parameters in the front-end. To achieve this, we create a scripted calculation view in HANA and call the flow graph procedure within it. The problem does not end there. Each time there is change to the parameters, the meta-data table, where model parameters are stored, needs to be updated. Then again, write operations are not permitted within scripted views. To work around this, we tweak the flow graph procedure to replace corresponding parameter values at runtime using a simple case statement within the select statement which picks up values from the parameter table.

Image-3: Modified Select statement on the model parameter table

Part2-Image3Modified Select statement on the model parameter table.PNG

Image-4: Actual Select statement on the model parameter table

Part2Image4Actual Select statement on the model parameter table.PNG

Lastly, to change the dimension members (Store and Product) dynamically, we create a custom procedure with two scalar input parameters for Store and Product respectively and replace the  static filter during the pre-process of data in the flowgraph.

Image-5: Modified Dynamic Dimension Filter

Part2-Image5Modified Dynamic Dimension Filter.png

Image-6: Flowgraph – Design Studio integration workflow

Part2-Image6Flowgraph - Design Studio integration workflow.PNG

Finally, this column view is consumable in SAP Design Studio and we can select model parameters as well as dimension parameters on the fly and visualize the predictions accordingly.

This approach can be further extended to other complex predictive algorithms such as classification, regression and decision trees with great visualizations using SAP Design Studio. This can also be extended to other visualization and data discovery tools like SAP Lumira and WebI enabling decision makers with the power of predictive analytics.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Fahad Ajaib
      Fahad Ajaib

      Hi Guys

      How are you providing the Filter value Store and Product from Design Studio to Flowgraph? I have the same scenario where I am using a calculation view as a data source in Design studio and calling Flowgraph inside this calculation view. I am providing filter values from Design studio to Calculation view and these filter values I need to provide to flowgraph. But the problem is that If I create a flowgraph with parameter (Task) then I can't call this flowgraph in Calculation view and if I create the flowgraph without parameter then I cannot provide filter value to flowgraph so I am not sure what to do in this scenario. Can you please help me in this regard.

      Thanks and best regards.


      Author's profile photo HARIKRISHNAN S
      Blog Post Author

      Hi Fahad,

      Sorry for the late response.

      As you see, we are not directly consuming or calling the Flowgraph inside the Calculation view. Instead we are creating a wrapper kind of procedure, inside that procedure do the filtering stuffs, now consume this wrapper procedure inside the calculation view. which solves the purpose.

      Let me know, if you need further clarifications.

      Thanks and Regards,