ClassifierFunction
✖
ClassifierFunction
Details and Options




- ClassifierFunction works like Function.
- ClassifierFunction[…][data] attempts to classify data, returning the class in which data is considered most likely to be.
- ClassifierFunction[…][{data1,data2,…}] attempts to classify all the datai.
- ClassifierFunction[…][data,prop] gives the specified property of the classification associated with data.
- Possible properties applicable to all methods include:
-
"Decision" best class according to the probabilities and the utility function "TopProbabilities" probabilities for most likely classes "TopProbabilities"n probabilities for the n most likely classes "Probability"class probability for a specific class "Probabilities" association of probabilities for all possible classes "SHAPValues" Shapley additive feature explanations for each example "Properties" list of all properties available - "SHAPValues" assesses the contribution of features by comparing predictions with different sets of features removed and then synthesized. The option MissingValueSynthesis can be used to specify how the missing features are synthesized. SHAP explanations are given as odds ratio multipliers with respect to the class training prior. "SHAPValues"n can be used to control the number of samples used for the numeric estimations of SHAP explanations.
- ClassifierFunction[…][data,…,opts] specifies that the classifier should use the options opts when applied to data.
- Possible options are:
-
ClassPriors Automatic explicit prior probabilities for classes IndeterminateThreshold Automatic below what probability to return Indeterminate MissingValueSynthesis Automatic how to synthesize missing values PerformanceGoal Automatic which aspect of performance to optimize TargetDevice "CPU" the target device on which to perform training RecalibrationFunction Automatic how to post-process class probabilities UtilityFunction Automatic utility expressed as a function of actual and predicted class - A ClassifierFunction[…] trained in an older version of the Wolfram Language will still work in the current version.
- Classify[net] can be used to convert a NetChain or NetGraph representing a classifier into a ClassifierFunction[…].
- Classify[ClassifierFunction[…],opts], can be used to update the values of PerformanceGoal, ClassPriors, IndeterminateThreshold, UtilityFunction or FeatureExtractor of the classifier.
- In Classify[ClassifierFunction[…],FeatureExtractorfe], the FeatureExtractorFunction[…] fe will be prepended to the existing feature extractor.
- Information[ClassifierFunction[…]] generates an information panel about the classifier and its estimated performances.
- Information[ClassifierFunction[…],prop] can be used to obtain specific properties.
- Information of a ClassifierFunction may include the following properties:
-
"Accuracy" estimated accuracy of the classifier "BatchEvaluationTime" marginal time to predict one example when a batch is given "Classes" list of classes that the classifier can return "ClassNumber" number of classes that the classifier can return "EvaluationTime" time needed to classify one example "ExampleNumber" number of training examples "FeatureTypes" feature types of the classfier input "FunctionMemory" memory needed to store the classifier "FunctionProperties" all classification properties available for this classifier "IndeterminateThreshold" value of IndeterminateThreshold used by the classifier "LearningCurve" performance as a function of the training set size "MaxTrainingMemory" maximum memory used during training "MeanCrossEntropy" estimated mean cross entropy of the classifier "Method" value of Method used by the classifier "MethodDescription" summary of the method "MethodOption" full method option to be reused in a new training "MethodParameters" parameter settings of the method "Properties" all information properties available for this classifier "FeatureExtractor" feature extractor as FeatureExtractorFunction "TrainingClassPriors" the distribution of classes seen during training "TrainingTime" time used by Classify to generate the classifier "UtilityFunction" value of UtilityFunction used by the classifier - Information properties also include all method suboptions.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Create a ClassifierFunction with Classify and a list of labeled examples:

https://wolfram.com/xid/0g7e5i7yiky-b9dzea

Classify an unlabeled example with the ClassifierFunction:

https://wolfram.com/xid/0g7e5i7yiky-l0fphr


https://wolfram.com/xid/0g7e5i7yiky-i8ukky

Return the probabilities of the classes given the feature of an example:

https://wolfram.com/xid/0g7e5i7yiky-5t4ktv

Return the sorted probabilities of the most likely classes:

https://wolfram.com/xid/0g7e5i7yiky-klyxkz

Return the probability of the most probable class:

https://wolfram.com/xid/0g7e5i7yiky-o7xoyn

