0% found this document useful (0 votes)
53 views2 pages

SAP HANA PAL - K-Means Algorithm or How To Do Cust... - SAP Community-1Q

The document discusses running a K-Means clustering algorithm on customer data using the SAP HANA Predictive Analysis Library (PAL). It first generates a K-Means procedure using PAL, then prepares control and result tables to store parameters and outputs. The control table stores parameters like the exit threshold and normalization method. Result tables are created to store the cluster assignments for each customer along with the distance to the cluster center, and to store the cluster centers. The document then executes the K-Means procedure on the customer data.

Uploaded by

jefferyleclerc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views2 pages

SAP HANA PAL - K-Means Algorithm or How To Do Cust... - SAP Community-1Q

The document discusses running a K-Means clustering algorithm on customer data using the SAP HANA Predictive Analysis Library (PAL). It first generates a K-Means procedure using PAL, then prepares control and result tables to store parameters and outputs. The control table stores parameters like the exit threshold and normalization method. Result tables are created to store the cluster assignments for each customer along with the distance to the cluster center, and to store the cluster centers. The document then executes the K-Means procedure on the customer data.

Uploaded by

jefferyleclerc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

3/14/24, 10:14 AM SAP HANA PAL – K-Means Algorithm or How to do Cust...

- SAP Community

call SYSTEM.afl_wrapper_generator('PAL_KMEANS_TELCO', 'AFLPAL', 'KMEANS', PDATA_TELCO);

After executing this code we should see a new procedure in the _SYS_AFL schema called PAL_KMEANS_TELCO

Run the K-Means Procedure

I generated the K-Means procedure so now I need to write the code that will execute it:

/* This table will contain the parameters that will be used

during the execution of the KMeans procedure.

For Eexample, the number of clusters you would like to use */

DROP TABLE PAL_CONTROL_TAB_TELCO;

CREATE COLUMN TABLE PAL_CONTROL_TAB_TELCO(

https://community.sap.com/t5/technology-blogs-by-members/sap-hana-pal-k-means-algorithm-or-how -to-do-customer-segmentation-for-the/ba-p/12976696/page/2 11/39


3/14/24, 10:14 AM SAP HANA PAL – K-Means Algorithm or How to do Cust... - SAP Community

INSERT INTO PAL_CONTROL_TAB_TELCO VALUES ('EXIT_THRESHOLD',null,0.000001,null); --> Threshold value for


exiting an iteration

INSERT INTO PAL_CONTROL_TAB_TELCO VALUES ('NORMALIZATION',0,null,null); --> How to normalize the data. In
this case I'm not normalizing at all

/* This table will contain the resulting cluster

assignment for each customer and the distance to the center of the cluster */

DROP TABLE PAL_KMEANS_RESASSIGN_TAB_TELCO;

CREATE COLUMN TABLE PAL_KMEANS_RESASSIGN_TAB_TELCO(

"ID" INT,

"CENTER_ASSIGN" INT,

"DISTANCE" DOUBLE,

primary key("ID")

);

/* This table will contain the resulting centers for each cluster */

https://community.sap.com/t5/technology-blogs-by-members/sap-hana-pal-k-means-algorithm-or-how -to-do-customer-segmentation-for-the/ba-p/12976696/page/2 13/39

You might also like