PALBase

class hana_ml.algorithms.pal.pal_base.PALBase(conn_context=None)

Subclass for PAL-specific functionality.

Attributes
fit_hdbprocedure

Returns the generated hdbprocedure for fit.

predict_hdbprocedure

Returns the generated hdbprocedure for predict.

Methods

add_attribute(attr_key, attr_val)

Function to add attribute.

apply_with_hint(with_hint[, ...])

Apply with hint.

consume_fit_hdbprocedure(proc_name[, ...])

Return the generated consume hdbprocedure for fit.

consume_predict_hdbprocedure(proc_name[, ...])

Return the generated consume hdbprocedure for predict.

create_apply_func(func_name, data[, key, ...])

Create HANA TUDF SQL code.

disable_arg_check()

Disable argument check.

disable_convert_bigint()

Disable the bigint conversion.

disable_hana_execution()

HANA execution will be disabled and only SQL script will be generated.

disable_with_hint()

Disable with hint.

enable_arg_check()

Enable argument check.

enable_convert_bigint()

Allows the conversion from bigint to double.

enable_hana_execution()

HANA execution will be enabled.

enable_no_inline([apply_to_anonymous_block])

Enable no inline.

enable_parallel_by_parameter_partitions([...])

Enable parallel by parameter partitions.

enable_workload_class(workload_class_name)

HANA WORKLOAD CLASS is applied for the statement execution.

get_fit_execute_statement()

Returns the execute_statement for training.

get_fit_output_table_names()

Get the generated result table names in fit function.

get_fit_parameters()

Get PAL fit parameters.

get_pal_function()

Extract the specific function call of the SAP HANA PAL function from the sql code.

get_parameters()

Parse sql lines containing the parameter definitions.

get_predict_execute_statement()

Returns the execute_statement for predicting.

get_predict_output_table_names()

Get the generated result table names in predict function.

get_predict_parameters()

Get PAL predict parameters.

get_score_execute_statement()

Returns the execute_statement for scoring.

get_score_output_table_names()

Get the generated result table names in score function.

get_score_parameters()

Get SAP HANA PAL score parameters.

is_fitted()

Checks if the model can be saved.

load_model(model)

Function to load the fitted model.

set_scale_out([route_to, no_route_to, ...])

SAP HANA statement routing.

apply_with_hint(with_hint, apply_to_anonymous_block=True)

Apply with hint.

Parameters
with_hintstr

The hint clauses.

apply_to_anonymous_blockbool, optional

If True, it will be applied to the anonymous block.

Defaults to True.

enable_workload_class(workload_class_name)

HANA WORKLOAD CLASS is applied for the statement execution.

Parameters
workload_class_namestr

The name of HANA WORKLOAD CLASS.

disable_arg_check()

Disable argument check.

enable_arg_check()

Enable argument check.

disable_hana_execution()

HANA execution will be disabled and only SQL script will be generated.

enable_hana_execution()

HANA execution will be enabled.

enable_parallel_by_parameter_partitions(apply_to_anonymous_block=False)

Enable parallel by parameter partitions.

Parameters
apply_to_anonymous_blockbool, optional

If True, it will be applied to the anonymous block.

Defaults to False.

enable_no_inline(apply_to_anonymous_block=True)

Enable no inline.

Parameters
apply_to_anonymous_blockbool, optional

If True, it will be applied to the anonymous block.

Defaults to True.

disable_with_hint()

Disable with hint.

enable_convert_bigint()

Allows the conversion from bigint to double.

Defaults to True.

disable_convert_bigint()

Disable the bigint conversion.

Defaults to False.

property fit_hdbprocedure

Returns the generated hdbprocedure for fit.

property predict_hdbprocedure

Returns the generated hdbprocedure for predict.

consume_fit_hdbprocedure(proc_name, in_tables=None, out_tables=None)

Return the generated consume hdbprocedure for fit.

Parameters
proc_namestr

The procedure name.

in_tableslist, optional

The list of input table names.

out_tableslist, optional

The list of output table names.

consume_predict_hdbprocedure(proc_name, in_tables=None, out_tables=None)

