0% found this document useful (0 votes)
49 views3 pages

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

The document discusses generating and running a K-Means clustering procedure in SAP HANA using the Predictive Analysis Library (PAL). It describes creating table types to store the input and output data for K-Means, generating a PAL_KMEANS_TELCO procedure using these table types, and executing the procedure by passing control parameters to specify properties like the number of clusters. The goal is to segment customers using K-Means clustering on a telco dataset.

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)
49 views3 pages

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

The document discusses generating and running a K-Means clustering procedure in SAP HANA using the Predictive Analysis Library (PAL). It describes creating table types to store the input and output data for K-Means, generating a PAL_KMEANS_TELCO procedure using these table types, and executing the procedure by passing control parameters to specify properties like the number of clusters. The goal is to segment customers using K-Means clustering on a telco dataset.

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/ 3

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

- SAP Community

"V006" DOUBLE,

"V007" DOUBLE

);

/* Table Type that will be used to specify

the different parameters to run the KMeans Algorithm */

DROP TYPE PAL_CONTROL_TELCO;

CREATE TYPE PAL_CONTROL_TELCO AS TABLE(

"NAME" VARCHAR (50),

"INTARGS" INTEGER,

"DOUBLEARGS" DOUBLE,

"STRINGARGS" VARCHAR (100)

);

/* This table is used to generate the KMeans procedure

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 9/39


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

and will point the AFL Wrapper Generator to the different

table types that we just created */

DROP TABLE PDATA_TELCO;

CREATE COLUMN TABLE PDATA_TELCO(

"ID" INT,

"TYPENAME" VARCHAR(100),

"DIRECTION" VARCHAR(100) );

/* Fill the table */

INSERT INTO PDATA_TELCO VALUES (1, '_SYS_AFL.PAL_KMEANS_DATA_TELCO', 'in');

INSERT INTO PDATA_TELCO VALUES (2, '_SYS_AFL.PAL_CONTROL_TELCO', 'in');

INSERT INTO PDATA_TELCO VALUES (3, '_SYS_AFL.PAL_KMEANS_RESASSIGN_TELCO', 'out');

INSERT INTO PDATA_TELCO VALUES (4, '_SYS_AFL.PAL_KMEANS_CENTERS_TELCO', 'out');

/* Creates the KMeans procedure that executes the KMeans Algorithm */

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 10/39


3/14/24, 10:01 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

You might also like