Teradata Package for Python Function Reference - NaiveBayesPredict - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.sqle.NaiveBayesPredict = class NaiveBayesPredict(builtins.object)
     Methods defined here:
__init__(self, modeldata=None, newdata=None, id_col=None, responses=None, formula=None, newdata_order_column=None, modeldata_order_column=None)
DESCRIPTION:
    The NaiveBayesPredict function uses the model output generated by the
    NaiveBayes function to predict the outcomes for a test set of data.
 
 
PARAMETERS:
    modeldata:
        Required Argument.
        Specifies the teradataml DataFrame containing the model data
        or instance of NaiveBayes.
 
    modeldata_order_column:
        Optional Argument.
        Specifies Order By columns for modeldata.
        Values to this argument can be provided as a list, if multiple
        columns are used for ordering.
        Types: str OR list of Strings (str)
 
    newdata:
        Required Argument.
        Specifies the teradataml DataFrame containing the input test data.
 
    newdata_order_column:
        Optional Argument.
        Specifies Order By columns for newdata.
        Values to this argument can be provided as a list, if multiple
        columns are used for ordering.
        Types: str OR list of Strings (str)
 
    id_col:
        Required Argument.
        Specifies the name of the column that contains the ID that uniquely
        identifies the test input data.
        Types: str
 
    responses:
        Required Argument.
        Specifies a list of Responses to output.
        Types: str OR list of Strings (str)
 
    formula:
        Optional Argument.
        Required when the modeldata is a teradataml DataFrame.
        A string consisting of "formula".
        Specifies the model to be fitted. Only basic formula of the
        "col1 ~ col2 + col3 +..." form is supported and all variables
        must be from the same virtual data frame object. The response
        should be column of type real, numeric, integer or boolean.
        Types: str
 
RETURNS:
    Instance of NaiveBayesPredict.
    Output teradataml DataFrames can be accessed using attribute
    references, such as NaiveBayesPredictObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load the data to run the example
    load_example_data("NaiveBayesPredict",["nb_iris_input_test","nb_iris_input_train"])
 
    # Create teradataml DataFrame objects.
    nb_iris_input_train = DataFrame.from_table("nb_iris_input_train")
    nb_iris_input_test = DataFrame.from_table("nb_iris_input_test")
 
    # Example 1 -
    # Run the train function
    naivebayes_train = NaiveBayes(formula="species ~ petal_length + sepal_width + petal_width + sepal_length",
                                  data=nb_iris_input_train)
 
    # Generate prediction using output of train function
    naivebayes_predict_result = NaiveBayesPredict(newdata=nb_iris_input_test,
                                                  modeldata = naivebayes_train,
                                                  id_col = "id",
                                                  responses = ["virginica","setosa","versicolor"]
                                                  )
 
    # Print result dataframe
    print(naivebayes_predict_result.result)
__repr__(self)
Returns the string representation for a NaiveBayesPredict 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.