| |
Methods defined here:
- __init__(self, modeldata=None, newdata=None, terms=None, family=None, linkfunction='CANONICAL', output_response_probdist=False, output_responses=None, newdata_sequence_column=None, modeldata_sequence_column=None, newdata_order_column=None, modeldata_order_column=None)
- DESCRIPTION:
The GLMPredict function uses the model generated by the function GLM
to perform generalized linear model prediction on new input data.
Note: This function is available only when teradataml is connected to
Vantage 1.1 or later versions.
PARAMETERS:
modeldata:
Required Argument.
Specifies the teradataml DataFrame containing the model data.
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 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)
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)
family:
Optional Argument.
Specifies the distribution exponential family. The default value is
read from model teradataml DataFrame. 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 teradataml DataFrame.
Permitted Values: LOGISTIC, BINOMIAL, POISSON, GAUSSIAN, GAMMA,
INVERSE_GAUSSIAN, NEGATIVE_BINOMIAL
Types: str
linkfunction:
Optional Argument.
Specifies the canonical 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 teradataml DataFrame.
Default Value: "CANONICAL"
Permitted Values: CANONICAL, IDENTITY, INVERSE, LOG,
COMPLEMENTARY_LOG_LOG, SQUARE_ROOT, INVERSE_MU_SQUARED, LOGIT,
PROBIT, CAUCHIT
Types: str
output_response_probdist:
Optional Argument.
Specifies whether to output probabilities.
Note: "output_response_probdist" argument support is only available
when teradataml is connected to Vantage 1.1.1 or later.
Default Value: False
Types: bool
output_responses:
Optional Argument.
Specifies responses to output probability.
This argument can only be used when output_response_probdist is set to TRUE.
Note: "output_responses" argument support is only available when
teradataml is connected to Vantage 1.1.1 or later.
Permitted Values: 0, 1
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 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:
# Load the data to run the example.
load_example_data("GLMPredict", ["admissions_test","admissions_train","housing_test","housing_train"])
# Create teradataml DataFrame objects.
admissions_test = DataFrame.from_table("admissions_test")
admissions_train = DataFrame.from_table("admissions_train")
housing_test = DataFrame.from_table("housing_test")
housing_train = DataFrame.from_table("housing_train")
# Example 1 -
# Generate a model based on train data "admissions_train"
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
)
# Use the generated model to predict the 'admissions' on the test data
# admissions_test by using generated model by GLM.
glm_predict_out1 = GLMPredict(modeldata = glm_out,
newdata = admissions_test,
terms = ["id","masters","gpa","stats","programming","admitted"],
family = "LOGISTIC",
linkfunction = "LOGIT",
output_response_probdist=True
)
# Print the result DataFrame.
print(glm_predict_out1.result)
# Example 2 - Generate a model based on train data "housing_train"
glm_out_hs = GLM(formula = "price ~ recroom + lotsize + stories + garagepl + gashw + bedrooms + driveway + airco + homestyle + bathrms + fullbase + prefarea",
family = "GAUSSIAN",
linkfunction = "IDENTITY",
data = housing_train,
weights = "1",
threshold = 0.01,
maxit = 25,
step = False,
intercept = True
)
# Use the generated model to predict the 'price' on the test data
# housing_test by using generated model by GLM.
glm_predict_out2 = GLMPredict(modeldata = glm_out_hs.coefficients,
newdata = housing_test,
terms = ["sn", "price"],
family = "GAUSSIAN",
linkfunction = "CANONICAL"
)
# Print the result DataFrame.
print(glm_predict_out2)
- __repr__(self)
- Returns the string representation for a GLMPredict class instance.
|