Teradata R Package Function Reference | 17.00 - 17.00 - LDA - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
17.00
created_date
September 2020
category
Programming Reference
featnum
B700-4007-090K

Description

The LDATrainer function uses training data and parameters to build a topic model, using an unsupervised method to estimate the correlation between the topics and words according to the topic number and other parameters. Optionally, the function generates the topic distributions for each training document.

Usage

  td_lda_mle (
      data = NULL,
      topic.num = NULL,
      docid.column = NULL,
      word.column = NULL,
      alpha = 0.1,
      eta = 0.1,
      count.column = NULL,
      maxiter = 50,
      convergence.delta = 1.0E-4,
      seed = NULL,
      out.topicnum = "all",
      out.topicwordnum = "none",
      initmodeltaskcount = NULL,
      data.sequence.column = NULL
  )

Arguments

data

Required Argument.
Specifies the tbl_teradata that contains the new documents.

topic.num

Required Argument.
Specifies the number of topics for all the documents in the input table, an integer value in the range [2, 1000], both lower and upper bounds inclusive.
Types: integer

docid.column

Required Argument.
Specifies the name of the input column that contains the document identifiers.
Types: character

word.column

Required Argument.
Specifies the name of the input column that contains the words (one word in each row).
Types: character

alpha

Optional Argument.
Specifies a hyperparameter of the model, the prior smooth parameter for the topic distribution over documents. As "alpha" decreases, fewer topics are associated with each document.
Default Value: 0.1
Types: numeric

eta

Optional Argument.
Specifies a hyperparameter of the model, the prior smooth parameter for the word distribution over topics. As "eta" decreases, fewer words are associated with each topic.
Default Value: 0.1
Types: numeric

count.column

Optional Argument.
Specifies the name of the input column that contains the count of the corresponding word in the row.
Types: character

maxiter

Optional Argument.
Specifies the maximum number of iterations to perform if the model does not converge, a positive integer value.
Default Value: 50
Types: integer

convergence.delta

Optional Argument.
Specifies the convergence delta of log perplexity, a NUMERIC value in the range (0.0, 1.0), both lower and upper bounds exclusive.
Default Value: 1.0E-4
Types: numeric

seed

Optional Argument.
Specifies the seed with which to initialize the model, a numeric value. Given the same seed, cluster configuration, and input tbl_teradata, the function generates the same model. By default, the function initializes the model randomly.
Types: numeric

out.topicnum

Specifies the number of top-weighted topics and their weights to include in the output tbl_teradata for each training document. The value "out.topicnum" must be a positive integer enclosed in quotes or "all".
The value "all" specifies all topics and their weights.
Default Value: "all"
Types: character

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 "out.topicwordnum" must be a positive integer enclosed in quotes or "all" or "none".
The value "all" specifies all topic words and their topic identifiers.
The value "none" specifies no topic words or topic identifiers.
Default Value: "none"
Types: character

initmodeltaskcount

Optional Argument.
Specifies the number of vWorkers that are adopted to generate initalized model. It must be a positive integer value.
By default, all the available vWorkers are used to initialize the model.
Note: This argument is supported when tdplyr is connected to Vantage 1.1.1 or later versions.
Types: integer

data.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "data". 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_mle" which is a named list containing objects of class "tbl_teradata".
Named list members can be referenced directly with the "$" operator using following names:

  1. model.table

  2. doc.distribution.data

  3. output

.

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("lda_example", "complaints_traintoken")
    
    # Create object(s) of class "tbl_teradata".
    complaints_traintoken <- tbl(con, "complaints_traintoken")
    
    # Example 1 - This function uses training data and parameters from 'complaints_traintoken'
    # tbl_teradata to build a topic model.
    td_lda_out <- td_lda_mle(data = complaints_traintoken,
                             topic.num = 5,
                             docid.column = "doc_id",
                             word.column = "token",
                             count.column = "frequency",
                             maxiter = 30,
                             convergence.delta = 1e-3,
                             seed = 2
                            )