td_retrieve_model and td_describe_model Retrieve Arguments | tdplyr - 17.00 - Limitations when td_retrieve_model and td_describe_model Retrieve Certain Arguments - Teradata R Package

Teradata® R Package User Guide

prodname
Teradata R Package
vrm_release
17.00
created_date
November 2020
category
User Guide
featnum
B700-4005-090K

td_retrieve_model() and td_describe_model() may not retrieve certain arguments

The td_retrieve_model() and td_describe_model() functions are unable to retrieve or display values for arguments to the model generating function in the following cases:
  • The order.columns and partition.columns for any model generating function are currently not saved, and not retrieved or displayed.

    For example, if the model generated by td_attribution_mle was saved, the td_retreive_model() or td_describe_model() will not be able to retrieve or display the data.order.column or data.partition.column as it will not be saved.

  • Values are not retrieved for the model generating function that accepts a value for an argument which is alternative to a formula argument.

    For example, when retrieving or describing a td_xgboost_mle model which was generated using the response.column argument instead of the formula argument and then saved, the response.column argument is not retrieved or displayed.

td_retrieve_model() and td_describe_model() may retrieve certain argument values incorrectly

td_retrieve_model() and td_describe_model() may retrieve or display incorrect values for certain attributes.

For example:
  • Arguments of type character may have leading and trailing white spaces trimmed.

    For example, when a model generated by the td_minhash_mle function by passing a space (' ') to the delimiter argument is saved, then describing or retrieving this saved model will retrieve an empty string as the value for the delimiter argument.

  • Arguments accepting vectors but passing a single value may be retrieved or displayed as a vector due to incorrect value parsing.

    For example, if a single value was passed to the comparison.columns argument of the td_string_similarity_mle function and the generated model was saved, then retrieving or describing this saved model will result in incorrect value being retrieved or printed for the comparison.columns argument.

Workaround

To work around this limitation with td_describe_model() not displaying the argument values correctly or not displaying them at all (except with order.columns and partition.columns), you can query the view named TD_ModelCataloging.ModelAlgorithmParametersVX as shown below, replacing the <model_name> with the model name to describe the arguments for.

  • When the model is saved using tdplyr.
    # Get remote data source connection.
    con <- td_get_context()$connection
     
    # When the model was saved using "tdplyr".
    argumentDescription <- tbl(con, sql("SELECT ClientSpecificAttrName as tdplyrAttrName,
                                                CASE
                                                  WHEN AttrValue IS NULL THEN AttrValueC
                                                  ELSE AttrValue
                                                END AS AttrValue
                                         FROM TD_ModelCataloging.ModelAlgorithmParametersVX
                                        WHERE ClientSpecificAttrName IS NOT NULL
                                          AND ClientSpecificAttrName <> '__class_name__'
                                          AND ModelId = (SELECT ModelId FROM TD_ModelCataloging.ModelsVX WHERE Name = '<model_name>')"))
     
    print(argumentDescription)
  • When the model is not saved using tdplyr.
    This example gives the SQL names for arguments instead of tdplyr names, along with their values.
    # Get remote data source connection.
    con <- td_get_context()$connection
     
    # When the model was not saved using "tdplyr".
     
    argumentDescription <- tbl(con, sql("SELECT AttrName as SQLAttrName,
                                                CASE
                                                  WHEN AttrValue IS NULL THEN AttrValueC
                                                  ELSE AttrValue
                                                END AS AttrValue
                                         FROM TD_ModelCataloging.ModelAlgorithmParametersVX
                                        WHERE AttrName IS NOT NULL
                                          AND  AttrName NOT LIKE '__non_%'
                                          AND ModelId = (SELECT ModelId FROM TD_ModelCataloging.ModelsVX WHERE Name = '<model_name>')"))
     
    print(argumentDescription)