Download using SAP Predictive Analysis

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Nonlinear dimensionality reduction wikipedia , lookup

Transcript
Embedding SAP Predictive into BI Tools
Embedding SAP Predictive into SAP BI tools.
“Using SAP data mining tools SAP Predictive Analysis & SAP InfiniteInsight to create trained
predictive models and building applications such as SAP BusinessObjects Dashboards &
Design Studio on the predictive models stored in SAP HANA”
This article applies to those who are interested in building
SAP BI Client Dashboards or Reports with real-time
Predictive capabilities.
SAP COMMUNITY NETWORK
© 2013 SAP AG
Final
1
Embedding SAP Predictive into BI Tools
Summary:
This paper provides a step-by-step description how to embed SAP Predictive into SAP BI Tools.
In detail how to SAP Predictive Analysis can be used to build predictive models and then use the
trained models in SAP BI Clients such as BusinessObjects Dashboard Designer, Web Intelligence or
Design Studio. SAP HANA is the acting platform between SAP Predictive Analysis and the SAP BI
Clients which can then facilitate real-time in-memory processing of predictive models and directly
return the results to the SAP BI Client. Using this approach will allow many more users access to
advanced analytics in an easy to use and visual appealing Dashboard without the need for
sophisticated statistics or programming skills. This article covers how to build a predictive model or
machine learning model using SAP Predictive Analysis and then exporting the model to HANA.
Hereafter HANA is used to facilitate requests from SAP BI Clients such as Dashboard Designer.
After reading this article you will be able to understand how to collaborate between data mining tools
and reporting tools facilitated by SAP HANA. Including how to write-back to SAP HANA tables
and call procedures from SAP BusinessObjects BI Clients and get the results from procedures
back to the BI Client.
Specifically you will see how to build simple trained predictive models using SAP Predictive Analysis
and how to write back to HANA and consume the results from running algorithms inside HANA in
SAP Dashboard Designer. The process is very similar if you would be using Design Studio, Web
Intelligence or SAP InfiniteInsight.
Software:
Frontend-data mining tools: SAP Predictive Analysis SP16 & SAP InfiniteInsight (former KXEN).
Frontend-reporting-tools: SAP BusinessObjects Dashboard Designer, Web Intelligence & SAP
Design Studio.
Backend-tools: SAP HANA & PAL (Predictive Analysis Library).
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2
Embedding SAP Predictive into BI Tools
1
Authors Bio
Kurt Holst ([email protected]) is an experienced Principal Consultant on Predictive Analytics, HANA &
BusinessObjects Enterprise architecture, configuration and performance optimization. Kurt has worked
with most major BI reporting & data mining tools together with different OLAP databases, SAP
NetWeaver BW and relational databases. Before joining SAP, Kurt worked as a BI Architect & developer
both internal and as an external consultant. Furthermore, Kurt has been attached to the Southern
university of Denmark as an external lecturer on Business Intelligence, Data Warehousing & Data Mining.
Kurt helps customers transform data into knowledge using predictive analysis or business intelligence
and is organizational within the Business Analytics Services team at SAP Denmark.
Adem Baykal ([email protected]) is an experienced Principal Consultant for SAP HANA & SAP
Business Intelligence at SAP. He has deep knowledge in the implementation of BI solutions on SAP BW
and SAP HANA as well as on other data sources. Within SAP he is an active Knowledge Champion in the
SAP HANA Implementation Community and he is currently active as Stream Lead for BusinessObjects BI
in the MEE Service Community Analytics at SAP. Adem was involved in many strategic SAP HANA and
SAP BI activities inside and outside SAP. He is a well-accepted Strategy Ambassador within SAP and on
customer side he has successfully implemented SAP HANA and SAP BI as Project Lead or Strategic
Architect. He is very experienced with deploying best practice BI solutions on Business Suite powered by
SAP HANA and NetWeaver BW powered by SAP HANA.
Company:
SAP
Last update:
March, 25th 2014
Disclaimer:
Please note that information and views set out in this article are those of the authors and do not
necessarily reflect the official roadmap, opinion or strategy of the SAP. Neither SAP nor any person
acting on their behalf may be held responsible for the use which may be made of the information
contained therein.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
3
Embedding SAP Predictive into BI Tools
Contents
1
Authors Bio ............................................................................................................................................ 3
2
Document update history ...................................................................................................................... 5
3
Executive summary ............................................................................................................................... 6
How could you benefit from the methodology that this article describes? ......................................................... 6
4
Background ........................................................................................................................................... 6
5
Definitions and expected foundations for the reader ............................................................................ 7
5.1
Terms and definitions ............................................................................................................................ 7
5.1.1
Data Mining .................................................................................................................................................. 7
5.1.2
Decision tree ................................................................................................................................................ 7
5.1.3
Confusion matrix ......................................................................................................................................... 7
5.1.4
SAP HANA XSJS .......................................................................................................................................... 7
5.1.5
SAP HANA Repository ................................................................................................................................ 7
5.1.6
SAP Predictive Analysis ............................................................................................................................. 8
5.1.7
SAP InfiniteInsight (formerly known as KXEN InfiniteInsight) ................................................................ 8
6
Technical requirements ......................................................................................................................... 9
7
Building trained predictive model. ......................................................................................................... 9
7.1
Building trained predictive model – business examples. ...................................................................... 9
7.1
Building trained predictive model – using SAP Predictive Analysis. ................................................... 10
7.2
Illustrating the generated predictive model – using SAP Predictive Analysis. .................................... 13
7.3
Scoring the trained predictive model on test or validation data. ......................................................... 14
7.4
Building trained predictive model – simple example. .......................................................................... 15
7.5
Saving the trained model as a new model in SAP PA: ....................................................................... 18
7.6
The procedure is now saved back to SAP HANA: .............................................................................. 20
8
Dashboard solution ............................................................................................................................. 23
8.1
Dashboard solution – business examples. ......................................................................................... 23
8.2
Dashboard solution – simple example. ............................................................................................... 24
9
Technical setup ................................................................................................................................... 25
10
Conclusion .......................................................................................................................................... 39
11
Perspective ......................................................................................................................................... 39
12
Appendix – HANA Script-code. ........................................................................................................... 40
13
Appendix – HANA Predictive Analysis Library script-code. ................................................................ 41
14
Reference Documentation .................................................................................................................. 44
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
4
Embedding SAP Predictive into BI Tools
2
Document update history
Date
Name
Alteration Reason
05.03.2014
Kurt Holst & Adem Baykal
Initial document
0.1
Kurt Holst & Adem Baykal
Describing solution
0.2
17.03.2014
Kurt Holst & Adem Baykal
First draft for internal peer review
0.3
20.03.2014
Kurt Holst & Adem Baykal
Incoorporating feedback from peers
0.5
25.03.2014
Kurt Holst & Adem Baykal
Publish to SCN
1.0
SAP COMMUNITY NETWORK
© 2014 SAP AG
Version
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
5
Embedding SAP Predictive into BI Tools
3
Executive summary
The purpose of this article is to demonstrate how embed predictive models in SAP BI Clients.
Currently there are two data mining tools, SAP Predictive Analysis and SAP InfiniteInsight (former
known as KXEN InfiniteInsight), which both could be used in collaboration with the SAP
BusinessObjects reporting tools or Design Studio. As described in SAP roadmap the two data mining
tools are being merged into one combined tool. (Reference: [2014, SAP Predictive Roadmap])
This article takes the reader through an end-to-end scenario using SAP Predictive Analysis, (it
applies also to SAP InfiniteInsight) to build a predictive trained model and consume the model in
reporting tools. Moreover how to write-back to HANA and run algorithms and get the results back to
the BI reporting tools
How could you benefit from the methodology that this article describes?




