| |
- XmlToHtmlReport(data, analysis_type, filter=None, gen_sql_only=False)
- DESCRIPTION:
Several Analytic Algorithms and Scoring functions output columns of XML.
This function transforms the XML to HTML, which is easier to view.
Function outputs the HTML in a column of type Teradata XML. You can copy
the HTML into a text file, give the text file a name ending in ".html",
and view it in a browser.
Alternatively, you can view the HTML in a Jupyter notebook by
double-clicking the cell that contains HTML to display it in web view.
Note:
This function is available in Vantage Analytic Library 2.0.0.3 or
later.
PARAMETERS:
data:
Required Argument.
Specifies the input data to run statistical tests.
Types: teradataml DataFrame
analysis_type:
Required Argument.
Specifies the class name of the function or a SQL function name
whose XML you want the function to translate to HTML.
Function outputs different reports in HTML format depending on
the values passed to the argument.
Permitted Values:
* "decisiontree", "DecisionTree".
Outputs HTML reports for:
* Decision Tree Summary.
* Variables.
* Text Tree.
* "decisiontreescore", "DecisionTreeEvaluator".
Outputs HTMl reports for:
* Decision Tree Scoring Summary—Confusion Matrix.
* "factor", "PCA".
Outputs HTMl reports for:
* Factor Analysis Summary.
* Variable Statistics.
* Eigenvalues.
* PCLoadings.
* Variance and Absolute Difference.
* Near Dependency Report.
* Group-by Columns.
* "factorscore", "PCAEvaluator".
Outputs HTMl reports for:
* Factor Analysis Scoring Summary.
* "linear", "LinReg".
Outputs HTMl reports for:
* Linear Regression Summary.
* Group-by Columns.
* Near Dependency Report.
* "logistic", "LogReg".
Outputs HTMl reports for:
* Prediction Success Table.
* Multithreshold Success Table.
* Lift Table.
* Near Dependency Report.
* Group-by Columns.
* Variable Statistics.
* "logisticScore", "LogRegEvaluator".
Outputs HTMl reports for:
* Prediction Success Table.
* Multithreshold Success Table.
* Lift Table.
Types: str
filter:
Optional Argument.
Specifies the clause to filter rows selected for analysis.
For example,
filter = "cust_id > 0"
This parameter is useful only when the function "analysis_type"
(which outputs the input table name for the report function)
specified its "group_columns" argument and generated multiple
XML models.
Multiple XML models in input table name can cause the function
to run out of memory. In that case, limit the rows selected for
analysis with this argument.
Type: str
gen_sql_only:
Optional Argument.
Specifies whether to generate only SQL for the function.
When set to True, function SQL is generated, not executed, which can be accessed
using show_query() method, otherwise SQL is just executed but not returned.
Default Value: False
Types: bool
RETURNS:
An instance of XmlToHtmlReport.
Output teradataml DataFrames can be accessed using attribute
references, such as XmlToHtmlReport.<attribute_name>.
Output teradataml DataFrame attribute name is: result.
RAISES:
TeradataMlException, TypeError, ValueError.
EXAMPLES:
# Notes:
# 1. To execute Vantage Analytic Library functions,
# a. import "valib" object from teradataml.
# b. set 'configure.val_install_location' to the database name where Vantage
# analytic library functions are installed.
# 2. Datasets used in these examples can be loaded using Vantage Analytic Library
# installer.
# Import valib object from teradataml to execute this function.
from teradataml import valib
# Set the 'configure.val_install_location' variable.
from teradataml import configure
configure.val_install_location = "SYSLIB"
# Create required teradataml DataFrame.
df = DataFrame("customer")
print(df)
# Example 1: Shows the Near Dependency Report is requested with
related options.
obj = valib.LogReg(data=df,
columns=["age", "years_with_bank", "income"],
response_column="nbr_children",
response_value=1,
cond_ind_threshold=3,
variance_prop_threshold=0.3)
# Print the results.
print(obj.model)
print(obj.statistical_measures)
print(obj.xml_reports)
obj = valib.XmlToHtmlReport(data=obj.model, analysis_type="logistic")
# Print te result.
print(obj.result)
# Example 2: Generate only SQL for the function, but do not execute the same.
obj = valib.XmlToHtmlReport(data=logreg_obj.model,
analysis_type="logistic",
gen_sql_only=True)
# Print the generated SQL.
print(obj.show_query("sql"))
# Print both generated SQL and stored procedure call.
print(obj.show_query("both"))
# Print the stored procedure call.
print(obj.show_query())
print(obj.show_query("sp"))
|