| |
- GLMPredict(modeldata=None, newdata=None, terms=None, family=None, linkfunction='CANONICAL', output_prob=False, output_responses=None, **generic_arguments)
- DESCRIPTION:
The GLMPredict() function uses the model generated by the function GLM()
to perform generalized linear model prediction on new input data.
PARAMETERS:
modeldata:
Required Argument.
Specifies the teradataml DataFrame containing the model data
generated by GLM() function or an instance of GLM.
Types: teradataml DataFrame or GLM
newdata:
Required Argument.
Specifies the teradataml DataFrame containing the input data.
Types: teradataml DataFrame
terms:
Optional Argument.
Specifies the names of newdata columns to copy to the output
teradataml DataFrame.
Types: str OR list of Strings (str)
family:
Optional Argument.
Specifies the distribution exponential family. The default value is
read from modeldata. If you specify this argument, you must give it
the same value that you used for the Family argument of the function
when you generated the model.
Permitted Values: LOGISTIC, BINOMIAL, POISSON, GAUSSIAN, GAMMA,
INVERSE_GAUSSIAN, NEGATIVE_BINOMIAL
Types: str
linkfunction:
Optional Argument.
The canonical link functions (default link functions) and the link
functions that are allowed for each exponential family.
Note:
Use the same value that you used for the Link argument of the
function when you generated the model.
Default Value: "CANONICAL"
Permitted Values: CANONICAL, IDENTITY, INVERSE, LOG,
COMPLEMENTARY_LOG_LOG, SQUARE_ROOT, INVERSE_MU_SQUARED, LOGIT,
PROBIT, CAUCHIT
Types: str
output_prob:
Optional Argument.
Specifies whether to output probabilities.
Default Value: False
Types: bool
output_responses:
Optional Argument.
Specifies responses for which to output probabilities.
Types: str OR list of strs
**generic_arguments:
Specifies the generic keyword arguments 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 GLMPredict.
Output teradataml DataFrames can be accessed using attribute
references, such as GLMPredictObj.<attribute_name>.
Output teradataml DataFrame attribute name is:
result
RAISES:
TeradataMlException
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("GLMPredict", ["admissions_test","admissions_train"])
# Create teradataml DataFrame objects.
admissions_test = DataFrame.from_table("admissions_test")
admissions_train = DataFrame.from_table("admissions_train")
# Train the data, i.e., create a GLM Model
glm_out = GLM(formula = "admitted ~ stats + masters + gpa + programming",
family = "LOGISTIC",
linkfunction = "LOGIT",
data = admissions_train,
weights = "1",
threshold = 0.01,
maxit = 25,
step = False,
intercept = True)
# Check the list of available analytic functions.
display_analytic_functions()
# Import function GLMPredict.
from teradataml import GLMPredict
# Example 1: Predicting if student is admitted or not with probabilities of
# the both the responses. Response '1' means admitted and '0' means
# not admitted.
obj = teradataml.GLMPredict(modeldata = glm_out,
newdata = admissions_test,
newdata_order_column="id",
modeldata_order_column=["attribute", "predictor"],
family="LOGISTIC",
terms=["id", "masters", "gpa", "stats", "programming", "admitted"],
linkfunction="CANONICAL",
output_prob=True,
output_responses=["1", "0"])
# Print the result DataFrame.
print(obj.result)
|