cancel
Showing results for 
Search instead for 
Did you mean: 

HANA PAL: Support Vector Machine bug

Former Member

I've found what I believe to be a bug with the PAL_SVM_TRAIN() and PAL_SVM_PREDICT() functions in PAL. I have reproduced the problem using the example provided in example 3 of the documentation here. I'm using SPS12 as provided in SAP CAL.

The error is associated with the specific order of the data types in the algorithm input tables; where if it doesn't follow certain patterns, the error will be thrown:

Could not execute 'CALL ...' in 90 ms 647 µs . 
SAP DBTech JDBC: [339]: invalid number:  [6930] attribute value is not a number 

I don't know what all the certain patterns are, but I can describe the simplest case that will reproduce the error.

In the documentation example 3, change the PAL_SVM_TRAINING_T Type:

  • delete ATTRIBUTE1
  • delete ATTRIBUTE2
  • swap the order of ATTRIBUTE3 and ATTRIBUTE4

The code should look like this

CREATE TYPE PAL_SVM_TRAINING_T AS TABLE ( 
	ID INTEGER, 
	ATTRIBUTE4 VARCHAR(10),
        ATTRIBUTE3 DOUBLE
	LABEL INTEGER
);

Reflect these changes in the input data table PAL_SVM_TRAINING_TBL by deleteing and swapping the relevant columns:

INSERT INTO PAL_SVM_TRAINING_TBL VALUES(0,'A',100,1);
INSERT INTO PAL_SVM_TRAINING_TBL VALUES(1,'A',100,1);
INSERT INTO PAL_SVM_TRAINING_TBL VALUES(2,'A',100,1);
...

Then complete the remainder of the example, and move onto the example 3 under PAL_SVM_PREDICT.

Make the analogous changes to PAL_SVM_SCORING_T

CREATE TYPE PAL_SVM_SCORING_T AS TABLE ( ID INTEGER,  ATTRIBUTE4 VARCHAR(10), ATTRIBUTE3 DOUBLE);

And edit the data for PAL_SVM_SCORING_TBL

INSERT INTO PAL_SVM_SCORING_TBL VALUES(0,'A',100);
INSERT INTO PAL_SVM_SCORING_TBL VALUES(1,'A',100);
INSERT INTO PAL_SVM_SCORING_TBL VALUES(2,'AB',400);
...

Continue to complete the remainder of the example, the error will be raised when the PAL_SVM_PREDICT() function is called.

This error won't occur if the order of Attribute3 and Attribute4 are switched.

I would like to know if anyone can replicate this error, and if so, if there is a work around.

Any help appreciated, Michael

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

I have developed a work around for this bug. It involves changing the order of the columns in the table. This is obvious in the example above because it works in the documentation, but does it generalise?

Yes. If you have many columns in your input data, you will need to rearrange them thus:

  • all of the DOUBLE type columns must be located immediately after the initial ID(integer) column.
  • after the DOUBLE type columns, any of the VARCHAR or INTEGER columns can be arranged in any order.
  • I haven't tried yet with NVARCHAR.

For example, the following input table will work for PAL_SVM_PREDICT()

CREATE TYPE PAL_SVM_SCORING_T AS TABLE ( 
    ID INTEGER,
    ATTRIBUTE3 DOUBLE,  
    ATTRIBUTE5 DOUBLE,
    ATTRIBUTE6 DOUBLE,    
    ATTRIBUTE4 VARCHAR(10), 
    ATTRIBUTE2 INTEGER,
    ATTRIBUTE1 VARCHAR(5),
    ATTRIBUTE7 INTEGER
    );