Introducing Machine Learning with SAP Leonardo (2018)

115 Pages • 29,452 Words • PDF • 13.2 MB
Uploaded at 2021-09-25 20:21

This document was submitted by our user and they confirm that they have the consent to share it. Assuming that you are writer or own the copyright of this document, report to us by using this DMCA report button.


Manu Kohli

Introducing Machine Learning with SAP®Leonardo

_.. Rheinwerk t'

What You'll Learn Start by understanding the building blocks of machine learning-s upervised and unsupervised learning-and the tools SAP provides for it: SAP Leonardo, SAP Data Hub, and SAP Vora. Then walk step-by-step through how to create test data and apply machine learning algorithms to data sets. A practical example on deep learning and neural networks will show you machine learning in action!

1

2

3

4

Machine Learning Overview ................................... .

5

1.1 1.2 1.3

6

Supervised Learning ........ . ......... . .................... . Unsupervised Learning ..... . ......... .. ..... . ......... .... . Use Cases and Examples ... . ..................... . ........ .

11 15

Machine Learning Tools ....................................... .

26

2.1 2.2 2.3

What Is Big Data? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SAP Leonardo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SAP Data Hub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

27 28 31

2.4

SAP Vora . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

34

2.5

Open Source Tools and Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . .

35

Data Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

36

3.1 3.2 3.3

Preprocessing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Normalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Train ing and Test Datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

37 44 45

Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

46

4.1 4.2 4.3 4.4 4.5 4.6

47 49 50 52 53 55

Logistic Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K-Means Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Support Vector Machine.......................... . ......... Regression Example: Price Det ermination . . . . . . . . . . . . . . . . . . . Class ificat ion Example: Customer Classification... . .... . .... Clustering Example: Equipment Fa ilure . . . . . . . . . . . . . . . . . . . . .

4

5

Outcomes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5.1

Understanding the Outcome of Machi ne Learn ing Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Handling Overfitting and Underfitting...................... Cross-Validation Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bias and Variance Ba lancing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

57 60 62 63

Machine Learning w ith SAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

64

6.1

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

65

6.2 6.3 6.4

SAP Cloud Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SAP Leonardo Machine Learning Functiona l Services . . . . . . . . SAP Leonardo Machine Learning Business Services . . . . . . . . . .

69 71 86

Deep Learning and Neural Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . .

95

5.2 5.3 5.4 6

7

7.1 7.2 7.3 7.4 8

1

56

Image and Video Ana lysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Developing a Neura l Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 TensorFlow Integration with SAP HANA..................... 104 Classification Example: SAP Environment, Health, and Safety Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

What's Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Machine Learning Overview

Machine learning refers to the process of using algorithms to find patterns and relationships in data in order to solve business problems. Machine learning algorithms differ from traditional programming in that machine learning algorithms learn from data patterns rather being explicitly programmed. For an enterprise, the majority of business process data is available in enterprise resource planning (ERP} applications such as SAP. This data can belong to one or more than one business functions, e.g., procurement, quality, sales, production, environmental health and safety, and so on. In SAP applications, transactional data is recorded in a time series (recorded over a

5

1 Machine Learning Overview

period of time), sourced from non-SAP applications (via interfaces), and often relationally associated. This large volume of data can be used extensively by machine learning algorithms to solve business problems. Data fields are carefully identified, shortlisted, and aggregated from multiple data sources, such as SAP and non-SAP IT applications, social media sites, data historians, and so on, to build a data model. A data historian is a software program that stores process or operational data in a manufacturing plant and allows quick information retrieval for analysis or processing. This data model is then fed to machine learning algorithms for analysis. Domain expertise, IT application knowledge, data modeling, and data sciences are important skills for designing and developing machine learning solutions. Machine learning algorithms have been around since 1960s; however, their application has become relevant largely in last few years. This development stems from the availability of high-power computing machines, high-speed Internet, cloud infrastructures, and in-memory databases. In the next section, we'll look various types of machine learning models and how their application can help us solve business problems.

1.1

Supervised Learning

Supervised learning is the machine learning task of inferring a function from data that has been labeled as training data. Various algorithms are applied as part of supervised learning process. These algorithms learn from the data and perform classification and regression tasks. However, before supervised learning can be applied, a feature set is prepared from the data. Feature sets consist of multiple columns, with each column referred to as a feature (or an input vector or dimension). As will be shown later in Table 3, fields such as supplier, material group, quantity, per unit price, payment terms, and so on can make up a feature set. All the data in one column will have the same scale and unit of measure. In our case, the leftmost column is called "Outcome," which serves as the label for the dependent variable on which algorithm learns. Each row describes a single entity or observation in which a feature set and label are recorded. We recommend having a

