25.10.2016 Views

SAP HANA Predictive Analysis Library (PAL)

sap_hana_predictive_analysis_library_pal_en

sap_hana_predictive_analysis_library_pal_en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table Column Column Data Type Description<br />

2nd column Double Value of statistics<br />

Example<br />

Assume that:<br />

●<br />

●<br />

●<br />

DM_<strong>PAL</strong> is a schema belonging to USER1; and<br />

USER1 has been assigned the AFLPM_CREATOR_ERASER_EXECUTE role; and<br />

USER1 has been assigned the AFL__SYS_AFL_AFL<strong>PAL</strong>_EXECUTE or<br />

AFL__SYS_AFL_AFL<strong>PAL</strong>_EXECUTE_WITH_GRANT_OPTION role.<br />

SET SCHEMA DM_<strong>PAL</strong>;<br />

DROP TYPE <strong>PAL</strong>_CROSTON_DATA_T;<br />

CREATE TYPE <strong>PAL</strong>_CROSTON_DATA_T AS TABLE("ID" INT, "RAWDATA" DOUBLE);<br />

DROP TYPE <strong>PAL</strong>_CONTROL_T;<br />

CREATE TYPE <strong>PAL</strong>_CONTROL_T AS TABLE("NAME" VARCHAR(100), "INTARGS" INT,<br />

"DOUBLEARGS" DOUBLE, "STRINGARGS" VARCHAR(100));<br />

DROP TYPE <strong>PAL</strong>_CROSTON_RESULT_T;<br />

CREATE TYPE <strong>PAL</strong>_CROSTON_RESULT_T AS TABLE("TIME" INT, "OUTPUT" DOUBLE);<br />

DROP TYPE <strong>PAL</strong>_CROSTON_STATISTICS_T;<br />

CREATE TYPE <strong>PAL</strong>_CROSTON_STATISTICS_T AS TABLE ("NAME" VARCHAR (50), "VALUE"<br />

DOUBLE);<br />

DROP TABLE <strong>PAL</strong>_CROSTON_PDATA_TBL;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_CROSTON_PDATA_TBL ("POSITION" INT,"SCHEMA_NAME"<br />

NVARCHAR(256),"TYPE_NAME" NVARCHAR (256),"PARAMETER_TYPE" VARCHAR (7));<br />

INSERT INTO <strong>PAL</strong>_CROSTON_PDATA_TBL VALUES (1,'DM_<strong>PAL</strong>','<strong>PAL</strong>_CROSTON_DATA_T','IN');<br />

INSERT INTO <strong>PAL</strong>_CROSTON_PDATA_TBL VALUES (2,'DM_<strong>PAL</strong>','<strong>PAL</strong>_CONTROL_T','IN');<br />

INSERT INTO <strong>PAL</strong>_CROSTON_PDATA_TBL VALUES<br />

(3,'DM_<strong>PAL</strong>','<strong>PAL</strong>_CROSTON_RESULT_T','OUT');<br />

INSERT INTO <strong>PAL</strong>_CROSTON_PDATA_TBL VALUES<br />

(4,'DM_<strong>PAL</strong>','<strong>PAL</strong>_CROSTON_STATISTICS_T','OUT');<br />

CALL SYS.AFLLANG_WRAPPER_PROCEDURE_DROP('DM_<strong>PAL</strong>','CROSTON_TEST_PROC');<br />

CALL SYS.AFLLANG_WRAPPER_PROCEDURE_CREATE('AFL<strong>PAL</strong>','CROSTON', 'DM_<strong>PAL</strong>',<br />

'CROSTON_TEST_PROC', <strong>PAL</strong>_CROSTON_PDATA_TBL);<br />

DROP TABLE #<strong>PAL</strong>_CONTROL_TBL;<br />

CREATE LOCAL TEMPORARY COLUMN TABLE #<strong>PAL</strong>_CONTROL_TBL ("NAME" VARCHAR(100),<br />

"INTARGS" INT, "DOUBLEARGS" DOUBLE, "STRINGARGS" VARCHAR(100));<br />

INSERT INTO #<strong>PAL</strong>_CONTROL_TBL VALUES ('RAW_DATA_COL',1,NULL,NULL);<br />

INSERT INTO #<strong>PAL</strong>_CONTROL_TBL VALUES ('ALPHA', NULL,0.1,NULL);<br />

INSERT INTO #<strong>PAL</strong>_CONTROL_TBL VALUES ('FORECAST_NUM',1, NULL,NULL);<br />

INSERT INTO #<strong>PAL</strong>_CONTROL_TBL VALUES ('METHOD',0, NULL,NULL);<br />

INSERT INTO #<strong>PAL</strong>_CONTROL_TBL VALUES('MEASURE_NAME',NULL,NULL,'MAPE');<br />

DROP TABLE <strong>PAL</strong>_CROSTON_DATA_TBL;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_CROSTON_DATA_TBL LIKE <strong>PAL</strong>_CROSTON_DATA_T ;<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (0, 0.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (1, 1.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (2, 4.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (3, 0.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (4, 0.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (5, 0.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (6, 5.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (7, 3.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (8, 0.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (9, 0.0);<br />

INSERT INTO <strong>PAL</strong>_CROSTON_DATA_TBL VALUES (10, 0.0);<br />

DROP TABLE <strong>PAL</strong>_CROSTON_RESULT_TBL;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_CROSTON_RESULT_TBL LIKE <strong>PAL</strong>_CROSTON_RESULT_T;<br />

DROP TABLE <strong>PAL</strong>_CROSTON_STATISTICS_TBL;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_CROSTON_STATISTICS_TBL LIKE <strong>PAL</strong>_CROSTON_STATISTICS_T;<br />

CALL DM_<strong>PAL</strong>.CROSTON_TEST_PROC(<strong>PAL</strong>_CROSTON_DATA_TBL, "#<strong>PAL</strong>_CONTROL_TBL",<br />

<strong>PAL</strong>_CROSTON_RESULT_TBL, <strong>PAL</strong>_CROSTON_STATISTICS_TBL) WITH OVERVIEW;<br />

SELECT * FROM <strong>PAL</strong>_CROSTON_RESULT_TBL;<br />

364 P U B L I C<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Predictive</strong> <strong>Analysis</strong> <strong>Library</strong> (<strong>PAL</strong>)<br />

<strong>PAL</strong> Functions

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!