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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CREATE column table <strong>PAL</strong>_FNLR_PDATA_TBL("POSITION" INT, "SCHEMA_NAME"<br />

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

INSERT INTO <strong>PAL</strong>_FNLR_PDATA_TBL values (1,'DM_<strong>PAL</strong>','<strong>PAL</strong>_FNLR_PREDICT_T','IN');<br />

INSERT INTO <strong>PAL</strong>_FNLR_PDATA_TBL values (2,'DM_<strong>PAL</strong>','<strong>PAL</strong>_FNLR_COEFFICIENT_T','IN');<br />

INSERT INTO <strong>PAL</strong>_FNLR_PDATA_TBL values (3,'DM_<strong>PAL</strong>','<strong>PAL</strong>_CONTROL_T','IN');<br />

INSERT INTO <strong>PAL</strong>_FNLR_PDATA_TBL values (4,'DM_<strong>PAL</strong>','<strong>PAL</strong>_FNLR_FITTED_T','OUT');<br />

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

CALL<br />

SYS.AFLLANG_WRAPPER_PROCEDURE_CREATE('AFL<strong>PAL</strong>','FORECASTWITHLNR','DM_<strong>PAL</strong>','<strong>PAL</strong>_FOR<br />

ECAST_LNR_PROC',<strong>PAL</strong>_FNLR_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 ('THREAD_NUMBER',8,null,null);<br />

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

CREATE COLUMN TABLE <strong>PAL</strong>_FNLR_PREDICTDATA_TBL ( "ID" INT,"X1" DOUBLE);<br />

INSERT INTO <strong>PAL</strong>_FNLR_PREDICTDATA_TBL VALUES (0,1);<br />

INSERT INTO <strong>PAL</strong>_FNLR_PREDICTDATA_TBL VALUES (1,2);<br />

INSERT INTO <strong>PAL</strong>_FNLR_PREDICTDATA_TBL VALUES (2,3);<br />

INSERT INTO <strong>PAL</strong>_FNLR_PREDICTDATA_TBL VALUES (3,4);<br />

INSERT INTO <strong>PAL</strong>_FNLR_PREDICTDATA_TBL VALUES (4,5);<br />

INSERT INTO <strong>PAL</strong>_FNLR_PREDICTDATA_TBL VALUES (5,6);<br />

INSERT INTO <strong>PAL</strong>_FNLR_PREDICTDATA_TBL VALUES (6,7);<br />

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

CREATE COLUMN TABLE <strong>PAL</strong>_FNLR_COEFFICIENT_TBL ("ID" INT,"Ai" DOUBLE);<br />

INSERT INTO <strong>PAL</strong>_FNLR_COEFFICIENT_TBL VALUES (0,14.86160299);<br />

INSERT INTO <strong>PAL</strong>_FNLR_COEFFICIENT_TBL VALUES (1,98.29359746);<br />

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

CREATE COLUMN TABLE <strong>PAL</strong>_FNLR_FITTED_TBL ("ID" INT,"Fitted" DOUBLE);<br />

CALL DM_<strong>PAL</strong>.<strong>PAL</strong>_FORECAST_LNR_PROC(<strong>PAL</strong>_FNLR_PREDICTDATA_TBL,<br />

<strong>PAL</strong>_FNLR_COEFFICIENT_TBL, "#<strong>PAL</strong>_CONTROL_TBL", <strong>PAL</strong>_FNLR_FITTED_TBL) with overview;<br />

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

Expected Result<br />

<strong>PAL</strong>_FNLR_FITTED_TBL:<br />

3.3.3 Exponential Regression<br />

Exponential regression is an approach to modeling the relationship between a scalar variable y and one or<br />

more variables denoted X. In exponential regression, data is modeled using exponential functions, and<br />

unknown model parameters are estimated from the data. Such models are called exponential models.<br />

In <strong>PAL</strong>, the implementation of exponential regression is to transform to linear regression and solve it:<br />

y = β0 × exp(β1 × x1 + β2 × x2 + … + βn × xn)<br />

256 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!