6

1 Machine Learning Overview

sufficient number of observational records to build a machine learning model. Therefore, when building a feature set, you should identify the relevant features (columns) and include a sufficient number of cases (rows) to solve a business problem. The objective of supervised learning is to determine the association between the feature set variables (x) and the external labels or output variable (y). Through supervised learning, the algorithm can learn the mapping function between input (x) and output (y), or y = f(x). All data used for supervised learning is labeled, and the algorithm learns to predict the output from the input data. Supervised learning can be used to resolve two types of business problems: • Classification problems Let's say you have a specified set of classes or labels and need to classify a new entry without a label into one of these specified classes. For example, you could predict the risk rating of a location (high, medium, low) or predict whether an individual has a "disease" or "no disease." For simplicity, we'll look at a two-class example of a classification task from the medical domain. The objective of this classification model is to predict whether a breast tumor should be labeled "malignant" or "benign," based on a feature set. The features for the tumor can include its physical attributes, such as its area, size, texture, and so on. The machine learning model is initially trained to perform classification by selecting a relevant feature set and a large number of labeled training examples. A model, once trained, is usually referred to as a classifier. The classifier working on a two-class problem can be represented visually as a straight line on a two-dimensional x-y plane, as shown in Figure 1. The classifier, once sufficiently trained, learns to identify tumors as either "malignant" (represented by triangles) or "benign" (represented by circles). The model can identify any new tumor without a label as either "malignant" or "benign" based on its features. Unlabeled tumors are represented by stars, as shown in Figure 1. Based on its learning and the

7

1 Machine Learning Overview

tumor's characteristics (i.e., size, area), the classifier can identify an unlabeled tumor as either "malignant" or "benign."

IClassifier I y

0

Benign Tumor

*Unlabeled Tumor

.A. Malignant Tumor

x Figure 1 Two-Class Classification Example (Benign Versus Malignant Tumors)

This example is easy to visually represent and understand because only two classes are involved. An additional example of classification technique is to analyze text of an email and classify it into one of the two classes: "spam" and "not spam." You can create machine learning algorithms to classify more than two classes as well. However, as the number of classes increases, the visualization of the classifier is not limited to a two-dimensional plane but the number of dimensions {3D, 4D, and so on) is the same as the number of classes on which the algorithm is learning. A visualization of a classifier in many dimensions is not easy to create or comprehend. Another way classification techniques can be applied is in designing a recommendation engine to help you select a supplier among several potential suppliers, based on their past performance. In this example, our feature set and labels to build this recommendation system are based on classification model, as detailed in Table 3. The development of a recommendation system can be considered a classification problem where we need to classify suppliers in one of the three classes (i.e., "Excellent," "Good," and "Non-Performing") based on past

8

1 Machine Learning Overview

purchase performance data. Based on your organization's requirements, you can change the number of classes to four or more. To execute this example, we'll use historical data (completed purchase orders) from an SAP application and evaluate supplier performance v.rith respect to quality, on-time delivery, and on-quantity commitments for each line item of a purchase order. Based on supplier performance with respect to these features, a label ("Excellent," "Good," or "Non-Performing") can be manually assigned to each line item of the data model. The labeled dataset, with its large number of examples (purchase order line items), can then teach the machine learning algorithm the classification rules. These classification rules, once learned by the algorithm, can be used as a recommendation engine to select the best supplier for a product category, for example, for a material group or a material n umber in an SAP application, during the request for proposal stage. • Regression problems Another way supervised learning can resolve business problems is through regression techniques, which involve creating a relationship between the dependent or outcome numerical variable (y) and one or more independent variables (x). The main goal of a regression algorithm is to predict discrete or continued values based on a feature set. Regression is different from classification because the outcome of the regression is a numerical value, whereas in classification, the outcome is one of several predefined classes. Linear regression establishes a curve/line connecting data points, such that the differences between the distances of data points from the curve or line are minimized. As shown in Figure 2, the blue line proposed by the algorithm finds the best fit between the predictor variable (x) and the target variable (y). One application of the regression technique might be to predict numerical values in multiple business cases, for example, predicting financial revenue, the price of a commodity, the weight of material in a manufacturing setup, and so on. The regression model learns to predict outcomes based on its analysis of historical data, which includes numerical outcomes (y) and feature sets (x).

9

1 Machine Learning Overview

Y (Air-conditioner units sold)

0

