(self, variant)
Send the table description to Qlik as meta data.
        Only used when the SSE is called from the Qlik load script.
Send the table description to Qlik as meta data.
        Only used when the SSE is called from the Qlik load script.
Send the table description to Qlik as meta data . Only used when the SSE is called from the Qlik load script .
def _send_table_description(self, variant):
        """
        Send the table description to Qlik as meta data.
        Only used when the SSE is called from the Qlik load script.
        """
        
        # Set up the table description to send as metadata to Qlik
        self.table = SSE.TableDescription()
        self.table.name = "SSE-Response"
        self.table.numberOfRows = len(self.response)

        # Set up fields for the table
        if variant == "setup":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="result")
            self.table.fields.add(name="timestamp")
        elif variant == "features":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="sort_order", dataType=1)
            self.table.fields.add(name="feature")
            self.table.fields.add(name="var_type")
            self.table.fields.add(name="data_type")
            self.table.fields.add(name="strategy")
            self.table.fields.add(name="strategy_args")
        elif variant == "fit":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="result")
            self.table.fields.add(name="time_stamp")
            self.table.fields.add(name="score_result")
            self.table.fields.add(name="score", dataType=1)
        elif variant == "metrics_clf":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="class")
            self.table.fields.add(name="accuracy", dataType=1)
            self.table.fields.add(name="precision", dataType=1)
            self.table.fields.add(name="recall", dataType=1)
            self.table.fields.add(name="fscore", dataType=1)
            self.table.fields.add(name="support", dataType=1)
        elif variant == "metrics_clf_cv":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="class")
            self.table.fields.add(name="accuracy", dataType=1)
            self.table.fields.add(name="accuracy_std", dataType=1)
            self.table.fields.add(name="precision", dataType=1)
            self.table.fields.add(name="precision_std", dataType=1)
            self.table.fields.add(name="recall", dataType=1)
            self.table.fields.add(name="recall_std", dataType=1)
            self.table.fields.add(name="fscore", dataType=1)
            self.table.fields.add(name="fscore_std", dataType=1)
        elif variant == "metrics_reg":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="r2_score", dataType=1)
            self.table.fields.add(name="mean_squared_error", dataType=1)
            self.table.fields.add(name="mean_absolute_error", dataType=1)
            self.table.fields.add(name="median_absolute_error", dataType=1)
            self.table.fields.add(name="explained_variance_score", dataType=1)
        elif variant == "metrics_reg_cv":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="r2_score", dataType=1)
            self.table.fields.add(name="r2_score_std", dataType=1)
            self.table.fields.add(name="mean_squared_error", dataType=1)
            self.table.fields.add(name="mean_squared_error_std", dataType=1)
            self.table.fields.add(name="mean_absolute_error", dataType=1)
            self.table.fields.add(name="mean_absolute_error_std", dataType=1)
            self.table.fields.add(name="median_absolute_error", dataType=1)
            self.table.fields.add(name="median_absolute_error_std", dataType=1)
            self.table.fields.add(name="explained_variance_score", dataType=1)
            self.table.fields.add(name="explained_variance_score_std", dataType=1)
        elif variant == "confusion_matrix":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="true_label")
            self.table.fields.add(name="pred_label")
            self.table.fields.add(name="count", dataType=1)
        elif variant == "confusion_matrix_multi":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="step", dataType=1)
            self.table.fields.add(name="true_negative", dataType=1)
            self.table.fields.add(name="false_positive", dataType=1)
            self.table.fields.add(name="false_negative", dataType=1)
            self.table.fields.add(name="true_positive", dataType=1)
        elif variant == "importances":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="feature_name")
            self.table.fields.add(name="importance", dataType=1)
        elif variant == "predict":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="key")
            self.table.fields.add(name="prediction")
        elif variant == "expression":
            self.table.fields.add(name="result")
        elif variant == "best_params":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="best_params")
        elif variant == "cluster":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="key")
            self.table.fields.add(name="label")
        elif variant == "reduce":
            self.table.fields.add(name="model_name")
            self.table.fields.add(name="key")
            # Add a variable number of columns depending on the response
            for i in range(self.response.shape[1]-2):
                self.table.fields.add(name="dim_{0}".format(i+1), dataType=1)
        elif variant == "keras_history":
            self.table.fields.add(name="model_name")
            # Add columns from the Keras model's history
            for i in range(1, self.response.shape[1]):
                self.table.fields.add(name=self.response.columns[i], dataType=1)
        
        # Debug information is printed to the terminal and logs if the paramater debug = true
        if self.model.debug:
            self._print_log(5)
            
        # Send table description
        table_header = (('qlik-tabledescription-bin', self.table.SerializeToString()),)
        self.context.send_initial_metadata(table_header)