Learn how to embed advanced analytics or machine trained models in dashboards.
Allow many more business users access to leverage otherwise complicated advanced
analytics in a simple to use and highly intuitive visual appealing Dashboard.
Write-back to HANA could be used in many other use cases (e.g. commenting solutions) to
utilize HANA even further in combination with custom build Dashboard or BI solutions.
Execute HANA Scripts or stored procedures from a Dashboard and retrieve the results directly
on the Dashboard.
This article presents one example of how SAP Predictive Analysis with just one algorithm can
enhance an existing performance management solution together with HANA; however it could have
many other use cases. The authors’ intention is to provide the knowledge to do this you without
overcomplicating the use case.
4
Background
This article is only for educational purposes. Data mining tools such as SAP Predictive Analysis and
SAP InfiniteInsight can export the developed models. These models, or mathematical algorithms, can
then be re-used in reporting tools such as Web Intelligence, Design Studio or Dashboard Designer.
The authors of this article have closely observed the Predictive Analysis & HANA communities online
where members are constantly looking for two important things;
1. How to write back from BI tools to SAP HANA
2. How BI tools can use predictive models created with SAP Predictive Analysis or SAP
InfiniteInsight
Creating an application such as a Dashboard that utilizes a trained predictive model could extend the
usage of complex algorithms to a much broader audience than just data scientists. Using a
Dashboard approach hides the complexity for the end user and as shown in this article can actually
further increase the overall business value of an existing BusinessObjects and HANA solution.
As state by Gartner the field of Advanced Analytics will require a lot of talents and just looking at the
sheer numbers this could be a big challenge: “Gartner predicts need for 1.9 million new data
scientists and creation of 6 million new big data jobs by 2015, and Dice.com identifies specific areas
of need” [Gartner, 2013]. One of the means to mitigate the lack of talents could be reached using the
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
6
Embedding SAP Predictive into BI Tools
approach described in this article where we are taking all the complexity away from the end users but
still allowing mass-consumption of advanced analytics including machine trained algorithms.
5
Definitions and expected foundations for the reader
This article provides a step-by-step description, including screenshots, to evaluate how SAP
Predictive Analysis can be used to predict the potential customers who will buy additional products
based on their behavior of interest.
5.1 Terms and definitions
Throughout this article different terms and definitions have been used and, to provide you with a
common understanding of these, a short description is given below.
5.1.1
Data Mining
This is a process of analyzing and summarizing data in order to discover patterns, trends and identify
relationships. Data mining uses mathematical algorithms and different techniques such as artificial
intelligence, neural network and statistical tools to segment data.
5.1.2
Decision tree
A decision tree is an analysis diagram which is used as a support tool that helps decision makers in
deciding between options and outcomes. A decision tree consists of nodes and branches and is used
in various contexts such as graph theory, algorithms and probability.
5.1.3
Confusion matrix
A confusion matrix is used for classifying results into actual and predicted information. Usually this
matrix contains two rows and two columns with the following four outcomes: false positives, false
negatives, true positives, and true negatives.
5.1.4
SAP HANA XSJS
As an application developer, you use a variety of languages to develop an application that exposes a
SAP HANA data model to requests from UI clients. In an application-development scenario,
developers typically use languages such as server-side JavaScript (XSJS) or an OData service to
define the application business model that exposes the data model built by the database developer.
You can call the application service from a client interface, for example, a browser or UI client. If you
want to develop an application service that can be used to expose an SAP HANA data model to client
requests.
5.1.5
SAP HANA Repository
In order to support developers in creating applications and services directly within this new SAP
HANA Extended Application Services, SAP has enhanced the SAP HANA Studio to include all the
necessary tools. SAP HANA Studio was already based upon Eclipse; therefore we were able to
extend the Studio via an Eclipse Team Provider plug-in which sees the SAP HANA Repository as a
remote source code repository similar to Git or Perforce. This way all the development resources
(everything from HANA Views, SQLScript Procedures, Roles, Server Side Logic, HTML and
JavaScript content, etc.) can have their entire lifecycle managed with the SAP HANA Database.
These lifecycle management capabilities include versioning, language translation export/import, and
software delivery/transport.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
7
Embedding SAP Predictive into BI Tools
5.1.6
SAP Predictive Analysis
SAP Predictive Analysis is a statistical analysis and data mining solution that
enables you to build predictive models to discover hidden insights and
relationships in your data, from which you can make predictions about future
events. „SAP Predictive Analysis is a complete data discovery, visualization,
and predictive analytics solution designed to extend your current analytics
capability and skillset, regardless of your history with BI. It’s an intuitive, dragand-drop, code-free experience with enough power for data scientists to conduct more sophisticated
analysis using Big Data, yet simple enough to allow business analysts to conduct forward-looking
analysis using departmental data from Excel.”
SAP Predictive Analysis is a rich client application that allows you to intuitively design complex
predictive models, visualize, discover, and share hidden insights and harness the power of Big Data
with SAP HANA:





