generates a ClassifierFunction[] based on the examples and classes given.


also generates a ClassifierFunction[] based on the examples and classes given.


generates a ClassifierFunction[] based on an association of classes with their examples.


attempts to classify data using a classifier function deduced from the training set given.


attempts to classify data using the built-in classifier function represented by "name".


gives the specified property of the classification associated with data.

Details and Options

  • Classify can be used on many types of data, including numerical, textual, sounds, and images, as well as combinations of these.
  • Each examplei can be a single data element, a list of data elements, an association of data elements, or a Dataset object. In Classify[training,], training can be a Dataset object.
  • Classify[training] returns a ClassifierFunction[] that can then be applied to specific data.
  • In Classify[,data], data can be a single item or a list of items.
  • In Classify[,data,prop], properties are as given in ClassifierFunction[]; they include:
  • "Decision"best class according to probabilities and utility function
    "TopProbabilities"probabilities for most likely classes
    "TopProbabilities"nprobabilities for the n most likely classes
    "Probability"classprobability for a specific class
    "Probabilities"association of probabilities for all possible classes
    "Properties"list of all properties available
  • Examples of built-in classifier functions include:
  • "CountryFlag"which country a flag image is for
    "FacebookTopic"which topic a Facebook post is about
    "Language"which natural language text is in
    "NameGender"which gender a first name is
    "NotablePerson"what notable person an image is of
    "Profanity"whether text contains profanity
    "ProgrammingLanguage"which programming language text is in
    "Sentiment"sentiment of a social media post
    "Spam"whether email is spam
  • The following options can be given:
  • ClassPriorsAutomaticexplicit prior probabilities for classes
    FeatureExtractorIdentityhow to extract features from which to learn
    FeatureNamesAutomaticfeature names to assign for input data
    FeatureTypesAutomaticfeature types to assume for input data
    IndeterminateThreshold0below what probability to return Indeterminate
    MethodAutomaticwhich classification algorithm to use
    PerformanceGoalAutomaticaspects of performance to try to optimize
    UtilityFunctionAutomaticutility as function of actual and predicted class
    ValidationSetAutomaticdata on which to validate the generated model
  • Possible settings for PerformanceGoal include:
  • "Memory"minimize storage requirements of the classifier
    "Quality"maximize accuracy of the classifier
    "Speed"maximize speed of the classifier
    "TrainingSpeed"minimize time spent producing the classifier
    Automaticautomatic tradeoff between speed, accuracy, and memory
  • PerformanceGoal{goal1,goal2,} will automatically combine goal1, goal2, etc.
  • Possible settings for Method include:
  • "LogisticRegression"classify using probabilities from linear combinations of features
    "Markov"classify using a Markov model on the sequence of features (only for text, bag of token, etc.)
    "NaiveBayes"classify by assuming probabilistic independence of features
    "NearestNeighbors"classify from nearest neighbor examples
    "NeuralNetwork"classify using an artificial neural network
    "RandomForest"classify using BreimanCutler ensembles of decision trees
    "SupportVectorMachine"classify using a support vector machine
  • Classify[{assoc1,assoc2,}"key",] can be used to specify that the class is given by the value of "key" in each association associ.
  • Classify[{list1,list2,}n,] can be used to specify that the class is given by the value of part n in each list listi.
  • Classify[Dataset[]part,] can be used to specify that classes are given by the value of part of each row of the dataset.
  • Classify[net] can be used to convert a NetChain or NetGraph representing a classifier into a ClassifierFunction[].


open allclose all

Basic Examples  (2)

Train a classifier function on labeled examples:

Click for copyable input
Click for copyable input

Use the classifier function to classify a new unlabeled example:

Click for copyable input

Obtain classification probabilities for this example:

Click for copyable input

Classify multiple examples:

Click for copyable input

Plot the probability that the class of an example is "A" as a function of the feature:

Click for copyable input

The training and the classification can be performed in one step:

Click for copyable input
Click for copyable input

Train a classifier with multiple features:

Click for copyable input

Classify a new example:

Click for copyable input

Classify an example that has missing features:

Click for copyable input

Get the probabilities for the most probable classes:

Click for copyable input

Scope  (17)

Options  (14)

Applications  (8)

Neat Examples  (2)

See Also

ClassifierFunction  ClassifierMeasurements  ClassifierInformation  Predict  SequencePredict  ClusterClassify  LogitModelFit  Nearest  FindClusters  Interpreter  DimensionReduce  ExampleData  LanguageIdentify  ImageIdentify  TextRecognize

Introduced in 2014
| Updated in 2017