(self)
return self.response
Get a string that can be evaluated in Qlik to get the features portion of the predict function
Get a string that can be evaluated in Qlik to get the features portion of the predict function
Get a string that can be evaluated in Qlik to get the features portion of the predict function
def get_features_expression(self):
        """
        Get a string that can be evaluated in Qlik to get the features portion of the predict function
        """
        
        # Get the model from cache or disk based on the model_name in request
        self._get_model_by_name()
        
        # Prepare the expression as a string
        delimiter = " &'|'& "

        # Get the complete feature definitions for this model
        features_df = self.model.original_features_df.copy()
    
        # Set features that are not expected in the features expression in Qlik
        exclude = ["excluded"]

        if not self.model.lag_target:
            exclude.append("target")
        if not self.model.lags:
            exclude.append("identifier")

        # Exclude columns that are not expected in the request data
        exclusions = features_df['variable_type'].isin(exclude)
        features_df = features_df.loc[~exclusions]
    
        # Get the feature names
        features = features_df["name"].tolist()
        
        # Prepare a string which can be evaluated to an expression in Qlik with features as field names
        self.response = pd.Series(delimiter.join(["[" + f + "]" for f in features]))
        
        # Send the reponse table description to Qlik
        self._send_table_description("expression")
        
        # Debug information is printed to the terminal and logs if the paramater debug = true
        if self.model.debug:
            self._print_log(4)
        
        # Finally send the response
        return self.response
def get_features_expression ( self ) : # Get the model from cache or disk based on the model_name in request self . _get_model_by_name ( ) # Prepare the expression as a string delimiter = " &'|'& " # Get the complete feature definitions for this model features_df = self . model . original_features_df . copy ( ) # Set features that are not expected in the features expression in Qlik exclude = [ "excluded" ] if not self . model . lag_target : exclude . append ( "target" ) if not self . model . lags : exclude . append ( "identifier" ) # Exclude columns that are not expected in the request data exclusions = features_df [ 'variable_type' ] . isin ( exclude ) features_df = features_df . loc [ ~ exclusions ] # Get the feature names features = features_df [ "name" ] . tolist ( ) # Prepare a string which can be evaluated to an expression in Qlik with features as field names self . response = pd . Series ( delimiter . join ( [ "[" + f + "]" for f in features ] ) ) # Send the reponse table description to Qlik self . _send_table_description ( "expression" ) # Debug information is printed to the terminal and logs if the paramater debug = true if self . model . debug : self . _print_log ( 4 ) # Finally send the response return self . response