SAP HANA PAL - K-Means Algorithm or How To Do Cust... - SAP Community-9
SAP HANA PAL - K-Means Algorithm or How To Do Cust... - SAP Community-9
SAP HANA PAL - K-Means Algorithm or How To Do Cust... - SAP Community-9
- SAP Community
The first step is creating a table that will contain information on customers mobile phone usage habits with the following
structure:
"DAY_TIME_CALLS" DOUBLE, --> Percentage of Calls made during day time hours (9 a.m. - 6 p.m.)
"WEEK_DAY_CALLS" DOUBLE, --> Percentage of Calls made during week days (Monday thru Friday)
So each row in this table will represent a unique customer. Now I need to fill it, but I do not have access to real data, so I
had to build my own dataset. I created 30 different customers (30 rows) that can be grouped in 3 segments:
Segment 1: From Customer ID 1 thru 10. In this segment customers usually have short calls. They originate or receive
a low number of calls. These customers call more in the evening, more often during the weekend and to mobile lines.
They send and receive a fair amount of SMSs. This segment could represent personal mobile users.
Segment 2: From Customer ID 10001 thru 10010. In this segment customers have an average call duration. They
originate or receive an average number of calls. They usually call during business hours and during week days. They
send or receive a small amount of SMSs. This segment could represent small business users.
Segment 3: From Customer ID 20001 thru 20010. In this segment customers usually have long duration calls. They
usually call during business hours and during week days. They usually call to mobile lines and they heavily use SMSs.
This segment could represent enterprise business users.
Now that I have my dataset, I’m ready to start coding. The first thing we need to do is generate the PAL procedure by
calling the AFL Wrapper Generator. To do so we need to create a number of Table Types that will be used to define the
structure of the data that will be used as input and output parameters:
"ID" INT,
"CENTER_ASSIGN" INT,
"DISTANCE" DOUBLE
);
"ID" INT,
"AVG_CALL_DURATION" DOUBLE,
"AVG_NUMBER_CALLS_RCV_DAY" DOUBLE,
"AVG_NUMBER_CALLS_ORI_DAY" DOUBLE,
"DAY_TIME_CALLS" DOUBLE,
"WEEK_DAY_CALLS" DOUBLE,
"CALLS_TO_MOBILE" DOUBLE,
"SMS_RCV_DAY" DOUBLE,
"SMS_ORI_DAY" DOUBLE,