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.mle.NaiveBayesPredict = class NaiveBayesPredict(builtins.object)
     Methods defined here:
__init__(self, formula=None, modeldata=None, newdata=None, id_col=None, output_prob=False, responses=None, terms=None, newdata_sequence_column=None, modeldata_sequence_column=None, newdata_order_column=None, modeldata_order_column=None)
DESCRIPTION:
    The NaiveBayesPredict function uses the model output by the
    NaiveBayes function to predict the outcomes for a test set
    of data.
 
    Note: This function is available only when teradataml is connected to
          Vantage 1.1 or later versions.
 
 
PARAMETERS:
    formula:
        Optional Argument.
        Required when the argument "modeldata" is teradataml DataFrame.
        Specifies a string consisting of "formula" which was used to fit in model data.
        Only basic formula of the "col1 ~ col2 + col3 +..." form is supported and
        all variables must be from the same virtual DataFrame object. The
        response should be column of type real, numeric, integer or boolean.
        Types: str
 
    modeldata:
        Required Argument.
        Specifies the teradataml DataFrame containing the model data.
        This argument can accept teradataml DataFrame or
        instance of NaiveBayes class.
 
    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 that defines 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
 
    output_prob:
        Optional Argument.
        Specifies whether to output probabilities.
        Default Value: False
        Types: bool
 
    responses:
        Optional Argument.
        Specifies a list of responses to output.
        Note: This argument is required when connected to Vantage prior to Vantage 1.1.1.
        Types: str OR list of Strings (str)
 
    terms:
        Optional Argument.
        Specifies the names of input teradataml DataFrame columns to copy to
        the output teradataml DataFrame.
        Types: str OR list of Strings (str)
 
    newdata_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "newdata". 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)
 
    modeldata_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "modeldata". 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 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 -
    # We will try to predict the 'species' for the flowers represented
    # by the data points in the train data (nb_iris_input_train).
    naivebayes_train = NaiveBayes(formula="species ~ petal_length + sepal_width + petal_width + sepal_length",
                                  data=nb_iris_input_train)
 
    # Use the generated model to predict the 'species' on the test data
    # nb_iris_input_test by using naivebayes_train which is already
    # in the sparse format.
    naivebayes_predict_result = NaiveBayesPredict(newdata=nb_iris_input_test,
                                modeldata=naivebayes_train,
                                newdata_sequence_column=['sepal_width','petal_width'],
                                id_col='id',
                                responses=['virginica','setosa','versicolor'],
                                output_prob=False
                                )
 
    # Print the result DataFrame
    print(naivebayes_predict_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.