# tSVMModel

Generates an SVM-based classifier model that can be used by tPredict to classify given elements.

tSVMModel applies the SVM algorithm to analyze feature vectors typically prepared and provided by tModelEncoder.

It generates a binary classification model out of this analysis and writes this model in memory or in a file system supported by this component, such as HDFS or S3.

In local mode, Apache Spark 3.0.x and later versions are supported.

This component is not shipped with your Talend Studio by default. You need to install it using the Feature Manager. For more information, see [Installing features using the Feature Manager](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/install-features-to-talend-studio).

## tSVMModel properties for Apache Spark Batch

These properties are used to configure tSVMModel running in the Spark Batch Job framework.

The Spark Batch tSVMModel component belongs to the Machine Learning family.

This component is available in Talend Platform products with Big Data and in Talend Data Fabric.

## Basic settings

| Properties | Description |
| --- | --- |
| Schema and Edit schema | A schema is a row description. It defines the number of fields<br>(columns) to be processed and passed on to the next component. When you create a Spark<br>Job, avoid the reserved word line when naming the<br>fields.<br><br>Click Edit<br>schema to make changes to the schema. If the current schema is of the Repository type, three options are available:<br><br><ul> <li> <p> <span>View schema</span>: choose this                option to view the schema only.</p> </li> <li> <p> <span>Change to built-in property</span>:                choose this option to change the schema to <span>Built-in</span> for local changes.</p> </li> <li> <p> <span>Update repository connection</span>:                choose this option to change the schema stored in the repository and decide whether                to propagate the changes to all the Jobs upon completion.</p> <p>If you just want to                propagate the changes to the current Job, you can select <span>No</span> upon completion and choose this schema metadata                again in the <span>Repository Content</span>                window.</p> </li> </ul> |
| Label | Select the input column used to provide classification labels. The records of this column<br>are used as the class names (Target in terms of classification) of the elements to be<br>classified.<br><br>Since a SVM model is a binary classification model, only two classes are expected, that is to<br>say, only two distinct values are expected from this column. |
| Vector to process | Select the input column used to provide features. Very often, this column is the output of<br>the feature engineering computations performed by tModelEncoder. |
| Save the model on file<br>system | Select this check box to store the model in a given file system. Otherwise, the model is<br>stored in memory. The button for browsing does not work with the Spark Local mode; if you are using the Spark Yarn<br>or the Spark Standalone mode, ensure that you have properly<br>configured the connection in a configuration component in the same Job, such as tHDFSConfiguration. |
| Step size | Enter the size (numerical value) of the initial step of the gradient<br>descent calculation. The default value *1.0* means that the whole data set is taken.<br><br>Selecting the best step size is often delicate in practice.<br><br>Generally speaking, when the feature points to be analyzed are very<br>muddled, it is recommended to increase the step size in order to cover<br>enough number of points in each iteration; however, bear in mind that<br>too large a step size can improperly increase the time of each<br>iteration.<br><br>On the other hand, the smaller the step size is, the more slowly the<br>convergence occurs and a more accurate model you can expect. |
| Number of iterations | Enter the number of iterations you want the Job to perform to train the model. |
| Fraction of data to be used per<br>iteration | Enter the fraction (expressed in decimal) of the input data to be used<br>in each iteration to calculate the gradient.<br><br>The default value 1.0 means that the whole dataset is<br>taken. |
| Regularization parameter | Enter the regularization number to used by the Updater<br>function in order to avoid overfitting in learning. |
| Updater function | Select the function to calculate the form of the hyperplane that<br>separates the two classes.<br><br>This function updates the weights of every point in each iteration so<br>as to perform the gradient step in a given direction to form the<br>hyperplane.<br><br>For example, in a 2-dimension space, this hyperplane can be a line or<br>a set of lines if the points to be classified are linearly<br>separable.<br><br>The available functions are:<br><br><ul> <li> <p> <span>Simple</span>: it does not use the                                    <span>Regularization                                    parameter</span>.</p> </li> <li> <p> <span>L1</span>: it performs the L1                                    regularization.</p> </li> <li> <p> <span>Squared L2</span>: it performs the                                    L2 regularization.</p> </li> </ul> |
| Gradient function | Select the loss function to calculate the margin between the<br>hyperplane and the nearest point of either class.<br><br>For further information about the loss functions available on this<br>drop-down list, see [Loss function for classification](https://en.wikipedia.org/wiki/Loss_functions_for_classification). |

## Advanced settings

| Properties | Description |
| --- | --- |
| Use feature scaling | If your training data cannot converge, select this check box to make<br>tSVMModel reduce the condition numbers<br>heuristically by scaling the feature data.<br><br>Reducing the condition numbers can often improve the convergence<br>rate. |
| Intercept | Select this check box to allow the tSVMModel to automatically calculate the intercept constants<br>and include them in the computation.<br><br>In general, intercept can guarantee that the residuals of your model<br>have a mean of zero. |
| Validate data before<br>training | Select this check box to check whether the vectors of the training<br>data are well formatted before starting the training. |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | This component is used as an end component and requires an input link.<br><br>You can accelerate the training process by adjusting the stopping conditions such as the<br>maximum number of iterations or the step size but note that the training<br>that stops too early could impact its accuracy. |
| Model evaluation | The parameters you need to set are free parameters and so their values may be provided by<br>previous experiments, empirical guesses or the like. They do not have any optimal values<br>applicable for all datasets.<br><br>Therefore, you need to train the classifier model you are generating with different sets<br>of parameter values until you can obtain the best confusion matrix. But note that you need<br>to write the evaluation code yourself to rank your model with scores.<br><br>You need to select the scores to be used depending on the algorithm you want to use to<br>train your classifier model. This allows you to build the most relevant confusion<br>matrix.<br><br>For examples about how the confusion matrix is used in a<br>Talend<br>Job for classification, see [Creating a classification model to filter spam](https://help.qlik.com/talend/r/en-US/8.0/components/machine-learning/classification-model).<br><br>For a general explanation about confusion matrix, see https://en.wikipedia.org/wiki/Confusion\_matrix from Wikipedia. |
| Spark Connection | In the Spark<br>Configuration tab in the Run<br>view, define the connection to a given Spark cluster for the whole Job. In<br>addition, since the Job expects its dependent jar files for execution, you must<br>specify the directory in the file system to which these jar files are<br>transferred so that Spark can access these files:<br><br><ul> <li> <div> <span>Yarn mode</span> (Yarn client or Yarn cluster):<ul> <li> <p>When using Google Dataproc, specify a bucket in the                                            <span>Google Storage staging bucket</span>                                        field in the <span>Spark configuration</span>                                        tab.</p> </li> <li> <p>When using HDInsight, specify the blob to be used for Job                                        deployment in the <span>Windows Azure Storage                                            configuration</span> area in the <span>Spark                                            configuration</span> tab.</p> </li> <li>When using Altus, specify the S3 bucket or the Azure                                    Data Lake Storage for Job deployment in the <span>Spark                                        configuration</span> tab.</li> <li> <p>When using on-premises distributions, use                                        the configuration component corresponding to the file system                                        your cluster is using. Typically, this system is HDFS and so                                        use <a href="https://help.qlik.com/talend/r/en-US/8.0/components/hdfs/thdfsconfiguration">tHDFSConfiguration</a>.</p> </li> </ul> </div> </li> <li> <p> <span>Standalone mode</span>: use the                            configuration component corresponding to the file system your cluster is                            using, such as <a href="https://help.qlik.com/talend/r/en-US/8.0/components/hdfs/thdfsconfiguration-properties-for-apache-spark-batch">tHDFSConfiguration Apache Spark Batch</a> or <a href="https://help.qlik.com/talend/r/en-US/8.0/components/amazon-s3/ts3configuration-properties-for-apache-spark-batch">tS3Configuration Apache Spark Batch</a>.</p> <p>If you are using Databricks without any configuration component present                            in your Job, your business data is written directly in DBFS (Databricks                            Filesystem).</p> </li> </ul><br><br>This connection is effective on a per-Job basis. |