X (Heat wave in t he city) Figure 2 Simple Linear Regression Example (Air Conditioner Sales)

One application of the regression technique might be to predict sales of any fast-moving consumer goods (FMCG), for example, televisions, air conditioners, or refrigerators, based on microeconomic parameters of a country (or region), the advertising budget of the organization, weather predictions, and so on. We'll discuss this example feature set in detail in Section 4.4. The historical time series data can be extracted from an SAP application and can include, for example, past sales of air conditioning units (y) and advertising budgets spent on print (x6), TV (x7), and Internet (x8). The feature set can be built by integrating macroeconomic and weather-related factors, such as the availability of disposal income (x1), interest rates (x 2), middle-class income (x 3), predicted temperature ranges (x4 ), economic growth rate (x5), and so on. The linear regression also indicates the relative strength of the impact of multiple independent variables (x1, x 2, x 3, ... Xn) on the dependent variable (y). The strength of each independent variable to influence the dependent variable is shown in Figure 2, where our independent variable (number of days of a heat wave in the city) is

10

1 Machine Learning Overview

observed to have a high and positive relation with sales of air conditioner units. The regression model learns the association between air conditioning unit sales (y) and various features in the feature set {x1, x 2, x 3, .... x 0 ). Regression can be of two types: simple linear regression and multiple Jin. ear regression. In simple linear regression, a single independent variable {x) is used to predict the value of a dependent variable (y). In multiple linear regression, two or more independent variables {x1, x 2, ... x 0 ) are used to predict the value of a dependent variable (y). A simple regression model can be visualized in two-dimensional x-y plane, as shown in Figure 2. In this example, only one independent variable {x) is taken. The relationship between y and xis positive, which seems logical, as sales of air conditioners in the city should increase during heat waves. To summarize, the goal of a supervised learning is to determine the relationship between training examples and reference labels and to produce a model that can predict labels or values for new input data points. Up to this point, we've learned about supervised learning techniques in which a label or a numerical value is assigned to each training dataset on which an algorithm learns. The next section talks about unsupervised learning techniques in which labels are not assigned to the dataset. The objective of unsupervised learning is to identify data patterns, inferences, and relationships between large datasets.

1.2

Unsupervised Learning

Unsupervised learning explores patterns on unlabeled datasets and draws inferences. The objective of unsupervised learning is as exploratory data analysis to find hidden patterns or groupings in data. Unsupervised learning results in clusters modeled using a measure of similarity, which is defined upon metrics such as Euclidean or probabilistic distance.

11

1 Machine Learning Overview

Let's look at our earlier supplier evaluation example again and see how unsupervised learning can be applied. We'll simply build a data model and not assign any labels (such as "Excellent," "Good," or "Non-Performing") to the line items in the dataset; however, the feature set (other than the label assignment) remains exactly same. We'll feed the data to the unsupervised machine learning algorithms with the objective of dividing this data into three sets. Unsupervised machine learning algorithms perform that distribution based on associated data patterns in the feature set. As shown in Figure 3, our data is distributed by the algorithm into three groups based on data patterns in the feature set, which are supplier performance measures based on quality, quantity, and on time-delivery. The distribution of the data into three classes, "Excellent," "Good," and "Non-Performing," is performed by the unsupervised learning algorithm based on data attributes in the feature set. The entries in these three groups may or may not match the assignment of labels that we used earlier for supplier performance using the supervised learning technique. Certain outliers, data errors, or model definition errors may cause some data points to be allocated to an incorrect group.

• •a a••a •a a aa •••

0-1----+ Outliers Outliers

OOOo

f""\.

gRPC Server

Model Pe rsistence (

Model 1\: )

Model n )

Figure 11 TensorFlow and SAP HANA Int egration

3

Data Preparation

Data preparation is the most important step when trying to resolve a problem through machine learning. The first step is t o clearly define a problem and then identify and select the right data feature set to resolve the problem. Your selection of a feature set should be based on the recommendation of your domain and business experts who may understand the problem and feature set contributing to the problem clearly. Let's look at two examples mentioned earlier in Section 1.3 for a better understanding. In the first example, you're trying to classify your suppliers into three categories (i.e., "Excellent," "Good," and "Non-Performing"). You'll need to build a feature set that will include purchase history details as well as supplier performance against contractual terms. The purchase history may include purchase material, quantity of purchase, supplier, and so on. The purchase performance data will include ho"v supplier performed with respect to contractual delivery time, contractual quality to deliver, and quality of delivery. These details can be easily tracked down from multiple

36

