LabVIEW Analytics and Machine Learning Toolkit API Reference

Initialize Classification Model (LR) VI

  • Updated2023-02-21
  • 6 minute(s) read

Initialize Classification Model (LR) VI

Owning Palette: Classification VIs

Requires: Analytics and Machine Learning Toolkit

Initializes the hyperparameters of the logistic regression (LR) algorithm. You can either set the hyperparameters or specify multiple values for each hyperparameter. If you specify multiple values for each hyperparameter, the Train Classification Model VI uses grid search to find the optimal set of hyperparameters.

Details  Examples

Set Parameters

hyperparameters specifies the hyperparameters of the logistic regression model.
tolerance specifies the tolerance for the stopping criteria. The default is 0.0001. The model fitting stops if the change of training error between two successive optimization iterations is lower than tolerance.
max iteration specifies the maximum number of optimization iterations for the stopping criteria. The default is 1000. The model fitting stops if the number of optimization iterations reaches max iteration.
cross validation configuration specifies settings for cross validation.
enable? specifies whether this VI enables cross validation in model training. The default is FALSE, which specifies that this VI disables cross validation in model training.

If enable? is TRUE, the Train Classification Model VI can return confusion matrix and metrics.
number of folds specifies the number of sections that this VI divides the training data into. The default is 3. One section is test data, and the remaining sections are training data. The Evaluate Classification Model VI repeats the cross-validation process for n times, where n equals number of folds.
metric configuration specifies the configuration for the evaluation metric in cross validation.
average method specifies the averaging method for this VI to calculate metric values for multiclass classification.

0Micro (default)—Calculates metric values for each sample and returns the mean of the metric values for all samples.
1Macro—Calculates the metric values for each label and returns the mean of the metric values for all labels.
2Weighted—Calculates the metric values for each label and returns the mean of weighted metric values for all labels. The number of true cases in a label determines the weight of the metric value of the label.
3Binary—Calculates the metric values for the class that positive label specifies.
positive label specifies the label of the class to calculate metric values. The default is 0. This input is valid only if average method is Binary.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
untrained logistic regression model returns the initialized logistic regression model for training.
error out contains error information. This output provides standard error out functionality.

Search Parameters

hyperparameter grids specifies multiple values for each hyperparameter of the logistic regression model.
tolerance specifies the tolerance for the stopping criteria. The model fitting stops if the change of training error between two successive optimization iterations is lower than tolerance.
max iteration specifies the maximum number of optimization iterations for the stopping criteria. The model fitting stops if the number of optimization iterations reaches max iteration.
hyperparameter optimization specifies the method of optimization to determine the optimal hyperparameter settings.
hyperparameter search method specifies the method to search for the optimal set of hyperparameters.

0Exhaustive search (default)—Tests all possible hyperparameter combinations in the training process. This method is reliable but time-consuming.
1Random search—Tests a random subset of the hyperparameter combinations in the training process. This method is faster.
number of searchings specifies the number of hyperparameter combinations that this VI selects to train the model. The default is 1. This input is valid only if hyperparameter search method is Random search.
evaluation metric specifies the metric to evaluate the trained model with different hyperparameter combinations. The Train Classification Model VI finds the optimal hyperparameter set based on evaluation metric.

0Accuracy
1Precision
2Recall
3F1 score
cross validation configuration specifies settings for cross validation.
number of folds specifies the number of sections that this VI divides the training data into. The default is 3. One section is test data, and the remaining sections are training data. The Evaluate Classification Model VI repeats the cross-validation process for n times, where n equals number of folds.
metric configuration specifies the configuration for the evaluation metric in cross validation.
average method specifies the averaging method for this VI to calculate metric values for multiclass classification.

0Micro (default)—Calculates metric values for each sample and returns the mean of the metric values for all samples.
1Macro—Calculates the metric values for each label and returns the mean of the metric values for all labels.
2Weighted—Calculates the metric values for each label and returns the mean of weighted metric values for all labels. The number of true cases in a label determines the weight of the metric value of the label.
3Binary—Calculates the metric values for the class that positive label specifies.
positive label specifies the label of the class to calculate metric values. The default is 0. This input is valid only if average method is Binary.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
untrained logistic regression model returns the initialized logistic regression model for training.
error out contains error information. This output provides standard error out functionality.

Initialize Classification Model (LR) Details



The following equation defines the logistic regression model:



where
x is the input with k + 1 dimensions. x0 is always 1.
y is the output with a binary value 0 or 1
β is the weight vector with k + 1 dimensions
P (y = 1|x) is the probability of y = 1 given a known instance of x

Examples

Refer to the following VIs for examples of using the Initialize Classification Model (LR) VI:

  • Classification (Set Parameters, Training) VI: labview\examples\AML\Classification
  • Classification (Search Parameters, Training) VI: labview\examples\AML\Classification