Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


  >  Docs Center  >  IDL Reference  >  Machine Learning  >  IDLmlSoftmax

IDLmlSoftmax

IDLmlSoftmax

The IDLmlSoftmax class implements a Softmax model that can be used for classification purposes.

Example


; Read data
read_seeds_example_data, data, labels, $
   N_ATTRIBUTES=nAttributes, N_EXAMPLES=nExamples, $
   N_LABELS=nLabels, UNIQUE_LABELS=uniqueLabels
 
; Shuffle data
IDLmlShuffle, data, labels
 
; Normalize data
Normalizer = IDLmlVarianceNormalizer(data)
Normalizer.Normalize, data
 
; Partition data
Part = IDLmlPartition({train:80, test:20}, data, labels)
 
; Define the model
Classifier = IDLmlSoftmax(nAttributes, uniqueLabels)
For i=0, 100 do loss = Classifier.Train(part.train['data'], $
  LABELS=part.train['labels'])
confMatrix= IDLmlTestClassifier(Classifier, part.test['data'], $
  part.test['labels'], ACCURACY=accuracy)
Print, 'Model accuracy:', accuracy 
 
; Classify the first example
Print, Classifier.Classify(data[*,0])

Syntax


Result = IDLmlSoftmax(Nattributes, Outputs [, Keywords=Value])

Arguments


Nattributes

Specify the number of attributes that the input data will be required to have.

Outputs

Specify the array of possible outputs. It can be an array of numbers or strings. Outputs can also be a scalar number; in that case, the possible output values will be all integer numbers from 0 to 'outputs' minus one.

Keywords


LAMBDA (optional)

Specify the contribution of L2 regularization in the loss function. By default, this is 0. Increasing this argument may help with model overfitting issues.

SEED (optional)

If repeatability is desired (such as for testing), set this keyword to the seed variable used to randomly initialize the weights.

Properties


CLASS_MAP

A hash that maps internal classification values to desired labels, if the model was defined using custom labels.

LAMBDA

The L2 regularization factor used to calculate the loss and gradient when training the model.

NATTRIBUTES

The number of input attributes the model requires.

NOUTPUTS

The number of possible outputs.

OUTPUTS

An array of possible outputs.

WEIGHTS

The current weight values that make up the Softmax model. Weights represent the strength of connection between the network units. Initially, they are a set of random numbers, but as the model is trained the weights will change, reflecting a model that is better trained.

Methods


IDLmlSoftmax::Classify


The IDLmlSoftmax::Classify method assigns each example to an output class, returning an array of label results.

Syntax


Result = Obj->[IDLmlSoftmax::]Classify(Features [, Keywords=Value])

Return Value


The method returns an array of class values that correspond to the data provided.

Arguments


Features

Specify an array of features of size n x m, where n is the number of attributes and m is the number of examples.

Keywords


LOSS (optional)

Set this keyword to a variable that will contain the loss result, which is a unitless number that indicates how closely the model fits the training data. Loss is defined as the total error computed by the loss function specified in the LOSS_FUNCTION parameter when creating the model, which defaults to Mean Squared Error if not specified.

SCORES (optional)

Set this keyword to an array of size m, where m is the number of examples containing the actual scores associated with the features. Use this keyword to pass in the actual scores associated with the features if you want to calculate the loss.

UNMAPPED_CLASSES (optional)

Set this keyword to a variable that will contain the actual internal class values for the classification results.

IDLmlSoftmax::Evaluate


The IDLmlSoftmax::Evaluate method evaluates a number of features and returns an array of scores that represent how closely each feature matches each output.

Syntax


Result = Obj->[IDLmlSoftmax::]Evaluate(Features [, Keywords=Value])

Return Value


This method returns the scores associated with the features. Scores represent the actual numerical outputs obtained by the model in response to a number of inputs.

Arguments


Features

Specify an array of features of size n x m, where n is the number of attributes and m is the number of examples.

Keywords


LOSS (optional)

Set this keyword to a variable that will contain the loss result, which is a unitless number that indicates how closely the model fits the training data. Loss is defined as the total error computed by the loss function specified in the LOSS_FUNCTION parameter when creating the model, which defaults to Mean Squared Error if not specified.

SCORES (optional)

Set this keyword to an array of size m, where m is the number of examples containing the actual scores associated with the features. Use this keyword to pass in the actual scores associated with the features if you want to calculate the loss.

IDLmlSoftmax::Restore


The IDLmlSoftmax::Restore static method restores the classifier from a file.

Syntax


Result = IDLmlSoftmax.Restore(Filename)

Return Value


A reference to the object instance restored from the file.

Arguments


Filename

Specify the name of the file to restore.

Keywords


None

IDLmlSoftmax::Save


The IDLmlSoftmax::Save method saves the classifier to a file.

Syntax


Obj->[IDLmlSoftmax::]Save, Filename

Arguments


Filename

Specify the name of the file to save.

Keywords


None

IDLmlSoftmax::Train


The IDLmlSoftmax::Train method performs training on the model and the loss, which is a unitless number that indicates how closely the model fits the training data.

Syntax


Result = Obj->[IDLmlSoftmax::]Train(Features [, Keywords=Value])

Return Value


This method returns the loss, which is a unitless number that indicates how closely the model fits the training data.

Arguments


Features

Specify an array of features of size n x m, where n is the number of attributes and m is the number of examples.

Keywords


CALLBACK_FUNCTION (optional)

An optional string with the name of an IDL function to be called on each training iteration. The callback function must accept two arguments: loss and state. The callback function must return 1 (!true) if the training should perform another iteration, or 0 (!false) if it should stop training.

LABELS (optional)

An array of size m, where m is the number of examples, containing the actual labels associated with the features.

LEARNING_RATE (optional)

Set this keyword to the step size to use for updating the model weights. The default value is 0.1.

SCORES (optional)

An array of size m, where m is the number of examples containing the actual scores associated with the features.

TRAIN_STATE (optional)

Specify optional user data to provide for the callback function.

Version History


8.7.1

Introduced

See Also


IDLmlAutoEncoder, IDLmlFeedForwardNeuralNetwork, IDLmlKMeans, IDLmlSupportVectorMachineClassification, IDLmlSupportVectorMachineRegression, IDLmlTestClassifier



© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us