3 Data Preparation

SAP tables or standard extractors, and a classification model can be built on this data. In our second example, a holistic risk assessment model needs to be developed using relevant feature sets from each SAP application. The selection of the right features from Incident Management (such as number of incidents, open investigations, fatalities, implemented safety measures, and trainings for a functional location) can provide insight about the risk associated with a location. Similar data, for example, the number of critical work permits issued (i.e., hot work permits and enclosed space permits) can signify a higher associated risk for a location when compared to other locations. In these processes, you must also consider that data and feature sets may belong outside of the SAP landscape. For example, if you're trying to resolve machinery breakdown problems, you may find that condition measurement records for the equipment may not be available in an SAP application but do exist in the data historian. Once the feature set finalized, data can be extracted and cleansed. Before machine learning algorithms can be applied on the data set, multiple data preprocessing steps are carried out on the dataset to achieve optimum results. These steps depend on the data quality and data type of the feature set. We will study about data preprocessing and data type in subsequent sections.

3.1

Preprocessing Data

Real world data has missing entries, outliers and various inconsistencies such as varied unit of measures. Data preprocessing includes data cleansing, transformation, binning, normalization and reduction. Data preprocessing begins with data cleansing that includes process of detecting outliers, identifying missing entries, and correcting corrupt records in the record set. Once the missing entries and outliers are corrected, the data will

37

3 Data Preparation

need to be transformed so that it can be fed into machine learning algorithms. In the end data reduction exercise is performed to reduce number of attributes in the dataset while ensuring similar analytical outcomes. We will read about all the steps in the subsequent sections.

Data Cleaning and Transformation Data preprocessing starts with data cleansing, which may include finding missing data entries, populating missing entries with appropriate statistical measures such as mean or median, removing records marked for deletion, and removing duplicate entries and outliers. Let's say you are looking for goods receipts linked to purchase orders, and you find that, for some purchase order line items, receipts have not been recorded but a follow-on invoice document has been created. In this case, you may need to preprocess the entries from the invoice document for data preparation. Similarly, you may need to preprocess entries from multiple relationally associated tables that may have linked fields such as purchase order header, item, history, receipt header, and item. Some preprocessing steps may include discarding deleted entries and defining unique identifiers, such as a combination of purchase order number and item number to link a purchase order with one or more goods receipts and/or invoices. Data transformation includes the processing of data that may include normalization or binning. Data normalization adjusts the values measured on different scales to a notionally common scale, often prior to the application of a mathematical model. For example, you may have to scale quality units in purchase order data to a common unit of measure (for example, kilograms) from multiple unit of measurements used in purchase orders (such as grams, tons, etc.). Another method is binning that leads to assignment of values to groups to create a smaller set of discrete ranges. Binning is also useful to reduce the influence of outliers or extreme values on the model. Binning thus helps to mitigate model bias because the numerical quantities can be transformed to frequency distributed bins using quantiles (or the equal-height method). As a result, outliers won't impact the model when trained.

38

3 Data Preparation

Bins can be prepared for numerical quantities, such as the per unit price, the quantity of purchase, or the amount of purchase (quantity x price). One example of binning is simple discretization using equal-width partitioning. For example, let's say you have a list of purchase orders with acertain supplier in which the following quantities (measured in kilograms) for a material group (i.e., raw materials) are ordered: 5, 9, 10, 12, 16, 37, 51, 53, 74, 94, 202, and 211. The formula for binning into equal-width partitions is width= max - min)-:- N, where N is the width of each interval. Let's divide our 12 purchases into 3 groups using the formula: Width= (211 - 5) -:- 3 = 70. Therefore, the values in our three bins will be as follo\.vs: • Bin 1 will have 9 values between 5 and 75 = {5, 9, 10, 12, 16, 37, 51, 53, 74} • Bin 2 will have 1 value between 76 and 145 = {94} • Bin 3 will have 2 values between 146 and 215 = {202, 211} However, note that equal-width binning may dominate the calculation by skewing the data by including outliers. Another method, equal-depth (frequency) partitioning, divides the range into N intervals with each interval containing approximately the same number of samples. Our purchase order data, when represented using equal-depth partitioning, will result in three bins with the following values: • Bin 1 will have 4 values = {5, 9, 10, 12} • Bin 2 will have 4 values = {16, 37, 51, 53} • Bin 3 will have 4 values= {74, 94, 202, 211} Rather than absolute values, these categorical bins have a smoothing effect on the data, thus contributing to training of the machine learning model. Once transformation is completed, data is aggregated using unique key combinations. For example, to calculate the goods receipt for a purchase order line item, you may have to aggregate all goods receipts for a purchase order line item with the correct movement types to compare the purchase order quantity with the goods receipt. For example, goods movement 101

