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

Teradata® Python Package Function Reference

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-07-17
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.