With SAP PA 1.0.11, it is possible to export created predictive model as HANA Stored procedure. This makes the created predictive models consumable from applications on HANA without having to go to PA to “score” the model. This article explains how you can do that.

1. Acquire the data using PA & train a predictive model using an algorithm. I am using below HANA C4.5 on the results of HANA K-Means.

Blog_1.PNG

2. Now, right click on the HANA C 4.5 (or any component in your analysis which generates the model and chose “Save the Model” option.

blog_2.PNG

3. Now, go to “Saved Models” tab and right click on model that was saved in Step 2 and select “SAP HANA Stored Procedure” option.

blog_3.PNGblog_4.PNG

4. Provide the schema in which the model needs to be stored and also name of the procedure & click on Finish to export the model.

P.S: Don’t have spaces or special characters in the name of the procedure

blog_5.PNG

6. Now login to HANA Studio and see the model in the Catalog->Procedures section in the Modeler perspective.

blog_6.PNG
7. Open the procedure by double clicking it and see the parameters.

blog_7.PNG

8. See the SQL statements that made the procedure and closely observe the sections which are commented. PA provides the statements to manage lifecycle management of the procedure. If you take the commented portion of the statements and run it in the Studio, you would be able to drop all the objects related to the procedure.

blog_8.PNG

9. Now, let us see how you can invoke this procedure from an application (in this case Studio) to score the model on a new set of data.

10. Open a SQL console and create a new table to hold the results.

blog_9.PNG

11. Now, call the procedure to score the model on the table “NewStores” which contains unseen data.

blog_10.PNG

12.  View the newly created table contents in the studio using the preview option.

blog_11.PNG

13. This way, you can score the PA created PAL model from any application.

For the detailed list of new features in PA 1.0.11, refer to the blog here: http://scn.sap.com/community/predictive-analysis/blog/2013/06/07/sap-predictive-analysis-10-sp11-new-features-at-a-glance

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Kevin Coy

    This is a nice write up. I would like to see an easier way to compare the results of what PA produces for a model against the results of calling the stored procedure against the same data. Using the Multiple Linear Regression model for instance produces an output table that can’t be easily, in my opinion, mapped back to the rows of the data used to produce the predicted values. PA surprisingly does not allow you to sort result tables based on columns or via filters, so it is hard to tell what the correct query is to fill a temporary table to pass into the exported stored procedure.

    Also, another question. Doing various tasks in Predictive Analysis, such as visualizing results produces all sorts of views, tables, etc. Is there an easy way to clean up after PA?

    (0) 

Leave a Reply