39

3 Data Preparation

can record the receipt of an item whereas goods movement 102 is the reversal of a goods receipt. Similarly, goods movement 103 and its reversal may highlight the quality of the supply and can be used to build a machine learning model for supplier selection in which quality is a criteria. Data Type: Structured

Structured data usually originates from information technology applications such as SAP or another relational database management system (RDBMS). Structured data has a predefined model and is organized in a defined manner. Most of the data stored in an SAP application is structured, so you can export from various SAP tables or from other business intelligence or business warehouse applications in a spreadsheet. Structured data is usually easier to understand and can be processed more easily by algorithms when compared to unstructured data. Structured data can consist of either continuous values or categorical values. Continuous values can be integers or real numbers; for example, in the case of a goods receipt against a purchase order, the data can be an integer or can also be negative real number (representing a return). A good example of categorical values can be material groups or a supplier number, which are not integers or real numbers, but rather numeric strings that are categorically represented. Most master data objects in SAP applications, such as the supplier master, the customer master, or equipment master, store structured data including names, length-delineated phone numbers, Social Security numbers, or ZIP codes. This data may be human- or machine-generated and created within an RDBMS structure. The data format is searchable both with human-generated queries and with algorithms using field names that can involve alphabetical, numeric, or keyword searches. Data Type: Unstructured

Unstructured data lacks a set format, predefined data models, or a schema. You may have to define custom and complex rules to extract this data from unstructured data sources, which include text files, emails, social media posts, websites, media sources such as videos and images, and so on. In SAP

40

3 Data Preparation

applications, some examples of unstructured data include the Word or PDF attachments that you may attach to transactional data, such as purchase orders, work orders, and so on. Other examples of unstructured data are Tweets and posts on social media from which meaningful information may be extracted. Unstructured data can be stored in a nonrelational database like NoSQL. Unstructured data can be human or machine generated as well. Some examples of unstructured machine-generated data include equipment condition measures from sensors, satellite imagery, computed tomography (CT) scan, and so on. Use cases for unstructured data are rapidly expanding. One example is text analytics, which can analyze unstructured text from logs and notes and extract and transform that data into useful structured information for further analysis. Social media analytics can be used to measure the effectiveness of a post to ensure high-volume customer conversations, facilitate supplier selection, and so on. SAP Leonardo's machine learning models can provide significant insights on unstructured data, such as images and text files. We'll explore these models in subsequent sections. Both structured and unstructured data can be used to prepare a feature set for building machine learning models. Preparing a Feature Set

Features are the variables selected in the problem statement that can strongly build a predictive model for problem resolution. A feature set is matrix of all the features: Each column represents a relevant feature that may contribute to the resolution of a business problem. Feature selection requires a sufficient understanding of business problem, and we recommend using the domain experts to help choose. The correct selection of features can improve the accuracy of the model and reduce its complexity. Machine learning provides various quantitative ways to reduce the number of features by measuring their weights in the outcome. This capability is

41

3 Data Preparation

specifically relevant for supervised learning, where each line item of a feature set is associated with a label. Let's look at an example: a feature set for a simple classification problem to evaluate suppliers based on their performance. Table 3 is populated with most relevant features for evaluating suppliers. For simplicity, we'll only consider five suppliers in this example. In a real-world scenario, machine learning algorithms might be trained on thousands of line items. For each record, we have one label (the leftmost column) and nine features. .....

.....

0..

+-' l1l

::I

.

l1l

:!:::: t:

l1l ::I

0 ..... Q

0

>. t:

~

•• ••• • • ••



•• •

•• • •• •• • • •• • • • • •• Time

Underfitted

Figure 19 Underfitted Model

61

5 Outcomes

Ideally, the model should be correctly fitted, as shown in Figure 20.

"'"' ::>

~

•• •

••

• • ••••••

••

• Ti me

Good Fit/Robust

Figure 20 Correctly Fit Model

5.3

Cross-Validation Techniques

Cross-validation is a statistical method for evaluating and comparing algorithms by dividing data into two segments: one used to train the model and the other to validate the model. The basic cross-validation technique is a holdout method, in which the dataset is separated into a training set and a test set. The algorithm function builder approximates function using the training set, and the function is asked to predict the output values for the data in the testing set. One criterion for evaluating a model is its accuracy. Various cross-validation techniques can make a model more robust and predict more accurately on multiple data forms. One cross-validation technique is k-fold cross-validation. In this process, the data is divided into k subsets, and the holdout method is repeated k times. Each time, one of the k subsets is used as the test set/validation set and the other k - 1 subsets are combined to form a training set.