5.1.7
Intuitively design complex predictive models
Visualize, discover, and share hidden insights
Unleash Big Data with SAP HANA’s power
Embed Predictive in to Apps and BI environments
Real-time answers
SAP InfiniteInsight (formerly known as KXEN InfiniteInsight)
SAP InfiniteInsight is a predictive modeling suite developed by KXEN that
assists analytic professionals and business executives to extract information from data. Among other
functions, SAP InfiniteInsight is used for variable importance, classification, regression, segmentation,
time series, product recommendation. One of the driving technologies behind SAP InfiniteInsight is to
the writers’ knowledge the “Statistical Learning Theory” or Vapnik–Chervonenkis theory accredited to
mathematician Vladimir Vapnik. The KXEN Company was acquired by SAP in Q4 2013.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
8
Embedding SAP Predictive into BI Tools
6
Technical requirements
SAP HANA with predictive analysis library configured and ready for use.
SAP Predictive Analysis using SAP HANA as “Connected” or online data source.
SAP Dashboard Designer, SAP Design Studio or other SAP BusinessObjects tool capable of
connecting to SAP HANA and adding a few buttons to invoke HANA XS.
7
Building trained predictive model.
A good starting point for our simple end-to-end use case is the decision tree which fulfills the
requirements for a classification problem and it also provides valuable descriptions on the findings.
Furthermore it can be used for the identification of driving indicators (factors, variables etc.) and
hence pruning insignificant indicators which can be leveraged in other algorithms.
The first step is to build the machine learning algorithm. In this case SAP Predictive Analysis will be
used to build a predictive model. The complete predictive process-flow could be more extensive than
presented as SAP PA is capable of using samples, filters etc. for data preparation etc. However in
this example the intent is to keep it simple so that the methodology and knowledge sharing is getting
the focus and not a sophisticated predictive model. From SAP PA the model is built on training data
and after running the trained model it can be saved and exported to HANA as a stored procedure ~ or
machine learned model. From there the machine learned model can be run on completely new or
unknown data to predict patterns, forecast etc.
7.1 Building trained predictive model – business examples.
SAP Predictive Analysis & SAP InfiniteInsight can provide real business value with advanced
analytics in areas such as – just to mention a few examples:
 Predicting who will buy additional products based on their behavior of interests – for instance
who will buy additional insurance - see reference [Holst & Manga, 2014] for detailed report.
 Preventive or Predictive Maintenance to enhance the customer experience, preventing
