cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way to export feature importance from SAP BO Predictive Analytics?

Former Member
0 Kudos

Hi,

we have created a classification model in SAP BO predictive analytics (dektop). For visualization we want to export the feature importance (maybe in an HANA DB) including corresponding values of the intervals.

So here is my question: is there any way to export the described values?

View Entire Topic
marc_daniau
Advisor
Advisor
0 Kudos

From SAP Predictive Analytics desktop, save the classification model in table: MODEL_TRAIN_DESKTOP within HANA.

From HANA Studio, prepare the signature of the APL function : get_model_info for a model in Native format

drop table GET_MODEL_INFO_SIGNATURE;
create column table GET_MODEL_INFO_SIGNATURE like PROCEDURE_SIGNATURE_T;
insert into GET_MODEL_INFO_SIGNATURE values (1, 'USER_APL','FUNCTION_HEADER_T', 'IN');
insert into GET_MODEL_INFO_SIGNATURE values (2, 'USER_APL','MODEL_NATIVE_T', 'IN');   --- Native format
insert into GET_MODEL_INFO_SIGNATURE values (3, 'USER_APL','OPERATION_CONFIG_T', 'IN');
insert into GET_MODEL_INFO_SIGNATURE values (4, 'USER_APL','SUMMARY_T', 'OUT');
insert into GET_MODEL_INFO_SIGNATURE values (5, 'USER_APL','VARIABLE_ROLES_WITH_COMPOSITES_OID_T', 'OUT');
insert into GET_MODEL_INFO_SIGNATURE values (6, 'USER_APL','VARIABLE_DESC_OID_T', 'OUT');
insert into GET_MODEL_INFO_SIGNATURE values (7, 'USER_APL','INDICATORS_T', 'OUT');
insert into GET_MODEL_INFO_SIGNATURE values (8, 'USER_APL','PROFITCURVE_T', 'OUT');

call SYS.AFLLANG_WRAPPER_PROCEDURE_DROP('USER_APL','APLWRAPPER_GET_MODEL_INFO');
call SYS.AFLLANG_WRAPPER_PROCEDURE_CREATE('APL_AREA','GET_MODEL_INFO','USER_APL', 'APLWRAPPER_GET_MODEL_INFO', GET_MODEL_INFO_SIGNATURE);

Specify the model format in the function header, and run the APL function : get_model_info

drop table FUNC_HEADER;
create table FUNC_HEADER like FUNCTION_HEADER_T;
insert into FUNC_HEADER values ('Oid', '#42');
insert into FUNC_HEADER values ('LogLevel', '8');
insert into FUNC_HEADER values ('ModelFormat', 'native');
drop table OPERATION_CONFIG;
create table OPERATION_CONFIG like OPERATION_CONFIG_T;
drop table SUMMARY;
create table SUMMARY like SUMMARY_T;
drop table VARIABLE_DESC;
create table VARIABLE_DESC like VARIABLE_DESC_OID_T;
drop table VARIABLE_ROLES;
create table VARIABLE_ROLES like VARIABLE_ROLES_WITH_COMPOSITES_OID_T;
drop table INDICATORS;
create table INDICATORS like INDICATORS_T;
drop table PROFITCURVES;
create table PROFITCURVES like PROFITCURVE_T;

call APLWRAPPER_GET_MODEL_INFO (
FUNC_HEADER, MODEL_TRAIN_DESKTOP, 
OPERATION_CONFIG, SUMMARY, VARIABLE_ROLES, VARIABLE_DESC, INDICATORS, PROFITCURVES 
) with overview;

Extract variables importance from APL table : INDICATORS

select 
 OID ,
 row_number() OVER (partition by OID order by to_double(VALUE) desc) as "Rank",
 VARIABLE as "Explanatory Variable", 
 round(to_double(VALUE) *100 , 2) as "Individual Contribution",
 round(sum(to_double(VALUE)) OVER (partition by OID order by to_double(VALUE) desc) *100 ,2) as "Cumulative Contribution"
from 
 INDICATORS 
where 
 KEY = 'MaximumSmartVariableContribution'
order by 4 desc;

Sample Results