62

5 Outcomes

The error estimation is averaged over all k trials to get a value representing the total effectiveness of the model. The advantage of this method is that all observations are used for both training and validation, and each observation is used for validation exactly once. The most commonly used value for kin cross-validation is 10.

5.4

Bias and Variance Balancing

The goal of any supervised machine learning algorithm is to determine the mapping function (f) for the output variable (y) given the input data (x). However, this mapping between the independent variables (x1, x 2, ... Xn) and f(y) is an approximation and includes an error value. This error can understood as error due to bias and error due to variance. Let's look at the differences between bias and variance next: • Biases are assumptions made by approximating the complicated model to make the target function easier to learn. Errors due to bias occur when (and result in) the expected model making predictions different from the true value of the training data. Bias error was introduced as the model tried to make the data simpler and can depend on the model. Parametric algorithms such as decision trees have high bias, making them fast learners but less flexible. A model with high bias needs to learn from large sample training datasets to achieve high accuracy to learn and to be easier to understand but are generally less flexible. These models have lower predictive performance on complex problems that fail to meet the simplifying assumptions of the algorithms bias. • Variance error is the recorded deviation in the target function if different training data was used. A model with lo"v variance shows similar results across multiple training datasets. Machine learning algorithms that have a high variance are influenced by the specifics of the training data. Some

63

6 Machine Learning w ith SAP

examples of low-variance machine learning algorithms include linear regression and logistic regression. Examples of high-variance machine learning algorithms include decision trees, k-nearest neighbors, and support vector machines. While building a model, our objective should be to achieve low bias and low variance and reasonable prediction performance. One step for parameterizing machine learning algorithms is to balance out bias and variance challenge. The bias-variance trade-off fork-nearest neighbor and support vector machine algorithms can be adjusted by managing the k parameters and C parameters of the respective algorithms. The fi ne-tuning of these parameters is out of scope of this E-Bite.

6

Machine Learning with SAP

SAP Leonardo Machine Learning is a new brand in the SAP portfolio of intelligent applications. With SAP Leonardo Machine Learning Foundation, enterprise data can be used to build machine learning models. Machine learning services are available through one of three means as shown in Figure 21, as follows:

• SAP HANA Predictive Analytics Library (PAL) Part of SAP HANA Application Function Library that contains functions that can be called within SAP HANA using SQL scripts to execute machine learning algorithms. • SAP Predictive Analytics SAP Predictive Analytics is based on set of rules used to predict an outcome based on input data. SAP Predictive Analytics is part of the SAP HANA box.

64

6

Machine Lea rning w ith SAP

• SAP Leonardo Machine Learning Foundation Available on SAP Cloud Platform, SAP Leonardo Machine Learning Foundation contains a library of pre built machine learning models that can be accessed through REST APis. The platform allows you to deploy your own models as well. Other SAP HANA components such as the Automated Predictive Library (APL) that comes with SAP BusinessObjects can be used to build machine learning models as well. SAP HANA application integration with programming language R allows machine learning algorithms and associated model to be integrated with SAP. The technology behind the APL allows you to build external libraries of machine learning algorithms that can be linked to SAP HANA applications. In this section, we'll primarily focus on SAP Leonardo Machine Learning Foundation and explore how machine learning models can be built and consumed on SAP Cloud Platform.