Return the generated consume hdbprocedure for predict.

Parameters
proc_namestr

The procedure name.

in_tableslist, optional

The list of input table names.

out_tableslist, optional

The list of output table names.

set_scale_out(route_to=None, no_route_to=None, route_by=None, route_by_cardinality=None, data_transfer_cost=None, route_optimization_level=None, workload_class=None, apply_to_anonymous_block=True)

SAP HANA statement routing.

Parameters
route_tostr, optional

Routes the query to the specified volume ID or service type.

Defaults to None.

no_route_tostr or list of str, optional

Avoids query routing to a specified volume ID or service type.

Defaults to None.

route_bystr, optional

Routes the query to the hosts related to the base table(s) of the specified projection view(s).

Defaults to None.

route_by_cardinalitystr or list of str, optional

Routes the query to the hosts related to the base table(s) of the specified projection view(s) with the highest cardinality from the input list.

data_transfer_costint, optional

Guides the optimizer to use the weighting factor for the data transfer cost. The value 0 ignores the data transfer cost.

Defaults to None.

route_optimization_level{'minimal', 'all'}, optional

Guides the optimizer to compile with route_optimization_level 'minimal' or to default to route_optimization_level. If the 'minimal' compiled plan is cached, then it compiles once more using the default optimization level during the first execution. This hint is primarily used to shorten statement routing decisions during the initial compilation.

workload_classstr, optional

Routes the query via workload class. route_to statement hint has higher precedence than workload_class statement hint.

Defaults to None.

apply_to_anonymous_blockbool, optional

If True it will be applied to the anonymous block.

Defaults to True.

get_fit_execute_statement()

Returns the execute_statement for training.

get_predict_execute_statement()

Returns the execute_statement for predicting.

get_score_execute_statement()

Returns the execute_statement for scoring.

get_parameters()

Parse sql lines containing the parameter definitions. In the sql code all the parameters are defined by four arrays, where the first one contains the parameter name, and one of the other three contains the value fitting to the parameter, while the other two are NULL. This format should be changed into a simple key-value based storage.

Returns
dict

Dict of list of tuples, where each tuple describes a parameter like (name, value, type)

get_fit_parameters()

Get PAL fit parameters.

Returns
list

List of tuples, where each tuple describes a parameter like (name, value, type)

get_predict_parameters()

Get PAL predict parameters.

Returns
list

List of tuples, where each tuple describes a parameter like (name, value, type)

get_score_parameters()

Get SAP HANA PAL score parameters.

Returns
list

List of tuples, where each tuple describes a parameter like (name, value, type)

get_fit_output_table_names()

Get the generated result table names in fit function.

Returns
list

List of table names.

get_predict_output_table_names()

Get the generated result table names in predict function.

Returns
list

List of table names.

get_score_output_table_names()

Get the generated result table names in score function.

Returns
list

List of table names.

get_pal_function()

Extract the specific function call of the SAP HANA PAL function from the sql code. Nevertheless it only detects the synonyms that have to be resolved afterwards.

Returns
dict

The procedure name synonym: CALL "SYS_AFL.PAL_RANDOM_FORREST" (...) -> SYS_AFL.PAL_RANDOM_FORREST"

load_model(model)

Function to load the fitted model.

Parameters
modelDataFrame

SAP HANA DataFrame for fitted model.

add_attribute(attr_key, attr_val)

Function to add attribute.

Parameters
attr_keystr

The key.

attr_valstr

The value.

create_apply_func(func_name, data, key=None, model=None, output_table_structure=None, execute=True, force=True)

Create HANA TUDF SQL code.

Parameters
func_namestr

The function name of TUDF.

dataDataFrame

The data to be predicted.

keystr, optional

The key column name in the predict dataframe.

modelDataFrame, optional

The model dataframe for prediction. If not specified, it will use model_.

output_table_structuredict, optional

The return table structure.

executebool, optional

Execute the creation SQL.

Defaults to True.

forcebool, optional

If True, it will drop the existing TUDF.

Returns
str

The generated TUDF SQL code.