Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Overview

This is a Transform type Snap that builds model for a classification dataset. In the Snap's settings, you can select the target field in the dataset, algorithm, and configure parameters for the selected algorithm.

Image Modified


Note

If you want to build the model on regression dataset, use Trainer -- Regression Snap instead.

Input and Output

Expected input: The classification dataset. 

Expected output: A serialization of the model, and metadata which are not human-readable. Additionally, the output includes a human-readable representation of the model if the Readable checkbox is selected.

Expected upstream Snap: Any Snap that generates a classification dataset document. For example, CSV Generator, JSON Generator, or a combination of File Reader and JSON Parser.

Expected downstream Snap: Snaps that require a model input. For example, the Predictor (Classification) Snap. Alternatively, any Snap that stores the model to be used in another pipeline. For example, a combination of JSON Formatter and File Writer.

Prerequisites

  • The data from upstream Snap must be in tabular format (no nested structure). 
  • This Snap automatically derives the schema (field names and types) from the first document. Therefore, the first document must not have any missing values.

Configuring Accounts

Accounts are not used with this Snap.

Configuring Views

Input

This Snap has exactly one document input view.
OutputThis Snap has exactly one document output view.
ErrorThis Snap has at most one document error view.

Troubleshooting

None.

Limitations and Known Issues

None.

Modes


Snap Settings


LabelRequired. The name for the Snap. Modify this to be more specific, especially if there are more than one of the same Snap in the pipeline.
Label field

Required. The label or output field in the dataset. This must be a categorical type represented as text (string data type). This is the field that the model will be trained to predict.

Default value: None

Example: $class

Algorithm

Required. The classification algorithm to be used to build the model. There are eight classification algorithms currently available:

  • Decision Tree
  • K-Nearest Neighbors
  • Logistic Regression
  • Naive Bayes
  • Support Vector Machines
  • Decision Stump
  • Random Forests
  • Multilayer Perceptron

The implementations are from WEKA, an open source machine learning library in Java.

Default value: Decision Tree

Options

The parameters to be applied on the selected classification algorithm. Each algorithm has a different set of parameters to be configured in this property. If this property is left blank, the default values are applied for all the parameters. If specifying multiple parameters, separate them with a comma ",".

See Options for Algorithms section below for details.

Default value: None

Examples:

  • batch_size = 120
  • batch_size = 120, collapse_tree = true
Readable

Select this to output the model in human-readable format. When selected, a $readable field is added to the output, this displays the model in a readable format.

Default value: Not selected

Multiexcerpt include macro
nameSnap Execution
pageAnaplan Read


Multiexcerpt include macro
nameSnap_Execution_Introduced
pageAnaplan Read


Best Practices


Using Type Converter Snap Upstream

In some cases, the numerical fields may be represented as text. You can use the Type Converter Snap to convert data into appropriate types before feeding into the Trainer (Classification) Snap.

Algorithm Selection 

In order to choose the best possible algorithm for your dataset, use the Cross Validator (Classification) Snap to perform k-fold cross validation on the dataset. The algorithm that produces the best accuracy is likely to be the one most suitable for your dataset. Apply the same algorithm for your dataset in the Trainer (Classification) Snap to build the model. 

Options for Algorithms

Expand
titleOptions for algorithms


Excerpt

This section lists all applicable parameters for each algorithm along with their default values. 

Decision Tree


Option Name
Option Data Type
Default Value
Description
batch_sizeint100Set the preferred batch size for batch prediction.
binary_splitsbooleanfalseEnable binary splits.
collapse_treebooleantrueSet to allow collapsing the tree.
confidence_factorfloat0.25Set the confidence threshold for pruning.
do_not_check_capabilitiesbooleanfalseEnable capability-check.
do_not_mask_split_point_actual_valuebooleanfalseSet whether the split point actual value is to be masked. 
min_num_objint2Set the minimum number of instances per leaf.
num_decimal_placesint2Set the number of decimal places.
num_foldsint3Set the number of folds for reduced error pruning. One fold is used as pruning set.
reduced_error_pruningbooleanfalseEnable reduced error pruning. This is false if the unpruned parameter is set to true.
save_instance_databooleanfalseSet whether the instance data is to be saved. If set to true, it does not clean up after the tree has been built.
seedint1Set the seed for random data shuffling.
subtree_raisingbooleantrueEnable sub-tree raising.
unprunedbooleanfalseEnable using unpruned tree. This is false if the reduced_error_pruningparameter is set to true.
use_laplacebooleanfalseAllow Laplace smoothing for predicted probabilities.
use_md_correctionbooleantrueAllow MDL correction for info gain on numeric attributes.


K-Nearest Neighbors


Option Name
Option Data Type
Default Value
Description
knnint1Set the number of neighbors the learner will use.
batch_sizeint100Set the preferred batch size for batch prediction.
cross_validatebooleanfalseSet whether the hold-one-out cross-validation will be used to select the best k-value.
distance_weightingenum 
[weight_none, weight_inverse, weight_similarity]
weight_noneSet the distance weighting method used. 
do_not_check_capabilitiesbooleanfalseEnable capability-check.
mean_squaredbooleanfalseSet whether the mean squared error is used rather than mean absolute error when doing cross-validation.
nearest_neighbours_search_algorithmenum 
[LinearNNSearch, BallTree, CoverTree, KDTress, FilteredNeighbourSearch]
LinearNNSearchSet the nearestNeighbourSearch algorithm to be used for finding nearest neighbor(s).
num_decimal_placesint2Set the number of decimal places.
window_sizeint0 (no window size)Set the maximum number of instances allowed in the training pool.


Logistic Regression