[

(

SAP HANA (PAL)

)

l(

l

( On-Premise

Cloud

I

Machine Lea rn ing

SAP Predictive Analytics (3.x)

( On-Premise

l[

Cloud

SAP Leonardo Machine Learning Foundation

l

[

SAP Cloud Platform

Figure 21 SAP Leonardo Mach ine Learning Applications

6.1

Overview

As shown in Figure 22, SAP Leonardo Machine Learning Foundation has three predominant service offerings. For each service offering, machine learning models have been developed, the services of which can be consumed using REST APis.

65

l

6

Machine Lea rning w ith SAP

SAP Leonardo Machine Learning Foundation

Foundation Services

Predictive Services

Business Services

-

.

[ (

[

SAP HANA (PAL)

On-Premise

J[

Cloud

Intell igent Services

l

Machine Learn ing

)

J [

SAP Predictive Analytics (3.x)

On-Premise

J [

Cloud

SAP Leonardo Machine Learn ing Foundation

J

[

SAP Cloud Platform

Figure 22 SAP Leonardo Machine Learning Foundation

We'll discuss each of the three services, as follows: • SAP Leonardo Machine Learning funct ional services These ready-to-use machine learning model services can be accessed using REST APis. REST technology is preferred as it leverages less bandwidth, making it more suitable for Internet usage. APis are available for image classification, image feature extraction, document feature extraction, and more. We'll look at some example APis in detail and apply them in Section 6.3. The application of image recognition has widespread impact. It can be applied for brand recognition and track visibility of an enterprise on social media for example data existing on Facebook or Twitter. Machine learning models can be retrained using enterprise specific data. Customers and partners can also deploy their machine learning models using a well-defined governance process. Some of the functional services available include the following: - Image classification API: Calculates and returns a list of classifications along with their probabilities for a given image.

66

l

6 Machine Learning w ith SAP

- Image feature extraction API: Capable of extracting feature vectors for any given image, which can be used for comparison, information retrieval, clustering, or further processing. - Topic detection API: Extracts topics from documents and scores them according to the most relevant topics. We'll read in detail about the utilization of these APis in Section 6.3 of this E-Bite. • SAP Leonardo Machine Learning predictive services Analytics services such as classification, clustering, and outlier detection can be performed on SAP HANA database on SAP Cloud Platform. Various models can be built and integrated on SAP Cloud Platform using structured data to generate classifications, scores, and recommendations. SAP Leonardo Machine Learning predictive services have been available in SAP HANA for some time. However, with SAP Leonardo, the availability of algorithms to perform predictive services has increased. SAP Predictive Analytics Integrator Service is a part of SAP Leonardo Machine Learning predictive services and integrates predictive models on cloud applications and enables their utilization. The framework enables organizatio ns to adopt predictive models in enterprise applications . Enterprise users can use the output of the models in the fo rm of recommendations and decisions to help them strategize and improve the business. • SAP Leo nardo Machine Learning business services These enterprise services are available for gaining better insight about and financial health scores for enterprise processes, customers, and su ppliers. Currently, SAP Leonardo Machine Learning business services offers three APis available for consumption on SAP API offering, as shown in Figure 23: - SAP Intelligent Financing API: This API offers customer-specific models and recommendation systems in certain functions and sectors. Some examples of SAP Leonardo Machine Learning intelligent applications are resume matching and invoice and cash matching. SAP Intelligent Financing can also calculate a substitute credit rating by analyzing historical business activities through a business network (suppliers and

67

6

Machine Learning with SAP

buyers). This calculation can result in an index, called an SAP Finance Health Score, which represents the sustainability of a business entity. One benefit of an SAP Finance Health Score is that a supplier with a high score may receive a lower interest rate and a longer credit period \AJhen seeking financing from banks.

SAP Leonardo Machine Learning - Business Services Discover SAP Leonardo Machine Learning for service organizations.

~ AP ls ,...,a ""'a

,...,a ""'a

SAP Service Ticket Intelligence -...

SAP 5ervice lteket lntell.igence helps to build a setf·dnven customer service powered by machine learning.

VerSiOn 2 4.0

REST

EJ

Details

,...,a ""'a

SAP Intelligent Financing API

SAP Intelligent Financing analyses

hrstoncal acrrvttJE?S of users ot a business network (supp(iers and buyers) to calw:ate an index. called ... REST

SAP Service Ticket Intelligence -...

SAP Sesvice lteket lntell.igeoce helps to build a setf·dnven customer seMCe powered by machine learning.

V4N'SiOn 2 4 0

REST

Figure 23 SAP Leonardo Machine Learning Business Services

SAP Service Ticket Intelligence classification API: This API improves the customer service with machine learning assistance. - SAP Service Ticket Intelligence recommendation API: This API makes recommendations based on a machine learning model to improve customer service for an enterprise. Using SAP Cloud Platform services, SAP Leonardo Machine Learning Foundation allows you to develop prototype, test, and deploy solutions to innovate your business.

68

6 Machine Learning w ith SAP

The key benefits of SAP Leonardo Machine Learning Foundation are: • Bringing SAP Partners onto a common platform to developing various machine learning models • Integrating, through SAP Data Hub, multiple data sources for developing machine learning models • Provisioning a version management system and governance mechanism to develop machine learning models • Developing a repository of machine learning algorithms that can be accessed via APis to provide real-time results • Providing an authorization framework to secure the communication channels between API Management, the SAP Leonardo Machine Learning services, and SAP Leonardo Machine Learning Foundation. In the next section, vve'll look at SAP Cloud Platform, through which SAP Leonardo Machine Learning Foundation can be accessed.

6.2

SAP Cloud Platform

SAP Cloud Platform is available as a platform as a service (PaaS}, thus enabling SAP customers and partners to build personalized, collaborative cloud applications. Using SAP Cloud Platform, you can access SAP Leonardo Machine Learning Foundation. You can add access to SAP Cloud Platform using a trial version, but machine learning services are not available in the trial version. However, you'll be able to access SAP AP! services with trial accounts and evaluate ready-to-use models. For installing your own model and using SAP Leonardo Machine Learning Foundation, you'll need to install Cloud Foundry and set the API to point to the Cloud Controller of your Cloud Foundry instance for the region of your account. You can deploy your machine learning models to the Cloud

69

6 Machine Learning w ith SAP

Foundry runtime, create and bind services to the models, and manage these applications and models using the Cloud Foundry. However, that option is only available to SAP Partners and paid SAP customers. In this section, we'll explore how to use SAP Leonardo Machine Learning business services and SAP Leonardo Machine Learning functional services AP Is. You can access multiple services available on SAP Cloud Platform using APis, as shown in Figure 24. Some services in the trial account are kept active, and some critical ones, for example IoT and machine learning, are not enabled in the trial account. However, the SAP Leonardo Machine Learning library can be accessed using SAP API Business Hub. Clicking on SAP API Business Hub will bring you to a screen from which you can navigate to Services.

•1:.!2,ill':zjt

Ci:

@t:.:c:;•

O'dwslrn!e busiia.s C;::. Establish airntdiom between >Gi Sellni«Wf l'.,'OC0$$9$ OlnCI n'Fi. d.1t.l in rN. Cl dOl.ICI awcaOoN ~ Cl'l•i;nmi5e tmt. ~.

VI) SAP API BusitlcSS Hub

"''d\1"}*

Attfss d.1ta n S/IP 8usinKs Suir.

5= -

-

•tt·*·•

@4.1,1.c .:5•

laing OOot.t $CMce$.

Figure 24 SAP Cloud Platform SAP API Business Hub

The SAP API Business Hub can also be accessed at https://api.sap.com/, where you can search for "SAP Leonardo." The search results are shown in Figure 25. The SAP API Business Hub displays two APis relevant to SAP

70

6

Machine Learning w ith SAP

Leonardo: SAP Leonardo Machine Learning business services and SAP Leonardo Machine Learning functional services. We'll look at these two API services in detail in Sections Section 6.3 and Section 6.4, respectively. SAP API Business Hub

CQ

Cl.8$$ic: Design

Gelling Started

Hi Manu ...,

Discover and consume digital content packages with APls. pre-packaged integrations. and sample apps from SAP and select partners SAP Leonat services SAP Leonardo Mbeflioe Learning touncldtJOO P'()nctes 1eadily consuf'Oab6t pr-e-11ai~ IT'IOC!e-ls.

v

Lioes Ot Business ~

V VC'ndor

Statistical Process Control

API PaacaRe

Coouol your prod Jct and process quality us ng standard statisiicat methodology Clear AU

ri1

SAP Asset lnteUJgence Networt< Integration with SAP ttybri.s Cloud tor Customer and SAP Cloud Platform IOT Services

rntegraoon Package

Figure 25 SAP Leonardo API

6.3

SAP Leonardo Machine Learning Functional Services

SAP Leonardo Machine Learning functional services has multiple services that can be accessed using APis. You can click on the link SAP Leonardo Machine Learning functional services, as shown in Figure 25, to view the 14 services that can be consumed using APls, as shown in Figure 26. We'll explore some examples using these APis and their practical application to the real '
Introducing Machine Learning with SAP Leonardo (2018)

Related documents

1,059 Pages • 652,515 Words • PDF • 38.1 MB

266 Pages • 123,300 Words • PDF • 3.9 MB

209 Pages • 58,165 Words • PDF • 2.6 MB

312 Pages • 62,542 Words • PDF • 14.5 MB

8 Pages • 4,288 Words • PDF • 82.8 KB

17 Pages • 2,643 Words • PDF • 2.4 MB

1 Pages • 323 Words • PDF • 25.7 KB

5 Pages • 1,631 Words • PDF • 289.3 KB

41 Pages • 4,303 Words • PDF • 1.7 MB

347 Pages • 106,578 Words • PDF • 1.3 MB

23 Pages • 17,180 Words • PDF • 1.1 MB