| |
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=256, hash_bits=256, label_column=None, cost=1.0, bias=0.0, class_weights=None, max_step=100, epsilon=0.01, seed=0, data_sequence_column=None)
- 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].
Default Value: 256
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].
Default Value: 256
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: 100
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.01
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)
RETURNS:
Instance of SVMDense.
Output teradataml DataFrames can be accessed using attribute
references, such as SVMDenseObj.<attribute_name>.
Output teradataml DataFrame attribute name is:
1. model_table
2. output
RAISES:
TeradataMlException
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.
|