Teradata Package for Python Function Reference - SVMDense - 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.SVMDense = class SVMDense(builtins.object)
     Methods defined here:
__init__(self, data=None, sample_id_column=None, attribute_columns=None, kernel_function='LINEAR', gamma=1.0, constant=1.0, degree=2, subspace_dimension=512, hash_bits=512, label_column=None, cost=1.0, bias=0.0, class_weights=None, max_step=10000, epsilon=0.001, seed=0, data_sequence_column=None, force_mapreduce=False)
DESCRIPTION:
    The SVMDense function takes training data in dense format and
    outputs a predictive model in binary format, which is input to the
    functions SVMDensePredict and SVMDenseSummary.
 
 
PARAMETERS:
    data:
        Required Argument.
        Specifies the name of the teradataml DataFrame that contains
        the training samples.
    
    sample_id_column:
        Required Argument.
        Specifies the name of the name of the column in data, teradataml DataFrame
        that contains the identifiers of the training samples.
        Types: str
    
    attribute_columns:
        Required Argument.
        Specifies the name of the name of the column in data, teradataml DataFrame
        that contains the attributes of the samples. Attribute columns must have a
        numeric value.
        Types: str OR list of Strings (str)
    
    kernel_function:
        Optional Argument.
        The distribution exponential family used to compute the hash function.
        For linear, a Pegasos algorithm is used to solve the linear SVM.
        For polynomial, RBF, or sigmoid, a Hash-SVM algorithm is used. Each
        sample is represented by compact hash bits, over which an inner
        product is defined to serve as the surrogate of the original
        nonlinear kernels.
        Default Value: "LINEAR"
        Permitted Values: LINEAR, POLYNOMIAL, RBF, SIGMOID
        Types: str
    
    gamma:
        Optional Argument.
        Only used when kernel_function is polynomial, RBF, or sigmoid. A
        positive double that specifies . The minimum value is 0.0.
        Default Value: 1.0
        Types: float
    
    constant:
        Optional Argument.
        Only used when kernel_function is polynomial or sigmoid. A double
        value that specifies c. If kernel_function is polynomial, the minimum
        value is 0.0.
        Default Value: 1.0
        Types: float
    
    degree:
        Optional Argument.
        Only used when kernel_function is polynomial. A positive integer that
        specifies the degree (d) of the polynomial kernel. The input value
        must be greater than 0.
        Default Value: 2
        Types: int
    
    subspace_dimension:
        Optional Argument.
        Only valid if kernel_function is polynomial, RBF, or sigmoid. A positive
        integer that specifies the random subspace dimension of the basis
        matrix V obtained by the Gram-Schmidt process. Since the Gram-Schmidt
        process cannot be parallelized, this dimension cannot be too large.
        Accuracy will increase with higher values of this number, but
        computation costs will also increase. The input value must be in the
        range [1, 2048].
        Note:
            Argument is ignored when "kernel_function" is 'linear'.
        Default Value: 512
        Types: int
    
    hash_bits:
        Optional Argument.
        Only valid if kernel_function is polynomial, RBF, or sigmoid. A positive
        integer specifying the number of compact hash bits used to represent
        a data point. Accuracy will increase with higher values of this
        number, but computation costs will also increase. The input value
        must be in the range [8, 8192].
        Note:
            Argument is ignored when "kernel_function" is 'linear'.
        Default Value: 512
        Types: int
    
    label_column:
        Required Argument.
        Column that identifies the class of the corresponding sample. Must be
        an integer or a string.
        Types: str
    
    cost:
        Optional Argument.
        The regularization parameter in the SVM soft-margin loss function.
        Must be greater than 0.0.
        Default Value: 1.0
        Types: float
    
    bias:
        Optional Argument.
        A non-negative value. If the value is greater than zero, each sample
        (x) in the training set will be converted to ( x, b); that is, it
        will add another dimension containing the bias value b. This argument
        addresses situations where not all samples center at 0.
        Default Value: 0.0
        Types: float
    
    class_weights:
        Optional Argument.
        Specifies the weights for different classes. The format should be:
        "classlabel m:weight m, classlabel n:weight n". If weight for a class
        is given, the cost parameter for this class will be weight * cost. A
        weight larger than 1 often increases the accuracy of the
        corresponding class; however, it may decrease global accuracy.
        Classes not assigned a weight in this argument will be assigned a
        weight of 1.0.
        Types: str OR list of Strings (str)
    
    max_step:
        Optional Argument.
        A positive integer value that specifies the maximum number of
        iterations of the training process. One step means that each sample
        is seen once by the trainer. The input value must be in the range [0,
        10000].
        Default Value: 10000
        Types: int
    
    epsilon:
        Optional Argument.
        Termination criterion. When the difference between the values of the
        loss function in two sequential iterations is less than this number,
        the function stops. Must be greater than 0.0.
        Default Value: 0.001
        Types: float
    
    seed:
        Optional Argument.
        A long integer value used to order the training set randomly and
        consistently. This value can be used to ensure that the same model
        will be generated if the function is run multiple times in a given
        database with the same arguments. The input value must be in the
        range [0, 9223372036854775807].
        Default Value: 0
        Types: int
    
    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)
 
    force_mapreduce:
        Optional Argument.
        Specifies whether the function is to use MapReduce. If set to
        'False', a lighter version of the function runs for faster results.
        It has no effect without "kernel_function" is 'linear'.
        Note:
            1. The model may be different with "force_mapreduce" set to 'True' and
               "force_mapreduce" set to 'False'.
            2. "force_mapreduce" argument support is only available when teradataml
               is connected to Vantage 1.3 version.
        Default Value: False
        Types: bool
 
