Teradata Package for Python Function Reference - Scale - 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.Scale = class Scale(builtins.object)
     Methods defined here:
__init__(self, object=None, data=None, method=None, scale_global=False, accumulate=None, multiplier=1.0, intercept='0', input_columns=None, object_sequence_column=None, data_sequence_column=None, object_order_column=None, data_order_column=None)
DESCRIPTION:
    The Scale function uses statistical information from the ScaleMap
    function to scale the input data set.
 
 
PARAMETERS:
    object:
        Required Argument.
        Specifies the teradataml DataFrame containing statistic input
        generated by ScaleMap or instance of ScaleMap.
 
    object_order_column:
        Optional Argument.
        Specifies Order By columns for data.
        Values to this argument can be provided as a list, if multiple
        columns are used for ordering.
        Types: str OR list of Strings (str)
 
    data:
        Required Argument.
        Specifies the input teradataml DataFrame for scale function.
 
    data_order_column:
        Optional Argument.
        Specifies Order By columns for data.
        Values to this argument can be provided as a list, if multiple
        columns are used for ordering.
        Types: str OR list of Strings (str)
 
    method:
        Required Argument.
        Specify one or more methods used to scale the dataset. If you specify multiple methods,
        the output teradataml DataFrame includes the column scalemethod
        (which contains the method name) and a row for each input-row/method combination.
        Permitted Values: MEAN, SUM, USTD, STD, RANGE, MIDRANGE, MAXABS.
        Types: str or list of Strings (str)
 
    scale_global:
        Optional Argument.
        Specifies whether all input columns are scaled to the same location
        and scale. (Each input column is scaled separately).
        Default Value: False
        Types: bool
 
    accumulate:
        Optional Argument.
        Specifies the input teradataml DataFrame columns to copy to the
        output table. By default, the function copies no input teradataml
        DataFrame columns to the output table.
        Types: str OR list of Strings (str)
 
    multiplier:
        Optional Argument.
        Specifies one or more multiplying factors to apply to the input
        variables-multiplier in the following formula:
            X' = intercept + multiplier * (X - location)/scale
        If you specify only one multiplier, it applies to all columns specified
        by the input_columns argument. If you specify multiple multiplying factors,
        each multiplier applies to the corresponding input column. For example, the first multiplier
        applies to the first column specified by the input_columns argument,
        the second multiplier applies to the second input column, and so on.
        Default Value: 1.0
        Types: float OR list of floats
 
    intercept:
        Optional Argument.
        Specifies one or more addition factors incrementing the scaled
        results-intercept in the following formula:
            X' = intercept + multiplier * (X - location)/scale
        If you specify only one intercept, it applies to all columns specified
        by the input_columns argument. If you specify multiple addition factors,
        each intercept applies to the corresponding input column.
        The syntax of intercept is:
        [-]{number | min | mean | max }
        where min, mean, and max are the scale_global minimum,
        maximum, mean values in the corresponding columns.
        The function scales the values of min, mean, and max.
        The formula for computing the scaled scale_global minimum is:
            scaledmin = (minX - location)/scale
        The formulas for computing the scaled scale_global mean and maximum
        are analogous to the preceding formula.
        For example, if intercept is "- min" and multiplier is 1,
        the scaled result is transformed to a nonnegative sequence according
        to this formula, where scaledmin is the scaled value:
            X' = -scaledmin + 1 * (X - location)/scale.
        Default Value: "0"
        Types: str or list of Strings (str)
 
    input_columns:
        Optional Argument.
        Specifies the input teradataml DataFrame columns that contain the
        attribute values of the samples. The attribute values must be numeric
        values between -1e308 and 1e308. If a value is outside this range,
        the function treats it as infinity.
        The default input columns are all columns of the statistic teradataml DataFrame
        (of the ScaleMap function) except stattype.
        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)
 
    data_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "data". 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 Scale.
    Output teradataml DataFrames can be accessed using attribute
    references, such as ScaleObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    # Load example data.
    # The table 'scale_housing' and 'scale_housing_test' contains house properties
    # like the number of bedrooms, lot size, the number of bathrooms, number of stories etc.
    # The table 'scale_stat' is the statistic data(genererated by ScaleMap function) of the scale_housing data.
    load_example_data("scalemap", "scale_housing")
    load_example_data("scale", ["scale_stat", "scale_housing_test"])
 
    # Create teradataml DataFrame objects.
    scale_housing = DataFrame.from_table("scale_housing")
    scale_housing_test = DataFrame.from_table("scale_housing_test")
    scale_stat = DataFrame.from_table("scale_stat")
 
    # Example 1 - This example scales (normalizes) input data using the
    # midrange method and the default values for the arguments Intercept
    # and Multiplier (0 and 1, respectively).
    scale_map_out = ScaleMap(data = scale_housing,
                             input_columns = ['price','lotsize','bedrooms','bathrms','stories']
                            )
 
    scale_out1 = Scale(object=scale_map_out,
                              data=scale_housing,
                              method="midrange",
                              accumulate="id"
                             )
    # Print the result DataFrame
    print(scale_out1)
 
    # Example 2 - This example uses a teradataml DataFrame as input for object argument and
    # the Intercept argument has the value "-min" (where min is the scale_global minimum value)
    # and we also specify different Multiplier values for corresponding columns.
    scale_out2 = Scale(object = scale_stat,
                      data = scale_housing,
                      method = "midrange",
                      accumulate = "id",
                      multiplier = [1.0,2.0,3.0,4.0,5.0],
                      intercept = "-min"
                     )
 
    # Print the result DataFrame
    print(scale_out2)
 
    # Example 3 - This example uses the statistics created by ScaleMap on a training data set
    # (scale_housing) and then uses these statistics to scale a similar
    # test data set(scale_housing_test).
    scale_out3 = Scale(object = scale_stat,
                              data = scale_housing_test,
                              method = "midrange",
                              accumulate = "id"
                             )
 
    # Example 4 - This example uses the Scale function to scale data (using
    # the maxabs method) before inputting it to the function KMeans, which
    # outputs the centroids of the clusters in the dataset.
    load_example_data("KMeans", "computers_train1")
    computers_train1 = DataFrame.from_table("computers_train1")
 
    scale_map_out4 = ScaleMap(data=computers_train1,
                                            input_columns=['price','speed','hd','ram'],
                                            miss_value='OMIT'
                                           )
 
    scale_out4 = Scale(object=scale_map_out4,
                                     data=computers_train1,
                                     method="maxabs",
                                     accumulate="id"
                                    )
    # Use the scaled data as input to KMeans to get clusters
    kmeans_out = KMeans(data = scale_out4.result,
                                centers = 8,
                                iter_max = 10,
                                threshold = 0.05
                               )
    # Print the result DataFrame
    print(kmeans_out)
__repr__(self)
Returns the string representation for a Scale 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.