Option Name
Option Data Type
Default Value
Description
batch_sizeint100Set the preferred batch size for batch prediction.
do_not_check_capabilitiesbooleanfalseEnable capability-check.
matx_itsint-1Set the maximum number of iterations.
num_decimal_placesint4Set the number of decimal places.
ridgedouble1.00E-08Sets the ridge in the log-likelihood.
use_conjugate_gradient_descentbooleanfalseSets whether conjugate gradient descent is used.


Naive Bayes


Option Name
Data Type
Default Value
Description
batch_sizeint100Set the preferred batch size for batch prediction.
do_not_check_capabilitiesbooleanfalseEnable capability-check.
num_decimal_placesint2Set the number of decimal places.
use_kernel_estimatorbooleanfalseUse kernel density estimator rather than normal distribution for numeric attributes. This is false if use_supervised_discretization is set to true.
use_supervised_discretizationbooleanfalseUse supervised discretization to process numeric attributes. This is false if use_kernel_estimator is set to true.


Support Vector Machines


Option Name
Data Type 
Default Value
Description
batch_sizeint100Set the preferred batch size for batch prediction.
cdouble1Set the complexity constant C.
build_calibration_modelsbooleanfalseSet whether to fit calibration models to SVM outputs.
checks_turned_offbooleanfalseDisable all checks.
do_not_check_capabilitiesbooleanfalseEnable capability-check.
epsilondouble1.00E-12Set the epsilon for round-off error.
filter_typeenum 
[filter_none, filter_normalize, filter_standardize]
filter_normalizeSet how the training data will be transformed.
kernelenum 
[PolyKernel, NormalizedPolyKernel, PrecomputedKernelMatrixKernel, Puk, RBFKernel, StringKernel]
PolyKernelSpecify the Kernel to use.
num_decimal_placesint2Set the number of decimal places.
num_foldsint-1Set the number of folds for the internal cross-validation.
random_seedint1Set the random number seed.
tolerance_parameterdouble1.00E-03Set the tolerance parameter.


Decision Stump


Option Name
Data Type
Default Value
Description
batch_sizeint100Set the preferred batch size for batch prediction.
do_not_check_capabilitiesbooleanfalseEnable capability-check.
num_decimal_placesint2Set the number of decimal places.


Random Forests


Option Name
Data Type
Default Value
Description
bag_size_percentint100Specify the size of each bag, as a percentage of the training set size.
batch_sizeint100Set the preferred batch size for batch prediction.
break_ties_randomlybooleanfalseSet whether to break ties randomly when several attributes look equally good.
calc_out_of_bagbooleanfalseSet whether to calculate the out-of-bag error.
compute_attribute_importancebooleanfalseSet whether compute and output attribute importance (mean impurity decrease method)
do_not_check_capabilitiesbooleanfalseEnable capability-check.
max_depthint0Set the maximum depth of the tree, 0 for unlimited.
num_decimal_placesint2Set the number of decimal places.
num_execution_slotsint1Set the  number of execution slots.
num_featuresint0Set the  number of attributes to randomly investigate.
num_iterationsint100Set the number of iterations.
seedint1Set the seed for random number generator.
store_out_of_bag_predictionsbooleanfalseSet whether to store out-of-bag predictions in internal evaluation object.


Multilayer Perceptron


Option Name
Data Type
Default Value
Description
batch_sizeint100Set the preferred batch size for batch prediction.
do_not_check_capabilitiesbooleanfalseEnable capability-check.
learning_ratedouble0.3Set the learning rate for the backward propagation. The value should be between 0 - 1.
momentumdouble0.2Set the momentum rate for the backward propagation algorithm.The value should be between 0 - 1.
num_decimal_placesint2Set the number of decimal places.
seedint0Set the value used to seed the random number generator.
validation_set_sizeint0
Set the percentage size of validation set to use to terminate training. The value should be between 0 - 1.
validation_thresholdint20
Set the number of consecutive increases of error allowed for validation testing before training terminates.





Example


Weight Balance Classification – Model Training

This pipeline demonstrates training a model to predict whether a weighing scale is balanced. The classification algorithm is selected based on the algorithm evaluation in the Cross Validator (Classification) Snap's example. The input dataset depicts the weight on each side of the scale and the side's distance from the floor. 

Image Modified

Download this pipeline.

Expand
titleUnderstanding the pipeline

Input

The input document is generated by the CSV Generator Snap and is composed of four fields, one classification field and three numeric fields:

  • Balance Class: The classification field to denote status of the weighing scale. B for Balanced, L for Left-inclined, and R for Right-inclined.
  • Left Weight
  • Left Distance
  • Right Weight
  • Right Distance

Image Modified

Note

This dataset has been sourced from UCI Dataset Archive.

Objective

Use Trainer (Classification) Snap to train the model for the dataset.

Data Preparation

This input document is passed through the Type Converter Snap that is configured to automatically detect and convert the data types. In any ML pipeline, you must first analyze the input document using the Profile Snap and the Type Inspector Snap to ensure that there are no null values or that the data types are accurate. This step is skipped in this example for simplicity's sake.

Model Training

Since the training algorithm was evaluated in the Cross Validator (Classification) Snap, the Trainer (Classification) Snap is configured with the same settings:

Image Modified

The output from this Snap is as shown below:

Image Modified

The model in the Trainer (Classification) Snap's output is written into a file using the File Writer Snap which is configured as shown below:

Image Modified

This model is used to predict the Balance Class for an unlabeled dataset. See Weight Balance Classification – Testing for details.

Download this pipeline.

Additional Example

The following use case demonstrates a real-world scenario for using this Snap:

Downloads

Multiexcerpt include macro
namedownload_instructions
pageOpenAPI

Attachments
patterns*.slp, *.zip

Insert excerpt
ML Core Snap Pack
ML Core Snap Pack
nopaneltrue