equipment failure and reduce the total repair cost.
 Predicting which customer is most likely to churn – using customer affinity analysis.
 Proactively detecting which components fail together and in which circumstances.
 Build appropriate stock levels of warranty replacement parts.
 Forecasting sales, repair, order intake etc.
 Etc…
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
9
Embedding SAP Predictive into BI Tools
7.1 Building trained predictive model – using SAP Predictive Analysis.
The development of predictive models is usually an iterative process where different models are
evaluate according to the test design and continuously optimized with respect to what is modeling
objectives.
Modeling -> Evaluation -> interpreting the results with domain experts -> data understanding -> data
preparation -> modeling -> … As recommended implementation methodology one could use Cross
Industry Standard Process for data mining, CRISP-DM, which is a hierarchical process model which
consists of phases and tasks. This model is also used to give an overview of life cycle of a data
mining project. CRiSP-DM was developed during 1996 by three “veterans” of the young and
immature data mining market. More detailed information on the model will be explained in the
following chapter.
Some of the steps might be skipped depending on the findings and need for enhancements in data
preparation, combining data fields, creating new calculations based on two or more existing fields etc.
During the modeling the data scientists and predictive modeling experts should document the process
so that it can be re-run with a different set of parameters. Further it should also document the reasons
for choosing those values.
Finally the model should be run in the modeling tool on the prepared dataset to create one or more
models.
The modeling process could look like this in SAP Predictive Analysis. On the left is the data source
and then there is a filter for either Training or Scoring (Test, validation) data. After which the actual
data mining algorithm is applied. In this case a Decision Tree is applied to the training data and the
model is executed and saved as a new trained model. The trained model is then applied to unknown
or scoring data.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
10
Embedding SAP Predictive into BI Tools
After running the Decision Tree on Training data SAP Predictive Analysis produces results in terms of
an Algorithm Summary. As shown SAP Predictive Analysis has generated a mathematical equation
that could now be run on new data to predict most likely outcomes.
The generated mathematical equation could be manually transferred to a SAP BI Clients; however
that would take a lot of effort and the amount of data should be limited as compared to the capabilities
of SAP HANAs in-memory processing which can take very large datasets.
In a simpler case with the use of linear regression for instance a manual approach could be preferred.
As an example with only one independent and one dependent variable:
Using SAP PA to generate an mathematical equation as to the relationship between the independent
and dependent variable.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
11
Embedding SAP Predictive into BI Tools
SAP PA generates a new column “PredictedValues”:
And going to SAP PA’ Algorithm summary provides a neat mathematical equation:
This equation could very easily be added to a Dashboard and once the user would enter a new value
for the “X” it would calculate the “Y”. However real predictive analysis isn’t always as easy– in fact far
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
12
Embedding SAP Predictive into BI Tools
from it. This is why there is a need for a more automated approach and tool support. But for
illustration purposes and in theory this is what this article is about – embedding the mathematical
equations build with known dataset in a user friendly Dashboard or report.
7.2 Illustrating the generated predictive model – using SAP Predictive Analysis.
SAP Predictive Analysis is capable of charting many of the build-in algorithms. For the Decision Tree
chart where the most important (driving factors) are on top of the tree.
Besides the Decision Tree chart and Algorithm Summary SAP PA also displays a Confusion Matrix
where the predicted results are compared with the actual results:
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
13
Embedding SAP Predictive into BI Tools
7.3 Scoring the trained predictive model on test or validation data.
After applying the trained model to scoring data SAP Predictive Analysis is executed and the
prediction column is added to the data set including probability if chosen:
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
14
Embedding SAP Predictive into BI Tools
From the Visualize tab the user can then develop additional visualizations on the newly predicted
results – for instance it is possible to build a table similar to the confusion matrix as shown below:
This articles main focus is to embed SAP Predictive into SAP BI tools and the next step would be to
utilize this model in SAP BI tools. To make it easy to replicate our steps we will use a simpler
example to illustrate the steps necessary to embed a trained or machine learned model as shown
above in a SAP BI tool.
7.4 Building trained predictive model – simple example.
Our data source is based on 5 simple fields. The intent is to build a binary classification model where
we predict whether the conditions are to go outside and play golf or not. (Reference: MacGregor,
2013).
The independent variables HUMIDITY, OUTLOOK, TEMP and WINDY are used to predict the target
variable “CLASS” which is our field that decides whether we should play or not.
The SQL statement for creating this data source can be found in the appendix of this article.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
15
Embedding SAP Predictive into BI Tools
Executing the model and displaying the Results including the new column “PredictedValues”
generated by SAP Predictive Analysis:
Using the Confusion Matrix to score our trained model:
The Confusion matrix is a way of visualization of the performance of an algorithm in supervised
learning.
Each column of the matrix represents the instances in a predicted class, while each row represents
the instances in an actual class. The confusion matrix is also called the contingency table or the error
matrix.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
16
Embedding SAP Predictive into BI Tools
SAP PA has built-in capability to display the indicators in a decision tree. The results of some
algorithms allow great visualizations – such as the decision tree shown below. This could then be
used to discuss with the business people with domain expertise.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
17
Embedding SAP Predictive into BI Tools
7.5 Saving the trained model as a new model in SAP PA:
Saving the model in SAP Predictive Analysis is performed by clicking on “Save as model” on each
algorithm.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
18
Embedding SAP Predictive into BI Tools
Exporting the SAP PA trained model to SAP HANA:
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
19
Embedding SAP Predictive into BI Tools
7.6 The procedure is now saved back to SAP HANA:
Opening the Store procedure reveals what code SAP Predictive Analysis generated.
Calling this code with the right parameters will allow the use of the trained model and hence harvest
the machine learned algorithm in SAP HANA or with a few more code-steps directly in SAP BI
Clients.
SAP InfiniteInsight also has the capability of producing the trained model as SQL code. SAP
InfiniteInsight can either generate the SQL code directly on HANA when already using SAP HANA as
data source.
The generation of SAP HANA specific SQL code can also be done manually in SAP InfiniteInsight
and then copy/pasted into SAP HANA, however if using SAP HANA as a data source this is already
done automatically.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
20
Embedding SAP Predictive into BI Tools
From the Save / Export menu there is an option to “Save Model”:
SAP Infinite Insight can export the trained model directly to SAP HANA. When having
Generating the SAP HANA Code – manually:
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
21
Embedding SAP Predictive into BI Tools
SAP InfiniteInsight has another very useful capability as the automatically re-training of models can
be scheduled using the tool “Factory”, which we do not cover here.
In the following part of the article it will be shown what steps needs to done to use the SQL code
generated by SAP Predictive Analysis inside a tool such as SAP BusinessObjects Dashboard.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
22
Embedding SAP Predictive into BI Tools
8
Dashboard solution
Business intelligence (BI) applications and dashboards have proven to be strong drivers and enablers
of BI adoption. But in order for your executives and business users to adopt them, BI applications
must be mobile, highly interactive, tailored to user needs, and able to deliver trusted, aggregated
numbers. What if you could quickly and cost-effectively create stunning, interactive visualizations
based on the exact requirements of executives – and do so while reusing your existing assets?
You can – with the SAP BusinessObjects Design Studio and SAP BusinessObjects Dashboards. This
breakthrough solution gives you the tools and flexibility to create visualizations, dashboards, and
even BI apps – all supporting a highly interactive mobile or desktop experience. Guided navigation
helps people access the insights they need. And because the software connects directly with SAP
NetWeaver Business Warehouse (SAP NetWeaver BW), SAP HANA, and any semantic layer
(universe), you can reuse your existing data assets while reducing the risk of errors.
8.1 Dashboard solution – business examples.
SAP BusinessObjects BI clients like SAP® BusinessObjects Design Studio and SAP
BusinessObjects Dashboards increases the value of your data through better insights enabled by
interactive data visualizations and a holistic, trusted view of the enterprise.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
23
Embedding SAP Predictive into BI Tools
8.2 Dashboard solution – simple example.
The following simple dashboard (created with SAP BusinessObjects Dashboards) shows how the
solution works. We want to keep it simple as we want to show you how easy the dashboard flow is.
The top area contains the data set we want to change. The bottom left table is based on an analytical
view which was built on the table PAL_DATA_TAB. The bottom right table shows what happens if we
enter a value in the input fields. The table itself is based on an analytical view which was built on the
table PAL_RESULT_TAB.
After entering new values in the input fields for ID 1 and pushing the “Send to SAP HANA” button, a
Server-Side JavaScript (XSJS) will be triggered on SAP HANA side and will execute a couple of SQL
statement including stored procedure calls. The data in the tables are updated with the entered
values and the PAL procedure starts running.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
24
Embedding SAP Predictive into BI Tools
In the final step after all SQL statements and stored procedures has been triggered on SAP HANA
side, the answer from SAP HANA is shown immediately in the dashboard.
9
Technical setup
This part describes the steps in SAP HAN that are needed to use the machine learned model in SAP
BI Clients. As shown below there are 6 features which is used to allow SAP BI Clients direct and realtime access to the trained predictive models inside SAP HANA.
The SAP PA generated model is simplified speaking exported to SAP HANA as a Stored Procedure. To allow SAP BI
Clients access to this stored procedure a few steps is required – as shown in the following.
Preparation of the SAP HANA Studio:
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
25
Embedding SAP Predictive into BI Tools
Start the SAP HANA Studio and open the “SAP HANA Modeler” perspective if not visible.
Make sure you are logged on to the SAP HANA system you are going to use.
Deploy and run SQL code:
Click on the system ID and start the SQL console for the selected system.
On the next screen you will see the empty SQL console.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
26
Embedding SAP Predictive into BI Tools
Go to the schema with the SAP PA trained model or SAP HANA stored procedure, “PAL_DASHBOARD”:
Use the stored procedure generated by SAP Predictive Analysis as shown earlier in this article:
Create XS JavaScript File for write back functionality in SAP HANA Studio:
Open a new perspective and select “SAP HANA Development”. If you can’t select it just click on “Other…”.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
27
Embedding SAP Predictive into BI Tools
Click on “Repositories” Tab and select “Create Repository Workspace” from the contact menu.
Enter a workspace name (e.g. in our demo “WRITEBACK_HANA”).
You have successfully created a new “Repository Workspace”.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
28
Embedding SAP Predictive into BI Tools
The next step is to create a new “Project” in the “Project repository” via context menu.
Select “XS Project” and click “next”.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
29
Embedding SAP Predictive into BI Tools
Enter a project name (e.g. in our demo “sap.hana.writebackhana”) and click “next”.
Now you have successfully created a “XS Project”.
Right Click on your project and select “File”.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
30
Embedding SAP Predictive into BI Tools
Name it “.xsaccess” and click “Finish”.
Repeat the same steps and create a second file named “.xsapp”. Your screen will look as follows.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
31
Embedding SAP Predictive into BI Tools
Double click on the file “.xsaccess” and enter the following content.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
32
Embedding SAP Predictive into BI Tools
Now we need an XSJS file with the some SQL code for the update code. Right click on project “sap.hana.writeback” and
select “new” followed by “XS JavaScript File”.
Name it “write2hana” and finish your entries.
Double click on “write2hana.xsjs” and insert the coding from the appendix into it.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
33
Embedding SAP Predictive into BI Tools
If you have finished click “save”.
Now it’s time to share your project. Select “Team” and “Share Project”.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
34
Embedding SAP Predictive into BI Tools
In the next screen select your Repository Workspace and click “Finish”.
Now all files will be transferred to SAP HANA.
We have finished all the activities required for the write back process. Now it’s time to activate all the developed objects.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
35
Embedding SAP Predictive into BI Tools
Test run for table update in SAP HANA:
Now select your XSJS file and run it.
Your browser will open. Please make sure to test it in Google Chrome. Enter your credentials and start:
The first time you run it you might get an error message which you will not see in other browsers. This error message is ok
because the system expects that you pass values for the fields
As your writeback3hana.xsjs waits for values just pass it via URL to test if it works well:
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
36
Embedding SAP Predictive into BI Tools
http://yourhanaserver:8000/sap/hana/writebackhana/write2hana.xsjs?ID=1&OUTLOOK=%27Sunny%27&TEMP=3&HU
MIDITY=2&WINDY=%27Yes%27
Now check in the SAP HANA Studio the table content of table PAL_DATA_TAB in schema “PAL_DASHBOARD”:
Remember what you have passed in your URL to the SAP HANA table:
ID=1
OUTLOOK=Sunny
TEMP=3
HUMIDITY=2
WINDY=Yes
Table PAL_DATA_TAB before change:
Table PAL_RESULT_TAB before change:
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
37
Embedding SAP Predictive into BI Tools
Table PAL_DATA_TAB after change:
Table PAL_RESULT_TAB before change:
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
38
Embedding SAP Predictive into BI Tools
10 Conclusion
As shown in this article with an end-to-end example of how to extend the use of machine learned
algorithms generated by SAP Predictive Analysis to easy accessible SAP BI Client such as a
Dashboard is feasible in a few steps using SAP HANA to facilitate the entire processing of algorithms,
returning predict data etc.
Embedding SAP Predictive or advanced analytics inside SAP BI Clients will greatly increase the
number of users with access to machine trained algorithms. The coding shown in this end-to-end
example is attached in the appendix and shouldn’t be a showstopper for anyone trying to
commoditize advanced analytics – the full code needed is less than one sheet of paper.
CNN Money interviewed the chief analytics officer at FICO, Andrew Jennings, whom also had a
saying on this topic and he goes a bit more in detail addressing the skills set needed in an advanced
analytics "If you're not a pure-math person or an expert programmer, that's all right, because you can
be on a team with people who are,", [CNN Money, 2013]. Using the approach shown in this article
end users without programming skills or advanced math-degrees can still benefit from advanced
analytics such as machine trained models. The end users of SAP BI Client such as a Dashboard
solution does not need to know all the inner-workings of a decision tree or neural network algorithm
as long as they can utilize it anyway to make assisted decisions.
In a real case this could extend the user base getting access to advanced analytics significantly.
Moreover in a customer environment where SAP BO, HANA and Predictive Analysis are already
available this approach would greatly improve the functionality available to users without adding new
products.
11 Perspective
During the creating of this article we came across a few development issues that we have addressed
– however in a productive environment it would likely need a more detailed approach.
We used SAP Predictive Analysis to train our algorithms and export the model to SAP HANA – we
could also have used SAP InfiniteInsight to do the very same steps. As of this writing it looks as if
SAP Predictive Analysis and InfiniteInsight will merge and a good guess is that this functionality will
therefore be available in the new merged tool.
As for SAP Web Intelligence and Design Studio, the process should be approximately the same as
for Dashboard Designer. Design Studio also allows for write-back and update buttons as described
with the Dashboard Designer solution in this document. For Web Intelligence there might be a need
for a custom coding a new button “Write-back” calling our HANA URL.
Single Sign on between BI tools and HANA using our approach – we did not go into details on this
function and as shown in this article the user needs to sign on to HANA the first time they press the
“Write-Back” button. Nevertheless you are able to select an authentication type to use when checking
user credentials before authorizing access to an application, for example: form-based authentication
(with user name and password), SAML (SSO with Security Assertion Markup Language), SAP logon
tickets. For more details it always helps to check the latest SAP HANA Developer Guide.
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
39
Embedding SAP Predictive into BI Tools
12 Appendix – HANA Script-code.
The code is provided as is – and as such not supported by SAP or the authors of this article.
Write2hana.xsjs
$.response.contentType = “text/html”;
var V_ID = $.request.parameters.get(‘ID’);
var V_OUTLOOK = $.request.parameters.get(‘OUTLOOK’);
var V_TEMP = $.request.parameters.get(‘TEMP’);
var V_HUMIDITY = $.request.parameters.get(‘HUMIDITY’);
var V_WINDY = $.request.parameters.get(‘WINDY’);
var hana_call = “CALL \”PAL_DASHBOARD\”.\”PROC_UPDATE_HANA\” (“ + V_ID + “ , “ + V_OUTLOOK + “ , “
+ V_TEMP + “ , “ + V_HUMIDITY + “ , “ + V_WINDY + “) WITH OVERVIEW”;
var hana_call2 = “TRUNCATE TABLE \”PAL_DASHBOARD\”.\”PAL_RESULT_TAB\””;
var hana_call3 = “CALL
\”_SYS_AFL\”.\”PAL_PREDICT_MODEL_CHAID\”(\”PAL_DASHBOARD\”.\”PAL_DATA_TAB\”,
\”PAL_DASHBOARD\”.\”PAL_CONTROL_TAB\”, \”PAL_DASHBOARD\”.\”PAL_JSONMODEL_TAB\”,
\”PAL_DASHBOARD\”.\”PAL_RESULT_TAB\”) with overview”;
try {
var conn = $.db.getConnection();
var pc = conn.prepareCall(hana_call);
pc.execute();
pc.close();
conn.commit();
conn.close();
var conn = $.db.getConnection();
pc = conn.prepareCall(hana_call2);
pc.execute();
pc.close();
conn.commit();
conn.close();
var conn = $.db.getConnection();
pc = conn.prepareCall(hana_call3);
pc.execute();
pc.close();
conn.commit();
conn.close();
var output = “<b>Message from SAP HANA XS Engine</b><br>Values for ID: “ + V_ID + “ with
OUTLOOK: <b>” + V_OUTLOOK + “</b>, TEMP: <b>” + V_TEMP + “</b>, HUMIDITY: <b>” + V_HUMIDITY +
“</b>, WINDY: <b>” + V_WINDY + “</b> has been transferred to SAP HANA. <br>Tables PAL_DATA_TAB and
PAL_RESULT_TAB has been updated 40uccessfully!”;
$.response.setBody(output);
} catch (error) {
$.response.setBody( “Failed to Update ID. “ + hana_call + “<br>Error Message: “ + error);
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
40
Embedding SAP Predictive into BI Tools
13 Appendix – HANA Predictive Analysis Library script-code.
The code, with permission from the author, shown below with a few exceptions from the great book
“Predictive Analysis with SAP – The Comprehensive Guide”, page 404+ by John MacGregor
--This document describes end to end cases with PAL. Using the HANA CHAID Decision Tree –
-- TRAIN PROCEDURE –
SET SCHEMA PAL_DASHBOARD;
DROP TYPE PAL_DATA_T;
CREATE TYPE PAL_DATA_T AS TABLE(“OUTLOOK” VARCHAR(50),”TEMP” INT,”HUMIDITY” INT,”Windy”
VARCHAR(50),”CLASSLABEL” VARCHAR(50));
DROP TYPE PAL_PMMLMODEL_T;
CREATE TYPE PAL_PMMLMODEL_T AS TABLE(“ID” INT,”PMMLMODEL” VARCHAR(5000));
DROP TYPE PAL_JSONMODEL_T;
CREATE TYPE PAL_JSONMODEL_T AS TABLE(“ID” INT,”JSONMODEL” VARCHAR(5000));
DROP TYPE PAL_CONTROL_T;
CREATE TYPE PAL_CONTROL_T AS TABLE(“NAME” VARCHAR (50),”INTARGS” INTEGER,”DOUBLEARGS”
DOUBLE,”STRINGARGS” VARCHAR (100));
--create procedure
DROP TABLE PDATA;
CREATE COLUMN TABLE PDATA(“ID” INT,”TYPENAME” VARCHAR(100),”DIRECTION” VARCHAR(100));
INSERT INTO PDATA VALUES (1, ‘PAL_DASHBOARD.PAL_DATA_T’, ‘in’);
INSERT INTO PDATA VALUES (2, ‘PAL_DASHBOARD.PAL_CONTROL_T’, ‘in’);
INSERT INTO PDATA VALUES (3, ‘PAL_DASHBOARD.PAL_JSONMODEL_T’, ‘out’);
INSERT INTO PDATA VALUES (4, ‘PAL_DASHBOARD.PAL_PMMLMODEL_T’, ‘out’);
call SYSTEM.afl_wrapper_eraser(‘PAL_CREATEDT_WITH_CHAID’);
call SYSTEM.afl_wrapper_generator(‘PAL_CREATEDT_WITH_CHAID’, ‘AFLPAL’, ‘CREATEDTWITHCHAID’,
PDATA);
-- TRAINING DATASET–
DROP TABLE PAL_TRAINING_TAB;
CREATE COLUMN TABLE PAL_TRAINING_TAB(“OUTLOOK” VARCHAR(50),”TEMP” INT,”HUMIDITY” INT,”Windy”
VARCHAR(50),”CLASSLABEL” VARCHAR(50));
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
PAL_TRAINING_TAB
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
(‘Sunny’,2,2,’Yes’,’Play’);
(‘Sunny’,2,1,’Yes’,’Do Not Play’);
(‘Sunny’,3,1,’No’,’Do Not Play’);
(‘Sunny’,2,1,’No’,’Do Not Play’);
(‘Sunny’,1,2,’No’,’Play’);
(‘Overcast’,2,1,’Yes’,’Play’);
(‘Overcast’,3,1,’No’,’Play’);
(‘Overcast’,1,2,’Yes’,’Play’);
(‘Overcast’,3,2,’No’,’Play’);
(‘Rain’,2,1,’Yes’,’Do Not Play’);
(‘Rain’,1,2,’Yes’,’Do Not Play’);
(‘Rain’,2,1,’No’,’Play’);
(‘Rain’,1,1,’No’,’Play’);
(‘Rain’,1,1,’No’,’Play’);
DROP TABLE PAL_CONTROL_TAB;
CREATE COLUMN TABLE PAL_CONTROL_TAB(“NAME” VARCHAR (50),”INTARGS” INTEGER,”DOUBLEARGS”
DOUBLE,”STRINGARGS” VARCHAR (100));
INSERT INTO PAL_CONTROL_TAB VALUES (‘PERCENTAGE’,null,1.0,null);
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
41
Embedding SAP Predictive into BI Tools
INSERT INTO PAL_CONTROL_TAB VALUES (‘THREAD_NUMBER’,2,null,null);
INSERT INTO PAL_CONTROL_TAB VALUES (‘IS_SPLIT_MODEL’,0,null,null);
INSERT INTO PAL_CONTROL_TAB VALUES (‘MIN_NUMS_RECORDS’,1,null,null);
-- INSERT INTO PAL_CONTROL_TAB VALUES (‘CONTINUOUS_COL’,2,25000,null);
-- INSERT INTO PAL_CONTROL_TAB VALUES (‘CONTINUOUS_COL’,2,60000,null);
INSERT INTO PAL_CONTROL_TAB VALUES (‘PMML_EXPORT’, 2, null, null);
DROP TABLE PAL_JSONMODEL_TAB;
CREATE COLUMN TABLE PAL_JSONMODEL_TAB(“ID” INT,”JSONMODEL” VARCHAR(5000));
DROP TABLE PAL_PMMLMODEL_TAB;
CREATE COLUMN TABLE PAL_PMMLMODEL_TAB(“ID” INT,”PMMLMODEL” VARCHAR(5000));
CALL “_SYS_AFL”.”PAL_CREATEDT_WITH_CHAID”(PAL_TRAINING_TAB, PAL_CONTROL_TAB, PAL_JSONMODEL_TAB,
PAL_PMMLMODEL_TAB) with overview;
SELECT
SELECT
SELECT
SELECT
*
*
*
*
FROM
FROM
FROM
FROM
PAL_TRAINING_TAB;
PAL_CONTROL_TAB;
PAL_JSONMODEL_TAB;
PAL_PMMLMODEL_TAB;
--- PREDICT PROCEDURE --SET SCHEMA PAL_DASHBOARD;
DROP TYPE PAL_DATA_T;
CREATE TYPE PAL_DATA_T AS TABLE(“ID” INT,”OUTLOOK” VARCHAR(50),”TEMP” INT,”HUMIDITY” INT,”Windy”
VARCHAR(50));
DROP TYPE PAL_JSONMODEL_T;
CREATE TYPE PAL_JSONMODEL_T AS TABLE(“ID” INT,”JSONMODEL” VARCHAR(5000));
DROP TYPE PAL_CONTROL_T;
CREATE TYPE PAL_CONTROL_T AS TABLE(“NAME” VARCHAR (50),”INTARGS” INTEGER,”DOUBLEARGS”
DOUBLE,”STRINGARGS” VARCHAR (100));
DROP TYPE PAL_RESULT_T;
CREATE TYPE PAL_RESULT_T AS TABLE(“ID” INT,”CLASSLABEL” VARCHAR(50));
-- create procedure
DROP TABLE PDATA;
CREATE COLUMN TABLE PDATA(“ID” INT,”TYPENAME” VARCHAR(100),”DIRECTION” VARCHAR(100));
INSERT INTO PDATA VALUES (1, ‘_SYS_AFL.PAL_DATA_T’, ‘in’);
INSERT INTO PDATA VALUES (2, ‘_SYS_AFL.PAL_CONTROL_T’, ‘in’);
INSERT INTO PDATA VALUES (3, ‘_SYS_AFL.PAL_JSONMODEL_T’, ‘in’);
INSERT INTO PDATA VALUES (4, ‘_SYS_AFL.PAL_RESULT_T’, ‘out’);
call SYSTEM.afl_wrapper_eraser(‘PAL_PREDICTWITHDT’);
call SYSTEM.afl_wrapper_generator(‘PAL_PREDICTWITHDT’, ‘AFLPAL’, ‘PREDICTWITHDT’, PDATA);
--- PREDICT or NEW DATASET --DROP TABLE PAL_DATA_TAB;
CREATE COLUMN TABLE PAL_DATA_TAB (“ID” INT,”OUTLOOK” VARCHAR(50),”TEMP” INT,”HUMIDITY” INT,”Windy”
VARCHAR(50));
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
SAP COMMUNITY NETWORK
© 2014 SAP AG
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
(1,’Sunny’,2,2,’Yes’);
(2,’Sunny’,2,1,’Yes’);
(3,’Sunny’,3,1,’No’);
(4,’Sunny’,2,1,’No’);
(5,’Sunny’,1,2,’No’);
(6,’Overcast’,2,1,’Yes’);
(7,’Overcast’,3,1,’No’);
(8,’Overcast’,1,2,’Yes’);
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
42
Embedding SAP Predictive into BI Tools
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INTO
INTO
INTO
INTO
INTO
INTO
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
PAL_DATA_TAB
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
(9,’Overcast’,3,2,’No’);
(10,’Rain’,2,1,’Yes’);
(11,’Rain’,1,2,’Yes’);
(12,’Rain’,2,1,’No’);
(13,’Rain’,1,1,’No’);
(14,’Rain’,1,1,’No’);
DROP TABLE PAL_CONTROL_TAB;
CREATE COLUMN TABLE PAL_CONTROL_TAB (“NAME” VARCHAR (50),”INTARGS” INTEGER,”DOUBLEARGS”
DOUBLE,”STRINGARGS” VARCHAR (100));
INSERT INTO PAL_CONTROL_TAB VALUES (‘THREAD_NUMBER’,2,null,null);
DROP TABLE PAL_RESULT_TAB;
CREATE TABLE PAL_RESULT_TAB(“ID” INT,”CLASSLABEL” VARCHAR(50));
SELECT * FROM PAL_JSONMODEL_TAB;
SELECT * FROM PAL_DATA_TAB;
--- EXECUTE PREDICT PROCEDURE WITH NEW DATASET --CALL “_SYS_AFL”.”PAL_PREDICTWITHDT”(PAL_DATA_TAB, PAL_CONTROL_TAB, PAL_JSONMODEL_TAB,
PAL_RESULT_TAB) with overview;
SELECT * FROM PAL_RESULT_TAB;
--- COMBINED PREDICTION TO PLAY OR NOT AND TESTING DATASET --select b.OUTLOOK, b.TEMP ,b.HUMIDITY ,b.”Windy”, a.”CLASSLABEL” AS GOLF from PAL_RESULT_TAB
a,PAL_DATA_TAB b, PAL_DATA_TAB c where a.ID = b.ID and c.OUTLOOK = b.OUTLOOK and c.TEMP = b.TEMP
and c.HUMIDITY = b.HUMIDITY and c.”Windy” = b.”Windy”;
SAP COMMUNITY NETWORK
© 2014 SAP AG
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
43
Embedding SAP Predictive into BI Tools
14 Reference Documentation
The following documents are referenced in this document:
DOCUMENT NAME
LOCATION
ISSUE
DATE
SAP HANA Predictive
Analysis Library (PAL)
(MacGregor, 2013)
John MacGregor
SAP HANA Platform SPS 07
Document Version: 1.0 – 27-11-2013
Predictive Analysis with SAP – The
Comprehensive Guide. ISBN 978-1-59229-916-4.
SAP Galileo Press.
http://help.sap.com/hana/SAP_HANA_Master_Gui
de_en.pdf
Nov
2013
2013
[Holst & Manga, 2014]
SAP Predictive Analysis – implementing real life
data mining use case predicting who will buy
additional insurance:
http://scn.sap.com/docs/DOC-50803
2014
[SAP Predictive Roadmap,
2014]
http://service.sap.com/roadmap
(Analytics -> Product -> SAP Predictive Analysis &
InfiniteInsight).
http://blognetwork.kilpatricktownsend.com/bigdatat
echlawblog/2013/05/22/gartner-predicts-need-for1-9-million-new-data-scientists-and-creation-of-6million-new-big-data-jobs-by-2015-and-dice-comidentifies-specific-areas-of-need/
2014
SAP HANA Developer Guide
[Gartner, 2013]
[CNN Money, 2013]
SAP COMMUNITY NETWORK
© 2014 SAP AG
2014
May
2013
http://management.fortune.cnn.com/2013/05/10/bi
g-data-jobs/
SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
44
www.sap.com
© 2014 SAP AG. All rights reserved.
SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP
BusinessObjects Explorer, StreamWork, SAP HANA, and other SAP
products and services mentioned herein as well as their respective
logos are trademarks or registered trademarks of SAP AG in Germany
and other countries.
Business Objects and the Business Objects logo, BusinessObjects,
Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and
other Business Objects products and services mentioned herein as
well as their respective logos are trademarks or registered trademarks
of Business Objects Software Ltd. Business Objects is an SAP
company.
Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL
Anywhere, and other Sybase products and services mentioned herein
as well as their respective logos are trademarks or registered
trademarks of Sybase Inc. Sybase is an SAP company.
Crossgate, m@gic EDDY, B2B 360°, and B2B 360° Services are
registered trademarks of Crossgate AG in Germany and other
countries. Crossgate is an SAP company.
All other product and service names mentioned are the trademarks of
their respective companies. Data contained in this document serves
informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials
are provided by SAP AG and its affiliated companies ("SAP Group")
for informational purposes only, without representation or warranty of
any kind, and SAP Group shall not be liable for errors or omissions
with respect to the materials. The only warranties for SAP Group
products and services are those that are set forth in the express
warranty statements accompanying such products and services, if
any. Nothing herein should be construed as constituting an additional
warranty.