#NEWLINE# def label_test_documents( self , testTable , outputTable , dictTable = None , modelTable = None , numTopics = None , alpha = None , eta = None ) : #NEWLINE# #INDENT# "\n               Invoke MADlib's PLDA algorithm\n               Inputs:\n               =======\n               testTable = (String) the table containing the documents on which the LDA model has to predict topics\n               dictTable = (String) table containing a dictionary of all tokens in the documents\n               modelTable = (String) table to store the LDA model params in.\n               outputTable = (String) table to store the results of the LDA model\n               numTopics = (int) number of topics in the document (default : the value used in building the LDA model)       \n               alpha = (float) the dirichlet prior Alpha (default: value used in building the LDA model - in the infer() method)\n               eta = (float) eta (default: value used in building the LDA model - in the infer() method)\n               \n               Outputs:\n               ========\n               Returns a row set of the form || id | contents | topics || from the outputTable \n            " #NEWLINE# dictTable = ( self . model [ 'dictTable' ] if ( not dictTable ) else alpha ) #NEWLINE# modelTable = ( self . model [ 'modelTable' ] if ( not modelTable ) else modelTable ) #NEWLINE# numTopics = ( self . model [ 'numTopics' ] if ( not numTopics ) else numTopics ) #NEWLINE# alpha = ( self . model [ 'alpha' ] if ( not alpha ) else alpha ) #NEWLINE# eta = ( self . model [ 'eta' ] if ( not eta ) else eta ) #NEWLINE# stmt = "\n                      select {madlib_schema}.plda_label_test_documents('{testTable}', '{outputTable}', '{modelTable}', '{dictTable}',\n                               {numTopics}, {alpha}, {eta});\n                   " . format ( testTable = testTable , outputTable = outputTable , modelTable = modelTable , dictTable = dictTable , numTopics = numTopics , alpha = alpha , eta = eta , madlib_schema = self . dbconn . madlib_schema ) #NEWLINE# self . dbconn . executeQuery ( stmt ) #NEWLINE# stmt = '\n                      select id, contents, topics from {outputTable};\n                   ' . format ( outputTable = outputTable ) #NEWLINE# cursor = self . dbconn . getCursor ( ) #NEWLINE# cursor . execute ( stmt ) #NEWLINE# result_set = [ row for row in cursor ] #NEWLINE# cursor . close ( ) #NEWLINE# return result_set