Teradata Package for Python Function Reference - CoxSurvival - 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.CoxSurvival = class CoxSurvival(builtins.object)
     Methods defined here:
__init__(self, object=None, cox_model_table=None, predict_table=None, predict_feature_names=None, predict_feature_columns=None, accumulate=None, cox_model_table_sequence_column=None, object_sequence_column=None, predict_table_sequence_column=None)
DESCRIPTION:
    The CoxSurvival function takes as input the coefficient and linear
    prediction tables generated by the function CoxPH and outputs a
    teradataml DataFrame of survival probabilities.
 
 
PARAMETERS:
    object:
        Required Argument.
        Specifies the teradataml DataFrame of the Cox coefficient model, which was
        output by the CoxPH function or instance of CoxPH.
 
    cox_model_table:
        Required Argument.
        Specifies the teradataml DataFrame of the Cox linear predictor model, which was
        output by the CoxPH function.
 
    predict_table:
        Required Argument.
        Specifies the teradataml DataFrame, which contains new
        prediction feature values for survival calculation.
 
    predict_feature_names:
        Required Argument.
        Specifies the names of features in the Cox model.
        Types: str OR list of Strings (str)
 
    predict_feature_columns:
        Required Argument.
        Specifies the names of the columns that contain the values for the
        features in the Cox model—one column name for each feature name. The
        ith feature name corresponds to the ith column name. For example,
        consider this pair of arguments: predict.feature.names("name",
        "age"), predict.feature.columns("c1", "c2") The predictive values of
        the feature "name" are in column "c1", and the predictive values of
        the feature "age" are in column "c2".
        Types: str OR list of Strings (str)
 
    accumulate:
        Optional Argument.
        Specifies the names of the columns in predict_table that the function
        copies to the output table.
        Types: str OR list of Strings (str)
 
    cox_model_table_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "cox_model_table". 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)
 
    object_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "object". 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)
 
    predict_table_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "predict_table". 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 CoxSurvival.
    Output teradataml DataFrames can be accessed using attribute
    references, such as CoxSurvivalObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        1. output
        2. survival_probability
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load the data to run the example.
    load_example_data("coxsurvival", ["lc_new_predictors", "lungcancer"])
 
    # Create teradataml DataFrame objects.
    lungcancer = DataFrame.from_table("lungcancer")
    lc_new_predictors = DataFrame.from_table("lc_new_predictors")
 
    # Generate CoxPH model object.
    coxph_out = CoxPH(data = lungcancer,
                      feature_columns = ["trt","celltype","karno","diagtime","age","prior"],
                      time_interval_column = "time_int",
                      event_column = "status",
                      categorical_columns = ["trt","celltype","prior"])
 
    # linear model predictor table and coefficient table that are generated from the td_coxph function
    # are used to determine the survival probabilities of the new patients.
    # Example 1 - Pass generated coefficient table and linear predictor dataframes
    cox_survival_out = CoxSurvival(object = coxph_out.coefficient_table,
                                   cox_model_table = coxph_out.linear_predictor_table,
                                   predict_table = lc_new_predictors,
                                   predict_feature_names = ["trt", "celltype","karno","diagtime","age","prior"],
                                   predict_feature_columns = ["trt","celltype","karno","diagtime","age", "prior"],
                                   accumulate = ["id", "name"])
 
    # Print the results.
    print(cox_survival_out.output)
    print(cox_survival_out.survival_probability)
 
    # Example 2 - Pass output of coxph_out directly as object argument.
    cox_survival_out = CoxSurvival(object = coxph_out,
                                   cox_model_table = coxph_out.linear_predictor_table,
                                   predict_table = lc_new_predictors,
                                   predict_feature_names = ["trt", "celltype","karno","diagtime","age","prior"],
                                   predict_feature_columns = ["trt","celltype","karno","diagtime","age", "prior"],
                                   accumulate = ["id", "name"])
 
    # Print the results.
    print(cox_survival_out.output)
    print(cox_survival_out.survival_probability)
__repr__(self)
Returns the string representation for a CoxSurvival 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.