RETURNS:
    Instance of SVMDense.
    Output teradataml DataFrames can be accessed using attribute
    references, such as SVMDenseObj.<attribute_name>.
    Output teradataml DataFrame attribute names are:
        1. model_table
        2. output
 
 
RAISES:
    TeradataMlException, TypeError, ValueError
 
 
EXAMPLES:
 
    # Load the data to run the example.
    load_example_data("svmdense","nb_iris_input_train")
 
    # Create teradataml DataFrame objects.
    nb_iris_input_train = DataFrame.from_table("nb_iris_input_train")
 
    # Example 1 - Linear Model
    svm_dense_out = SVMDense(data = nb_iris_input_train,
                            sample_id_column = "id",
                            attribute_columns = ['sepal_length', 'sepal_width' , 'petal_length' , 'petal_width'],
                            kernel_function = "linear",
                            label_column = "species",
                            cost = 1.0,
                            bias = 0.0,
                            max_step = 100,
                            seed = 1
                            )
 
    # Print the result DataFrame
    print(svm_dense_out)
 
    # Example 2 - Polynomial Model
    svm_dense_out = SVMDense(data = nb_iris_input_train,
                            sample_id_column = "id",
                            attribute_columns = ['sepal_length', 'sepal_width' , 'petal_length' , 'petal_width'],
                            kernel_function = "polynomial",
                            gamma = 0.1,
                            degree = 2,
                            subspace_dimension = 120,
                            hash_bits = 512,
                            label_column = "species",
                            cost = 1.0,
                            bias = 0.0,
                            max_step = 100,
                            seed = 1
                            )
 
    # Print the result DataFrame
    print(svm_dense_out)
 
    # Example 3 - Radial Basis Model (RBF) Model
    svm_dense_out = SVMDense(data = nb_iris_input_train,
                            sample_id_column = "id",
                            attribute_columns = ['sepal_length', 'sepal_width' , 'petal_length' , 'petal_width'],
                            kernel_function = "rbf",
                            gamma = 0.1,
                            subspace_dimension = 120,
                            hash_bits = 512,
                            label_column = "species",
                            cost = 1.0,
                            bias = 0.0,
                            max_step = 100,
                            seed = 1
                            )
 
    # Print the result DataFrame
    print(svm_dense_out)
 
    # Example 4 - Sigmoid Model
    svm_dense_out = SVMDense(data = nb_iris_input_train,
                            sample_id_column = "id",
                            attribute_columns = ['sepal_length', 'sepal_width' , 'petal_length' , 'petal_width'],
                            kernel_function = "sigmoid",
                            gamma = 0.1,
                            subspace_dimension = 120,
                            hash_bits = 512,
                            label_column = "species",
                            cost = 1.0,
                            bias = 0.0,
                            max_step = 30,
                            seed = 1
                            )
 
    # Print the result DataFrame
    print(svm_dense_out)
__repr__(self)
Returns the string representation for a SVMDense 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.