(request, context)
Execute functions that provide common data science capabilities for Qlik.
        :param request: an iterable sequence of RowData
        :param context:
        :return: Refer to comments below as the response depends on the function called
Execute functions that provide common data science capabilities for Qlik.
        :param request: an iterable sequence of RowData
        :param context:
        :return: Refer to comments below as the response depends on the function called
Execute functions that provide common data science capabilities for Qlik . : param request : an iterable sequence of RowData : param context : : return : Refer to comments below as the response depends on the function called
def _misc(request, context):
        """
        Execute functions that provide common data science capabilities for Qlik.
        :param request: an iterable sequence of RowData
        :param context:
        :return: Refer to comments below as the response depends on the function called
        """
        # Get a list from the generator object so that it can be iterated over multiple times
        request_list = [request_rows for request_rows in request]
        
        # Get the function id from the header to determine the variant being called
        function = ExtensionService._get_function_id(context)
        
        # Create an instance of the CommonFunction class
        handle = CommonFunction(request_list, context)
        
        # Call the function based on the mapping in functions.json
        # The if conditions are grouped based on similar output structure
        if function == 33:    
            # Get entities from the default model
            response = handle.association_rules()
            # return six columns: 'rule', 'rule_lhs', 'rule_rhs', 'support', 'confidence', 'lift'
            dtypes = ["str", "str", "str", "num", "num", "num"]
        elif function == 43:
            # Provide predictions in a chart expression based on an existing model
            response = handle.predict(load_script=False)
            # Return predictions
            dtypes = ["str"]
        elif function == 44:
            # Provide predictions in the load script based on an existing model
            response = handle.predict(load_script=True)
            # Return the model name, keys and predictions
            dtypes = ["str", "str", "str"]
        elif function == 45:
            # Get a string that can be evaluated to get the features expression for the predict function
            response = handle.get_features_expression()
            # Return the feature expression
            dtypes = ["str"]

        # Get the response as SSE.Rows
        response_rows = utils.get_response_rows(response.values.tolist(), dtypes) 

        # Get the number of bundles in the request
        num_request_bundles = len(request_list)

        # Get the number of rows in the response
        num_rows = len(response_rows) 

        # Calculate the number of rows to send per bundle
        if num_rows >= num_request_bundles:
            rows_per_bundle = num_rows//num_request_bundles
        else:
            rows_per_bundle = num_rows

        # Stream response as BundledRows
        for i in range(0, num_rows, rows_per_bundle):
            # Yield Row data as Bundled rows
            yield SSE.BundledRows(rows=response_rows[i : i + rows_per_bundle])
def _misc ( request , context ) : # Get a list from the generator object so that it can be iterated over multiple times request_list = [ request_rows for request_rows in request ] # Get the function id from the header to determine the variant being called function = ExtensionService . _get_function_id ( context ) # Create an instance of the CommonFunction class handle = CommonFunction ( request_list , context ) # Call the function based on the mapping in functions.json # The if conditions are grouped based on similar output structure if function == 33 : # Get entities from the default model response = handle . association_rules ( ) # return six columns: 'rule', 'rule_lhs', 'rule_rhs', 'support', 'confidence', 'lift' dtypes = [ "str" , "str" , "str" , "num" , "num" , "num" ] elif function == 43 : # Provide predictions in a chart expression based on an existing model response = handle . predict ( load_script = False ) # Return predictions dtypes = [ "str" ] elif function == 44 : # Provide predictions in the load script based on an existing model response = handle . predict ( load_script = True ) # Return the model name, keys and predictions dtypes = [ "str" , "str" , "str" ] elif function == 45 : # Get a string that can be evaluated to get the features expression for the predict function response = handle . get_features_expression ( ) # Return the feature expression dtypes = [ "str" ] # Get the response as SSE.Rows response_rows = utils . get_response_rows ( response . values . tolist ( ) , dtypes ) # Get the number of bundles in the request num_request_bundles = len ( request_list ) # Get the number of rows in the response num_rows = len ( response_rows ) # Calculate the number of rows to send per bundle if num_rows >= num_request_bundles : rows_per_bundle = num_rows // num_request_bundles else : rows_per_bundle = num_rows # Stream response as BundledRows for i in range ( 0 , num_rows , rows_per_bundle ) : # Yield Row data as Bundled rows yield SSE . BundledRows ( rows = response_rows [ i : i + rows_per_bundle ] )