Return the probability of a given class:

https://wolfram.com/xid/0g7e5i7yiky-bgq0f

Plot the probability of class "B" as a function of the feature:

https://wolfram.com/xid/0g7e5i7yiky-oa6egz

Generate a ClassifierFunction using multiple features:

https://wolfram.com/xid/0g7e5i7yiky-6d3z0t

Use the function on a new example:

https://wolfram.com/xid/0g7e5i7yiky-q87iwn

Classify an example that has missing features:

https://wolfram.com/xid/0g7e5i7yiky-pjaio8

Get the probabilities for the most probable classes:

https://wolfram.com/xid/0g7e5i7yiky-v3ik3x

Scope (5)Survey of the scope of standard use cases
Create a function classifying textual data:

https://wolfram.com/xid/0g7e5i7yiky-vcqdub


https://wolfram.com/xid/0g7e5i7yiky-hhhr2x

Obtain information on the function:

https://wolfram.com/xid/0g7e5i7yiky-jn5tqy

Obtain the properties that can be used by this function:

https://wolfram.com/xid/0g7e5i7yiky-kwj0qq


https://wolfram.com/xid/0g7e5i7yiky-vvh6kg

Generate a classifier measurements object of the function applied to a test set:

https://wolfram.com/xid/0g7e5i7yiky-duh5q9

Get the accuracy from the function on the test set:

https://wolfram.com/xid/0g7e5i7yiky-cbhd3s

Visualize the confusion matrix:

https://wolfram.com/xid/0g7e5i7yiky-4pfth2

Generate a classifier function whose input is an association:

https://wolfram.com/xid/0g7e5i7yiky-pl8yra

Use the function on an example:

https://wolfram.com/xid/0g7e5i7yiky-10r04a

Classify examples containing missing features:

https://wolfram.com/xid/0g7e5i7yiky-deouc6


https://wolfram.com/xid/0g7e5i7yiky-ooqlup

Store the ClassifierFunction[…] into a file using the "WMLF" format:

https://wolfram.com/xid/0g7e5i7yiky-qro8f2

https://wolfram.com/xid/0g7e5i7yiky-ezpjam

https://wolfram.com/xid/0g7e5i7yiky-9goiy9

Load the classifier from the file using Import:

https://wolfram.com/xid/0g7e5i7yiky-iuml56

Use the loaded classifier on new data:

https://wolfram.com/xid/0g7e5i7yiky-u2wn4p


https://wolfram.com/xid/0g7e5i7yiky-8dxsp7

Train a classifier to predict a person's odds of surviving or dying in the Titanic crash:

https://wolfram.com/xid/0g7e5i7yiky-t1tf33

Calculate the prior odds of a passenger dying:

https://wolfram.com/xid/0g7e5i7yiky-of8sjz

Use the classifier to predict the odds of a person dying:

https://wolfram.com/xid/0g7e5i7yiky-0z7ebi

Get an explanation of how each feature multiplied the model's predicted odds of a class:

https://wolfram.com/xid/0g7e5i7yiky-h0rxx8

Compare the model's explanation of feature impact to the base rate odds:

https://wolfram.com/xid/0g7e5i7yiky-b1m3d3


Options (6)Common values & functionality for each option
ClassPriors (1)
Train a classifier on an imbalanced dataset:

https://wolfram.com/xid/0g7e5i7yiky-g33b9h

https://wolfram.com/xid/0g7e5i7yiky-8p5txa

The example 5False is classified as True:

https://wolfram.com/xid/0g7e5i7yiky-s227oj


https://wolfram.com/xid/0g7e5i7yiky-ia8b5e

Classify this example with a uniform prior over classes:

https://wolfram.com/xid/0g7e5i7yiky-kafd4s


https://wolfram.com/xid/0g7e5i7yiky-bj1v9f

The class priors of a classifier can also be updated after training:

https://wolfram.com/xid/0g7e5i7yiky-45vl1r


https://wolfram.com/xid/0g7e5i7yiky-9fyrxe

IndeterminateThreshold (1)

https://wolfram.com/xid/0g7e5i7yiky-f26y4p

https://wolfram.com/xid/0g7e5i7yiky-2l2lc2

Obtain class probabilities for an example:

https://wolfram.com/xid/0g7e5i7yiky-lfqvzb

The most probable class is chosen as the prediction:

https://wolfram.com/xid/0g7e5i7yiky-u7mhh

No prediction is made if no class probabilities exceed a specified probability threshold:

https://wolfram.com/xid/0g7e5i7yiky-wrck2

Update the value of the threshold permanently:

https://wolfram.com/xid/0g7e5i7yiky-m6emr6


https://wolfram.com/xid/0g7e5i7yiky-r6tarl

RecalibrationFunction (2)

https://wolfram.com/xid/0g7e5i7yiky-4aizph

Compute the class probabilities of a new example:

https://wolfram.com/xid/0g7e5i7yiky-yagshs

Check if the model has been calibrated:

https://wolfram.com/xid/0g7e5i7yiky-nw6el1

Temporarily set a recalibration function to apply to the probabilities:

https://wolfram.com/xid/0g7e5i7yiky-nh9ww

Set a permanent recalibration function to apply to the probabilities:

https://wolfram.com/xid/0g7e5i7yiky-yghi42

Compute the class probabilities of a new example:

https://wolfram.com/xid/0g7e5i7yiky-p9pr10

Remove the recalibration function from the classifier:

https://wolfram.com/xid/0g7e5i7yiky-yyc7ct

https://wolfram.com/xid/0g7e5i7yiky-2pli6l
Create a nearest neighbors classifier with no calibration function:

https://wolfram.com/xid/0g7e5i7yiky-dcnt2l

The classifier is slightly overconfident:

https://wolfram.com/xid/0g7e5i7yiky-fxmvjl

Select the worst classification case in the test set:

https://wolfram.com/xid/0g7e5i7yiky-87l5rk

Evaluate the estimated probabilities:

https://wolfram.com/xid/0g7e5i7yiky-0gt5cu

Use "temperature scaling" to reduce the classifier self-confidence:

https://wolfram.com/xid/0g7e5i7yiky-6tt1id


https://wolfram.com/xid/0g7e5i7yiky-x8okg7

TargetDevice (1)
Train a classifier using a neural network:

https://wolfram.com/xid/0g7e5i7yiky-gnlysk
Evaluate the resulting classifier on system's default GPU and look at its AbsoluteTiming:

https://wolfram.com/xid/0g7e5i7yiky-4fgmey
Compare the previous timing with the one achieved by using the default CPU computation:

https://wolfram.com/xid/0g7e5i7yiky-g2ypu8
UtilityFunction (1)

https://wolfram.com/xid/0g7e5i7yiky-h3wasx

https://wolfram.com/xid/0g7e5i7yiky-lowgr7

By default, the most probable class is predicted:

https://wolfram.com/xid/0g7e5i7yiky-gwhw1


https://wolfram.com/xid/0g7e5i7yiky-omckhm

Specify a utility function that penalizes examples of class "yes" being misclassified as "no":

https://wolfram.com/xid/0g7e5i7yiky-lqwpd

Update the value of the utility function permanently:

https://wolfram.com/xid/0g7e5i7yiky-ho2veh


https://wolfram.com/xid/0g7e5i7yiky-clqi9j

Wolfram Research (2014), ClassifierFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/ClassifierFunction.html (updated 2021).
Text
Wolfram Research (2014), ClassifierFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/ClassifierFunction.html (updated 2021).
Wolfram Research (2014), ClassifierFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/ClassifierFunction.html (updated 2021).
CMS
Wolfram Language. 2014. "ClassifierFunction." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ClassifierFunction.html.
Wolfram Language. 2014. "ClassifierFunction." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ClassifierFunction.html.
APA
Wolfram Language. (2014). ClassifierFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ClassifierFunction.html
Wolfram Language. (2014). ClassifierFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ClassifierFunction.html
BibTeX
@misc{reference.wolfram_2025_classifierfunction, author="Wolfram Research", title="{ClassifierFunction}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ClassifierFunction.html}", note=[Accessed: 25-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_classifierfunction, organization={Wolfram Research}, title={ClassifierFunction}, year={2021}, url={https://reference.wolfram.com/language/ref/ClassifierFunction.html}, note=[Accessed: 25-April-2025
]}