| |
- NaiveBayesPredict(modeldata=None, newdata=None, id_col=None, responses=None, formula=None, **generic_arguments)
- DESCRIPTION:
NaiveBayesPredict() function predicts the outcomes for a test set of data
using the model output generated by the NaiveBayes() function.
PARAMETERS:
modeldata:
Required Argument.
Specifies the teradataml DataFrame which contains the model
data generated by the NaiveBayes() function or instance of NaiveBayes.
Types: teradataml DataFrame or NaiveBayes
newdata:
Required Argument.
Specifies the input teradataml DataFrame.
Types: teradataml DataFrame
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
**generic_arguments:
Specifies the generic keyword arguments which SQLE functions accept.
Below are the generic keyword arguments:
persist:
Optional Argument.
Specifies whether to persist the results of the function in table or not.
When set to True, results are persisted in table; otherwise, results
are garbage collected at the end of the session.
Default Value: False
Types: boolean
volatile:
Optional Argument.
Specifies whether to put the results of the function in volatile table or not.
When set to True, results are stored in volatile table, otherwise not.
Default Value: False
Types: boolean
Function allows the user to partition, hash, order or local order the input
data. These generic arguments are available for each argument that accepts
teradataml DataFrame as input and can be accessed as:
* "<input_data_arg_name>_partition_column" accepts str or list of str (Strings)
* "<input_data_arg_name>_hash_column" accepts str or list of str (Strings)
* "<input_data_arg_name>_order_column" accepts str or list of str (Strings)
* "local_order_<input_data_arg_name>" accepts boolean
Note:
These generic arguments are supported by teradataml if the underlying SQLE Engine
function supports, else an exception is raised.
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, TypeError, ValueError
EXAMPLES:
# Notes:
# 1. Get the connection to Vantage, before importing the function in user space.
# 2. User can import the function, if it is available on the Vantage user is connected to.
# 3. To check the list of analytic functions available on the Vantage user connected to,
# use "display_analytic_functions()"
# Load the data to run the example.
load_example_data("teradataml", ["nb_iris_input_test", "nbp_iris_model"])
# Create teradataml DataFrame objects.
nb_iris_input_test = DataFrame.from_table("nb_iris_input_test")
nbp_iris_model = DataFrame.from_table("nbp_iris_model")
# Check the list of available analytic functions.
display_analytic_functions()
# Import function NaiveBayesPredict.
from teradataml import NaiveBayesPredict
# Example 1: Predict the 'species' on the test data nb_iris_input_test
# using the NaiveBayes model nbp_iris_model.
naive_bayes_predict = teradataml.NaiveBayesPredict(newdata=nb_iris_input_test,
modeldata=nbp_iris_model,
id_col="id",
responses=["virginica", "setosa", "versicolor"],
formula="species ~ petal_length + sepal_width + petal_width + sepal_length"
)
# Print the result DataFrame.
print(naive_bayes_predict.result)
|