| |
Methods defined here:
- __init__(self, object=None, data=None, docid_column=None, word_column=None, count_column=None, out_topicnum='all', out_topicwordnum='none', data_sequence_column=None, object_sequence_column=None)
- DESCRIPTION:
The LDAInference function uses the model teradataml DataFrame
generated by the function LDA to infer the topic distribution
in a set of new documents. You can use the distribution for tasks
such as classification and clustering.
PARAMETERS:
object:
Required Argument.
Specifies the name of the model teradataml DataFrame generated
by the function LDA or instance of LDA, which contains the
model.
data:
Required Argument.
Specifies the name of the teradataml DataFrame that contains
the new documents.
docid_column:
Required Argument.
Specifies the name of the input column that contains the document
identifiers.
Types: str OR list of Strings (str)
word_column:
Required Argument.
Specifies the name of the input column that contains the words (one
word in each row).
Types: str OR list of Strings (str)
count_column:
Optional Argument.
Specifies the name of the input column that contains the count of
the corresponding word in the row, a column of numeric type.
Types: str OR list of Strings (str)
out_topicnum:
Optional Argument.
Specifies the number of top-weighted topics and their weights to
include in the output teradataml DataFrame for each training
document. The value out_topicnum must be a positive int. The value
"all", specifies all topics and their weights.
Default Value: "all"
Types: str
out_topicwordnum:
Optional Argument.
Specifies the number of top topic words and their topic identifiers
to include in the output teradataml DataFrame for each training
document. The value out_topicwordnum must be a positive int. 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: str
data_sequence_column:
Optional Argument.
Specifies the list 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: str OR list of Strings (str)
object_sequence_column:
Optional Argument.
Specifies the list 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: str OR list of Strings (str)
RETURNS:
Instance of LDAInference.
Output teradataml DataFrames can be accessed using attribute
references, such as LDAInferenceObj.<attribute_name>.
Output teradataml DataFrame attribute name is:
1. doc_distribution_data
2. output
RAISES:
TeradataMlException
EXAMPLES:
# Load example data.
load_example_data("LDAInference", ["complaints_testtoken","complaints_traintoken"])
# Create teradataml DataFrame objects.
complaints_testtoken = DataFrame.from_table("complaints_testtoken")
complaints_traintoken = DataFrame.from_table("complaints_traintoken")
# Example 1 - Build a model using LDA and use it's output as direct input to LDAInference
lda_out = LDA(data = complaints_traintoken,
topic_num = 5,
docid_column = "doc_id",
word_column = "token",
count_column = "frequency",
maxiter = 30,
convergence_delta = 1e-3,
seed = 2
)
ldainference_out1 = LDAInference(data=complaints_testtoken,
object=lda_out,
docid_column='doc_id',
word_column='token',
count_column='frequency',
out_topicnum='all',
out_topicwordnum='none',
data_sequence_column='doc_id',
object_sequence_column='topicid'
)
# Print the result teradataml DataFrame
print(ldainference_out1.doc_distribution_data)
print(ldainference_out1.output)
# Example 2 - Use the table by persisting LDA model generarted.
# Persist the model table generated by the LDA function.
copy_to_sql(lda_out.model_table, "model_lda_out")
# Create teradataml DataFrame objects.
model_lda_out = DataFrame.from_table("model_lda_out")
ldainference_out2 = LDAInference(data=complaints_testtoken,
object=model_lda_out,
docid_column='doc_id',
word_column='token',
count_column='frequency',
out_topicnum='all',
out_topicwordnum='none',
data_sequence_column='doc_id',
object_sequence_column='topicid'
)
# Print the result teradataml DataFrame
print(ldainference_out2)
- __repr__(self)
- Returns the string representation for a LDAInference class instance.
- get_build_time(self)
- Function to return the build time of the algorithm in seconds.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
- get_prediction_type(self)
- Function to return the Prediction type of the algorithm.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
- get_target_column(self)
- Function to return the Target Column of the algorithm.
When model object is created using retrieve_model(), then the value returned is
as saved in the Model Catalog.
- show_query(self)
- Function to return the underlying SQL query.
When model object is created using retrieve_model(), then None is returned.
|