# tLogisticRegressionModel properties for Apache Spark Batch

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

The Spark Batch tLogisticRegressionModel 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

| 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. 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 column | Select the input column used to provide classification labels. The<br>records of this column are used as the class names (Target in terms of<br>classification) of the elements to be classified. |
| Feature column | Select the input column used to provide features. Very often, this<br>column is the output of the feature engineering computations performed<br>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. |
| ElasticNet mixing parameter | Enter the ElasticNet coefficient (numerical value) used for the<br>regularization calculation in order to control the bias/variance<br>trade-off in feature selection. ElasticNet is the combination of L1<br>regularization and L2 regularization.<br><br>The value to be put varies between 0.0 and 1.0, indicating the weights<br>of the L1 regularization and the L2 regularization in the ElasticNet<br>combination. When the value is 0.0, the regularization is actually<br>equivalent to the L2 regularization; when the value is 1.0, it is<br>equivalent to the L1 regularization.<br><br>For further information about how ElasticNet is implemented in Spark,<br>see [ML linear methods](http://spark.apache.org/docs/latest/ml-linear-methods.html), in which the related formula shows how the value you put (*α* in that formula) is used to calculate the<br>ElasticNet regularization.<br><br>For further information about ElasticNet, see [Regularization and variable selection via the<br>elastic net](http://web.stanford.edu/~hastie/Papers/B67.2%20%282005%29%20301-320%20Zou%20&%20Hastie.pdf). |
| Fit an intercept term | Select this check box to allow the tLogisticRegressionModel to automatically calculate the<br>intercept constants and include them in the regression<br>computation.<br><br>In general, intercept should present to guarantee that the residuals<br>of your model have a mean of zero. |
| Maximum number of iterations | Enter the number of iterations you want the Job to perform to train<br>the model. |
| Regularization | Enter the regularization coefficient (numerical value) to be used<br>along with ElasticNet for the regularization calculation.<br><br>For further information about how this parameter is implemented in<br>Spark, see [ML linear methods](http://spark.apache.org/docs/latest/ml-linear-methods.html), in which the related formula shows how the<br>value you put (*λ* in that formula) is<br>used to calculate the eventual regularization. |
| Threshold | Enter the threshold (numerical value and ranging between 0.0 and 1.0)<br>used to separate the positive predictions from the negative predictions.<br>An element about which the prediction score (the odds of being a case)<br>is greater or equal to this threshold will be identified as positive,<br>and negative otherwise.<br><br>The default threshold is *0.5*. |
| Convergence tolerance | Enter the convergence score which the iterations are expected to<br>obtain.<br><br>In general, smaller value will result in higher accuracy in the<br>prediction at the cost of more iterations.<br><br>But note that in some cases, your model may not be able to reach the<br>convergence you put despite of whatever number of iterations you want<br>the Job to perform. This failure to converge might indicate that the<br>convergence score you use is not realistic to the features you are<br>processing and therefore, you need to process these features to a<br>greater degree. |

## Usage

| **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, the threshold or the convergence tolerance<br>but note that the training that stops too early could impact its<br>performance. |
| --- | --- |
| 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/en-US/components/7.3/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>When using Qubole, add a                                        <span>tS3Configuration</span> to your Job to write                                    your actual business data in the S3 system with Qubole. Without                                        <span>tS3Configuration</span>, this business data is                                    written in the Qubole HDFS system and destroyed once you shut                                    down your cluster.</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/7.3/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/7.3/components/hdfs/thdfsconfiguration-properties-for-apache-spark-batch">tHDFSConfiguration Apache Spark Batch</a> or <a href="https://help.qlik.com/talend/r/en-US/7.3/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. |