def _send_table_description ( self , variant ) : # Set up the table description to send as metadata to Qlik self . table = SSE . TableDescription ( ) self . table . name = "SSE-Response" self . table . numberOfRows = len ( self . response ) # Set up fields for the table if variant == "setup" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "result" ) self . table . fields . add ( name = "timestamp" ) elif variant == "features" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "sort_order" , dataType = 1 ) self . table . fields . add ( name = "feature" ) self . table . fields . add ( name = "var_type" ) self . table . fields . add ( name = "data_type" ) self . table . fields . add ( name = "strategy" ) self . table . fields . add ( name = "strategy_args" ) elif variant == "fit" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "result" ) self . table . fields . add ( name = "time_stamp" ) self . table . fields . add ( name = "score_result" ) self . table . fields . add ( name = "score" , dataType = 1 ) elif variant == "metrics_clf" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "class" ) self . table . fields . add ( name = "accuracy" , dataType = 1 ) self . table . fields . add ( name = "precision" , dataType = 1 ) self . table . fields . add ( name = "recall" , dataType = 1 ) self . table . fields . add ( name = "fscore" , dataType = 1 ) self . table . fields . add ( name = "support" , dataType = 1 ) elif variant == "metrics_clf_cv" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "class" ) self . table . fields . add ( name = "accuracy" , dataType = 1 ) self . table . fields . add ( name = "accuracy_std" , dataType = 1 ) self . table . fields . add ( name = "precision" , dataType = 1 ) self . table . fields . add ( name = "precision_std" , dataType = 1 ) self . table . fields . add ( name = "recall" , dataType = 1 ) self . table . fields . add ( name = "recall_std" , dataType = 1 ) self . table . fields . add ( name = "fscore" , dataType = 1 ) self . table . fields . add ( name = "fscore_std" , dataType = 1 ) elif variant == "metrics_reg" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "r2_score" , dataType = 1 ) self . table . fields . add ( name = "mean_squared_error" , dataType = 1 ) self . table . fields . add ( name = "mean_absolute_error" , dataType = 1 ) self . table . fields . add ( name = "median_absolute_error" , dataType = 1 ) self . table . fields . add ( name = "explained_variance_score" , dataType = 1 ) elif variant == "metrics_reg_cv" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "r2_score" , dataType = 1 ) self . table . fields . add ( name = "r2_score_std" , dataType = 1 ) self . table . fields . add ( name = "mean_squared_error" , dataType = 1 ) self . table . fields . add ( name = "mean_squared_error_std" , dataType = 1 ) self . table . fields . add ( name = "mean_absolute_error" , dataType = 1 ) self . table . fields . add ( name = "mean_absolute_error_std" , dataType = 1 ) self . table . fields . add ( name = "median_absolute_error" , dataType = 1 ) self . table . fields . add ( name = "median_absolute_error_std" , dataType = 1 ) self . table . fields . add ( name = "explained_variance_score" , dataType = 1 ) self . table . fields . add ( name = "explained_variance_score_std" , dataType = 1 ) elif variant == "confusion_matrix" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "true_label" ) self . table . fields . add ( name = "pred_label" ) self . table . fields . add ( name = "count" , dataType = 1 ) elif variant == "confusion_matrix_multi" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "step" , dataType = 1 ) self . table . fields . add ( name = "true_negative" , dataType = 1 ) self . table . fields . add ( name = "false_positive" , dataType = 1 ) self . table . fields . add ( name = "false_negative" , dataType = 1 ) self . table . fields . add ( name = "true_positive" , dataType = 1 ) elif variant == "importances" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "feature_name" ) self . table . fields . add ( name = "importance" , dataType = 1 ) elif variant == "predict" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "key" ) self . table . fields . add ( name = "prediction" ) elif variant == "expression" : self . table . fields . add ( name = "result" ) elif variant == "best_params" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "best_params" ) elif variant == "cluster" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "key" ) self . table . fields . add ( name = "label" ) elif variant == "reduce" : self . table . fields . add ( name = "model_name" ) self . table . fields . add ( name = "key" ) # Add a variable number of columns depending on the response for i in range ( self . response . shape [ 1 ] - 2 ) : self . table . fields . add ( name = "dim_{0}" . format ( i + 1 ) , dataType = 1 ) elif variant == "keras_history" : self . table . fields . add ( name = "model_name" ) # Add columns from the Keras model's history for i in range ( 1 , self . response . shape [ 1 ] ) : self . table . fields . add ( name = self . response . columns [ i ] , dataType = 1 ) # Debug information is printed to the terminal and logs if the paramater debug = true if self . model . debug : self . _print_log ( 5 ) # Send table description table_header = ( ( 'qlik-tabledescription-bin' , self . table . SerializeToString ( ) ) , ) self . context . send_initial_metadata ( table_header )