Teradata R Package Function Reference - 16.20 - LDATopicSummary - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
16.20
created_date
February 2020
category
Programming Reference
featnum
B700-4007-098K

Description

The td_lda_topic_summary_mle function displays readable information from the binary model tbl_teradata generated by the Latent Dirichlet Allocation (LDA) function td_lda_mle.

Usage

  td_lda_topic_summary_mle (
      object = NULL,
      summary = FALSE,
      out.topicwordnum = "all",
      word.weight = FALSE,
      word.count = FALSE,
      out.byword = TRUE,
      object.sequence.column = NULL,
      object.order.column = NULL
  )

Arguments

object

Required Argument.
Specifies the td_lda_mle model table.

object.order.column

Optional Argument.
Specifies the order By columns for object.
Values to this argument can be provided as vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character).

summary

Optional Argument.
Specifies whether to display only a summary of the information in the model table.
Default Value: FALSE.
Types: logical.

out.topicwordnum

Optional Argument.
Specifies the number of top topic words and their topic identifiers to include in the output tbl_teradata for each training document. The value of out.topicwordnum must be either a positive integer value in quotes or the string "all". The default value, "all", specifies all topic words and their topic identifiers.
Types: character.

word.weight

Optional Argument.
Specifies whether to display the weight (probability of occurrence) of each unique word in each topic. The weights for the unique words in each topic are normalized to 1.
Default Value: FALSE.
Types: logical.

word.count

Optional Argument.
Specifies whether to display the count (number of occurrences) of each unique word in each topic. Topic distribution is factored into word counts.
Default Value: FALSE.
Types: logical.

out.byword

Optional Argument.
Specifies whether to display each topic-word pair in its own row. If you specify "false", each row contains a unique topic and all words that occur in that topic, separated by commas.
Default Value: TRUE.
Types: logical.

object.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "object". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character).

Value

Function returns an object of class "td_lda_topic_summary_mle" which is a named list containing Teradata tbl object.
Named list member can be referenced directly with the "$" operator using name: result.

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("lda_example","complaints_traintoken")
    
    # Create remote tibble objects.
    complaints_traintoken <- tbl(con, "complaints_traintoken")
    
    # Example 1 - This function td_lda_topic_summary_mle uses the model table from td_lda_mle to display only a summary      
    # of the information in the model table 
    td_lda_out <- td_lda_mle(data=complaints_traintoken,
                             docid.column='doc_id',
                             word.column='token',
                             topic.num=3,
                             alpha=0.1,
                             eta=0.1,
                             maxiter=50,
                             convergence.delta=0.0001,
                             seed=2,
                             out.topicnum='all',
                             out.topicwordnum='none'
                            )
    td_lda_topic_summary_mle_out <- td_lda_topic_summary_mle(object = td_lda_out,
                                                             summary = TRUE)
    
    # Example 2 - This function td_lda_topic_summary_mle uses to display all topic words and their topic identifiers
    # with each row contains a unique topic and all words that occur in that topic, separated by commas.
    td_lda_topic_summary_mle_out <- td_lda_topic_summary_mle(object = td_lda_out,
                                                             out.topicwordnum = 'all',
                                                             out.byword = TRUE
                                                             )
    
    # Example 3 - This function td_lda_topic_summary_mle uses to display each topic-word pair with wordweight, wordcount,
    # each topic-word pair in its own row.
    td_lda_topic_summary_mle_out <- td_lda_topic_summary_mle(object = td_lda_out,
                                                             word.weight = TRUE,
                                                             word.count = TRUE,
                                                             out.byword = TRUE
                                                             )