generates a ClassifierFunction that attempts to predict classi from the example ini.
attempts to predict the output associated with input from the training examples given.
Details and Options




- Classify is used to train algorithms to categorize data into classes based on observed patterns.
- Classification is a supervised learning approach commonly employed for tasks such as email filtering, image and handwriting recognition, medical diagnosis based on pattern identification, and predicting customer behavior in business analytics.
- Classify can be used on many types of data, including numerical, textual, sounds, and images, as well as combinations of these.
- Complex expressions are automatically converted to simpler features like numbers or classes.
- The final model type and hyperparameter values are selected using cross-validation on the training data.
- The training data can have the following structure:
-
{in1out1,in2out2,…} a list of Rule between input and output {in1,in2,…}{out1,out2,…} a Rule between inputs and corresponding outputs {list1,list2,…}n the nth element of each List as the output {assoc1,assoc2,…}"key" the "key" element of each Association as the output Dataset[…]column the specified column of Dataset as the output Tabular[…]column the specified column of Tabular as the output - In addition, special forms of data include:
-
"name" a built-in classifier function FittedModel[…] a fitted model converted into a ClassifierFunction NetChain[…],NetGraph[…] convert a net representing a classifier into a ClassifierFunction - Each example input ini can be a single data element, a list {feature1, …} or an association <"feature1"value1,… > .
- Each example output outi can be any atomic expression like a string, an integer or a boolean.
- The prediction properties prop are the same as in ClassifierFunction. They include:
-
"Decision" best class according to probabilities and 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.
- Examples of built-in classifier functions include:
-
"CountryFlag" which country a flag image is for "FacebookTopic" which topic a Facebook post is about "FacialAge" estimated age from a face "FacialExpression" what type of expression a face displays "FacialGender" what gender a face appears to be "Language" which natural language text is in "LanguageExtended" language of a text, including rare languages "NameGender" which gender a first name is "NotablePerson" what notable person an image is of "NSFWImage" whether an image is considered "not safe for work" "Profanity" whether text contains profanity "ProgrammingLanguage" which programming language text is in "Sentiment" sentiment of a social media post "Spam" whether email is spam "SpokenLanguage" which natural language audio recording is in - The following options can be given:
-
AnomalyDetector None anomaly detector used by the classifier AcceptanceThreshold Automatic rarer-probability threshold for anomaly detector ClassPriors Automatic explicit prior probabilities for classes FeatureExtractor Identity how to extract features from which to learn FeatureNames Automatic feature names to assign for input data FeatureTypes Automatic feature types to assume for input data IndeterminateThreshold 0 below what probability to return Indeterminate Method Automatic which classification algorithm to use MissingValueSynthesis Automatic how to synthesize missing values PerformanceGoal Automatic aspects of performance to try to optimize RandomSeeding 1234 what seeding of pseudorandom generators should be done internally RecalibrationFunction Automatic how to post-process class probabilities TargetDevice "CPU" the target device on which to perform training TimeGoal Automatic how long to spend training the classifier TrainingProgressReporting Automatic how to report progress during training UtilityFunction Automatic utility as function of actual and predicted class ValidationSet Automatic the set of data on which to evaluate the model during training - Possible settings for Method include:
-
"ClassDistributions" classify using learned distributions "DecisionTree" classify using a decision tree "GradientBoostedTrees" classify using an ensemble of trees trained with gradient boosting "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 Breiman–Cutler ensembles of decision trees "SupportVectorMachine" classify using a support vector machine - Using FeatureExtractor"Minimal" indicates that the internal preprocessing should be as simple as possible.
- Possible settings for PerformanceGoal include:
-
"DirectTraining" train directly on the full dataset, without model searching "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 Automatic automatic tradeoff among speed, accuracy, and memory {goal1,goal2,…} automatically combine goal1, goal2, etc. - The following settings for TrainingProgressReporting can be used:
-
"Panel" show a dynamically updating graphical panel "Print" periodically report information using Print "ProgressIndicator" show a simple ProgressIndicator "SimplePanel" dynamically updating panel without learning curves None do not report any information - Possible settings for RandomSeeding include:
-
Automatic automatically reseed every time the function is called Inherited use externally seeded random numbers seed use an explicit integer or strings as a seed - In Classify[ClassifierFunction[…],FeatureExtractorfe], the FeatureExtractorFunction[…] fe will be prepended to the existing feature extractor.
- Information can be used on the ClassifierFunction[…] obtained.



Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Train a classifier function on labeled examples:

https://wolfram.com/xid/0i1lib1d8-6cwlu3

Use the classifier function to classify a new unlabeled example:

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

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

https://wolfram.com/xid/0i1lib1d8-g98f4p

Train a classifier with multiple features:

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

Classify a new examples that may contain missing features:

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

Scope (33)Survey of the scope of standard use cases
Data Format (7)
Specify the training set as a list of rules between an input example and the output value:

https://wolfram.com/xid/0i1lib1d8-n3lf9z

Each example can contain a list of features:

https://wolfram.com/xid/0i1lib1d8-5i899g

Each example can contain an association of features:

https://wolfram.com/xid/0i1lib1d8-250cgd

Specify the training set as a list of rules between a list of inputs and a list of outputs:

https://wolfram.com/xid/0i1lib1d8-rqhpke

Specify all the data in a matrix and mark the output column:

https://wolfram.com/xid/0i1lib1d8-5kyd9k

Specify all the data in a list of associations and mark the output key:

https://wolfram.com/xid/0i1lib1d8-ihybis

Specify all the data in a dataset and mark the output column:

https://wolfram.com/xid/0i1lib1d8-7tfkv4

Data Types (13)
Numerical (3)
Predict a variable from a number:

https://wolfram.com/xid/0i1lib1d8-zhyqm6

Predict a variable from a numerical vector:

https://wolfram.com/xid/0i1lib1d8-phdgu5

Predict a variable from a numerical array of arbitrary depth:

https://wolfram.com/xid/0i1lib1d8-tdhm4r

Nominal (3)
Predict a class from a nominal value:

https://wolfram.com/xid/0i1lib1d8-btibju

Predict a class from several nominal values:

https://wolfram.com/xid/0i1lib1d8-9ljf1l


https://wolfram.com/xid/0i1lib1d8-qc5ur1

Predict a class from a mixture of nominal and numerical values:

https://wolfram.com/xid/0i1lib1d8-23kul


https://wolfram.com/xid/0i1lib1d8-e4z5l2

Quantities (1)
Train a classifier on data including Quantity objects:

https://wolfram.com/xid/0i1lib1d8-beyyeu

Use the classifier on a new example:

https://wolfram.com/xid/0i1lib1d8-ljemp1

Predict the most likely price when only the "Price" is known:

https://wolfram.com/xid/0i1lib1d8-f6pdpt

Text (1)
Colors (1)
Images (1)
Sequences (1)
Missing Data (2)
Train a classifier on a dataset with missing features:

https://wolfram.com/xid/0i1lib1d8-iqtxzh

Classify examples containing missing features as well:

https://wolfram.com/xid/0i1lib1d8-k2kfsg

Train a classifier on a dataset with named features. The order of the keys does not matter. Keys can be missing:

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

Classify examples containing missing features:

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

Information (4)
Extract information from a trained predictor:

https://wolfram.com/xid/0i1lib1d8-rwllrs

Get information about the input features:

https://wolfram.com/xid/0i1lib1d8-zqh27x

Get the feature extractor used to process the input features:

https://wolfram.com/xid/0i1lib1d8-ly2pte

Get a list of the supported properties:

https://wolfram.com/xid/0i1lib1d8-m3ykix

Built-in Classifiers (9)
Use the "Language" built-in classifier to detect the language in which a text is written:

https://wolfram.com/xid/0i1lib1d8-kc7oue

Use it to detect the language of examples:

https://wolfram.com/xid/0i1lib1d8-0yd698

Obtain the probabilities for the most likely languages:

https://wolfram.com/xid/0i1lib1d8-tn5q76

Restrict the classifier to some languages with the option ClassPriors:

https://wolfram.com/xid/0i1lib1d8-1v24g1

Use the "FacebookTopic" built-in classifier to detect the topic of a Facebook post:

https://wolfram.com/xid/0i1lib1d8-h5g7hz


https://wolfram.com/xid/0i1lib1d8-3q3s5n

Unrecognized topics or languages will return Indeterminate:

https://wolfram.com/xid/0i1lib1d8-kuqzlj

Use the "CountryFlag" built-in classifier to recognize a country from its flag:

https://wolfram.com/xid/0i1lib1d8-v2jwas

Use the "NameGender" built-in classifier to get the probable sex of a person from their first name:

https://wolfram.com/xid/0i1lib1d8-6foxxr

Use the "NotablePerson" built-in classifier to determine what notable person is depicted in the given image:

https://wolfram.com/xid/0i1lib1d8-waiip

Use the "Sentiment" built-in classifier to infer the sentiment of a social media message:

https://wolfram.com/xid/0i1lib1d8-y4ge3

Use the "Profanity" built-in classifier to return True if a text contains strong language:

https://wolfram.com/xid/0i1lib1d8-pxy5c0

Use the "Spam" built-in classifier to detect if an email is spam from its content:

https://wolfram.com/xid/0i1lib1d8-xxd7gv

Use the "SpokenLanguage" built-in classifier to detect the language in which a text is written:

https://wolfram.com/xid/0i1lib1d8-spmw9y

Options (23)Common values & functionality for each option
AcceptanceThreshold (1)
Create a classifier with an anomaly detector:

https://wolfram.com/xid/0i1lib1d8-xbvaeq

Change the value of the acceptance threshold when evaluating the classifier:

https://wolfram.com/xid/0i1lib1d8-rmozzx


https://wolfram.com/xid/0i1lib1d8-v8fyvh

Permanently change the value of the acceptance threshold in the classifier:

https://wolfram.com/xid/0i1lib1d8-5oakn


https://wolfram.com/xid/0i1lib1d8-vsnuhj

AnomalyDetector (1)
Create a classifier and specify that an anomaly detector should be included:

https://wolfram.com/xid/0i1lib1d8-qxo89p

Evaluate the classifier on an non-anomalous input:

https://wolfram.com/xid/0i1lib1d8-0j6dyn

Evaluate the classifier on an anomalous input:

https://wolfram.com/xid/0i1lib1d8-1h9pb9

The "Probabilities" property is not affected by the anomaly detector:

https://wolfram.com/xid/0i1lib1d8-0f8nbd

Temporarily remove the anomaly detector from the classifier:

https://wolfram.com/xid/0i1lib1d8-8hvu12

Permanently remove the anomaly detector from the classifier:

https://wolfram.com/xid/0i1lib1d8-ro1s8l


https://wolfram.com/xid/0i1lib1d8-7pl50v

ClassPriors (1)
Train a classifier on an imbalanced dataset:

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

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

The training example 5False is classified as True:

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


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

Classify this example with a uniform prior over classes instead of the imbalanced training prior:

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


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

The class priors can be specified during the training:

https://wolfram.com/xid/0i1lib1d8-vezk1f


https://wolfram.com/xid/0i1lib1d8-vhr4xh


https://wolfram.com/xid/0i1lib1d8-wieovz


https://wolfram.com/xid/0i1lib1d8-io5u5g

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

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


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


https://wolfram.com/xid/0i1lib1d8-mgbek1

FeatureExtractor (3)
Train a FeatureExtractorFunction on a simple dataset:

https://wolfram.com/xid/0i1lib1d8-x55qsg

https://wolfram.com/xid/0i1lib1d8-zt6cqe

Use the feature extractor function as a preprocessing step in Classify:

https://wolfram.com/xid/0i1lib1d8-ci0jay

Train a classifier on texts preprocessed by custom functions and an extractor method:

https://wolfram.com/xid/0i1lib1d8-y7aarg


https://wolfram.com/xid/0i1lib1d8-02aohy

Create a feature extractor and extract features from a dataset of texts:

https://wolfram.com/xid/0i1lib1d8-encwxs

Train a classifier on the extracted features:

https://wolfram.com/xid/0i1lib1d8-mh79x5

Join the feature extractor to the classifier:

https://wolfram.com/xid/0i1lib1d8-wqrrwd

The classifier can now be used on the initial input type:

https://wolfram.com/xid/0i1lib1d8-7kos20

FeatureNames (2)
Train a classifier and give a name to each feature:

https://wolfram.com/xid/0i1lib1d8-48k90i

Use the association format to predict a new example:

https://wolfram.com/xid/0i1lib1d8-f3cwzr

The list format can still be used:

https://wolfram.com/xid/0i1lib1d8-6665m0

Train a classifier on a training set with named features and use FeatureNames to set their order:

https://wolfram.com/xid/0i1lib1d8-ida89d

Features are ordered as specified:

https://wolfram.com/xid/0i1lib1d8-mo755h

Classify a new example from a list:

https://wolfram.com/xid/0i1lib1d8-3pb471

FeatureTypes (2)
Train a classifier on data where the feature is intended to be a sequence of tokens:

https://wolfram.com/xid/0i1lib1d8-uo90yy

Classify wrongly assumed that examples contained two different text features:

https://wolfram.com/xid/0i1lib1d8-78wwz4

The following classification will output an error message:

https://wolfram.com/xid/0i1lib1d8-vev84w


Force Classify to interpret the feature as a "NominalSequence":

https://wolfram.com/xid/0i1lib1d8-kaf4tc


https://wolfram.com/xid/0i1lib1d8-n4zzii


https://wolfram.com/xid/0i1lib1d8-ez4pae

Train a classifier with named features:

https://wolfram.com/xid/0i1lib1d8-dbyvuq

https://wolfram.com/xid/0i1lib1d8-3dzzwj

Both features have been considered numerical:

https://wolfram.com/xid/0i1lib1d8-g00qh3

Specify that the feature "gender" should be considered nominal:

https://wolfram.com/xid/0i1lib1d8-3z3lut


https://wolfram.com/xid/0i1lib1d8-8tgdi

IndeterminateThreshold (1)
Specify a probability threshold when training the classifier:

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

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

Obtain class probabilities for an example:

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

As there are no class probabilities above 0.9, no prediction is made:

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

Specifying a threshold when classifying supersedes the trained threshold:

https://wolfram.com/xid/0i1lib1d8-jiveeg

Update the value of the threshold in the classifier:

https://wolfram.com/xid/0i1lib1d8-otww78


https://wolfram.com/xid/0i1lib1d8-mdl8cu

Method (3)

https://wolfram.com/xid/0i1lib1d8-dju6nw

https://wolfram.com/xid/0i1lib1d8-2ua27x

Train a random forest classifier:

https://wolfram.com/xid/0i1lib1d8-5urh95

Plot the probability of class "a" given the feature for both classifiers:

https://wolfram.com/xid/0i1lib1d8-354mwb

Train a nearest neighbors classifier:

https://wolfram.com/xid/0i1lib1d8-2rcb2u

https://wolfram.com/xid/0i1lib1d8-hruxbw

Find the classification accuracy on a test set:

https://wolfram.com/xid/0i1lib1d8-bv2blv

https://wolfram.com/xid/0i1lib1d8-e0jek4

In this example, using a naive Bayes classifier reduces the classification accuracy:

https://wolfram.com/xid/0i1lib1d8-h9y3dv


https://wolfram.com/xid/0i1lib1d8-btdg1t

However, using a naive Bayes classifier reduces the classification time:

https://wolfram.com/xid/0i1lib1d8-c4pe3


https://wolfram.com/xid/0i1lib1d8-v05k66

MONK's problems consist of synthetic binary classification datasets used for comparing the performance of different classifiers. Generate the dataset for the second MONK problem:

https://wolfram.com/xid/0i1lib1d8-kx548d
Test the accuracy of each available classifier by training on 169 examples and testing on the entire dataset:

https://wolfram.com/xid/0i1lib1d8-25pljo

https://wolfram.com/xid/0i1lib1d8-elys4b

MissingValueSynthesis (1)
Train a classifier with two input features:

https://wolfram.com/xid/0i1lib1d8-uarmq6

Get class probabilities for an example that has a missing value:

https://wolfram.com/xid/0i1lib1d8-00e8xt

Set the missing value synthesis to replace each missing variable with its estimated most likely value given known values (which is the default behavior):

https://wolfram.com/xid/0i1lib1d8-e03411

Replace missing variables with random samples conditioned on known values:

https://wolfram.com/xid/0i1lib1d8-od0kq

Averaging over many random imputations is usually the best strategy and allows obtaining the uncertainty caused by the imputation:

https://wolfram.com/xid/0i1lib1d8-fqeata

Specify a learning method during training to control how the distribution of data is learned:

https://wolfram.com/xid/0i1lib1d8-lyqv3u

Classify an example with missing values using the "KernelDensityEstimation" distribution to condition values:

https://wolfram.com/xid/0i1lib1d8-hwf88u

Provide an existing LearnedDistribution at training to use it when imputing missing values during training and later evaluations:

https://wolfram.com/xid/0i1lib1d8-8ni5d

Specify an existing LearnedDistribution to synthesize missing values for an individual evaluation:

https://wolfram.com/xid/0i1lib1d8-z7m9zi

Control both the learning method and the evaluation strategy by passing an association at training:

https://wolfram.com/xid/0i1lib1d8-ktalq9

RecalibrationFunction (1)

https://wolfram.com/xid/0i1lib1d8-mf2v5t
Train a random forest classifier without any recalibration:

https://wolfram.com/xid/0i1lib1d8-7n1hut

Visualize the calibration curve on a test set:

https://wolfram.com/xid/0i1lib1d8-r7qryw

Train a random forest classifier with recalibration:

https://wolfram.com/xid/0i1lib1d8-6z5iap

Visualize the calibration curve on a test set:

https://wolfram.com/xid/0i1lib1d8-rkvfws

PerformanceGoal (1)
Train a classifier with an emphasis on training speed:

https://wolfram.com/xid/0i1lib1d8-9reyva

https://wolfram.com/xid/0i1lib1d8-hq956d


https://wolfram.com/xid/0i1lib1d8-5pj95i

Compute the classification accuracy on a test set:

https://wolfram.com/xid/0i1lib1d8-vgczcx

https://wolfram.com/xid/0i1lib1d8-cqph3r

By default, a compromise between classification speed and performance is sought:

https://wolfram.com/xid/0i1lib1d8-2udre2


https://wolfram.com/xid/0i1lib1d8-uqqrve


https://wolfram.com/xid/0i1lib1d8-gdh7l0

With the same data, train a classifier with an emphasis on training speed and memory:

https://wolfram.com/xid/0i1lib1d8-dctcxo

The classifier uses less memory, but is also less accurate:

https://wolfram.com/xid/0i1lib1d8-wk9ft5


https://wolfram.com/xid/0i1lib1d8-pq5t0t

TargetDevice (1)
Train a classifier on the system's default GPU using a neural network and look at the AbsoluteTiming:

https://wolfram.com/xid/0i1lib1d8-gnlysk
Compare the previous result with the one achieved by using the default CPU computation:

https://wolfram.com/xid/0i1lib1d8-lm8aa7
TimeGoal (2)
Train a classifier while specifying a total training time of 5 seconds:

https://wolfram.com/xid/0i1lib1d8-idsajs


https://wolfram.com/xid/0i1lib1d8-c4k8t4


https://wolfram.com/xid/0i1lib1d8-kiebhl
Train a classifier while specifying a target training time of 0.1 seconds:

https://wolfram.com/xid/0i1lib1d8-ef9kd

The classifier reached an accuracy of about 90%:

https://wolfram.com/xid/0i1lib1d8-roiqri

Train a classifier while specifying a target training time of 5 seconds:

https://wolfram.com/xid/0i1lib1d8-eez9o1

The classifier reached an accuracy of about 99%:

https://wolfram.com/xid/0i1lib1d8-j8zh5z

TrainingProgressReporting (1)

https://wolfram.com/xid/0i1lib1d8-pac3cx
Show training progress interactively during training of a classifier:

https://wolfram.com/xid/0i1lib1d8-rhqvee

Show training progress interactively without plots:

https://wolfram.com/xid/0i1lib1d8-qt9tmk

Print training progress periodically during training:

https://wolfram.com/xid/0i1lib1d8-me00oh
Show a simple progress indicator:

https://wolfram.com/xid/0i1lib1d8-jyd4wa


https://wolfram.com/xid/0i1lib1d8-uhwsza
UtilityFunction (1)

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

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

By default, the most probable class is predicted:

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


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

This corresponds to the following utility specification:

https://wolfram.com/xid/0i1lib1d8-eqeg3q

Train a classifier that penalizes examples of class "yes" being misclassified as "no":

https://wolfram.com/xid/0i1lib1d8-g7xgz

The classifier decision is different despite the probabilities being unchanged:

https://wolfram.com/xid/0i1lib1d8-iu32hr


https://wolfram.com/xid/0i1lib1d8-ny4nrx

Specifying a utility function when classifying supersedes the utility function specified at training:

https://wolfram.com/xid/0i1lib1d8-h1kfl

Update the value of the utility function in the classifier:

https://wolfram.com/xid/0i1lib1d8-fqlao5


https://wolfram.com/xid/0i1lib1d8-qfov1n

ValidationSet (1)
Train a logistic regression classifier on the Fisher iris data:

https://wolfram.com/xid/0i1lib1d8-cf6lt

https://wolfram.com/xid/0i1lib1d8-t2s4e8

Obtain the L2 regularization coefficient of the trained classifier:

https://wolfram.com/xid/0i1lib1d8-g8bxn1


https://wolfram.com/xid/0i1lib1d8-b4hon9

https://wolfram.com/xid/0i1lib1d8-9ptx3u

A different L2 regularization coefficient has been selected:

https://wolfram.com/xid/0i1lib1d8-dy1ept

Applications (10)Sample problems that can be solved with this function
Titanic Survival (2)
Load the "Titanic" dataset, which contains a list of Titanic passengers with their age, sex, ticket class, and survival:

https://wolfram.com/xid/0i1lib1d8-w0bl4c
Visualize a sample of the dataset:

https://wolfram.com/xid/0i1lib1d8-rufy9w

Train a logistic classifier on this dataset:

https://wolfram.com/xid/0i1lib1d8-dja9uy

Calculate the survival probability of a 10-year-old girl traveling in third class:

https://wolfram.com/xid/0i1lib1d8-hoh5du

Plot the survival probability as a function of age for some combinations of "class" and "sex":

https://wolfram.com/xid/0i1lib1d8-5y5co

https://wolfram.com/xid/0i1lib1d8-meudb

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

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

Calculate the prior odds of a passenger dying:

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

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

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

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

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

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

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


Fisher's Iris (3)
Train a classifier on the Fisher iris dataset to predict the species of Iris:

https://wolfram.com/xid/0i1lib1d8-b3wvm8

Predict the species of Iris from a list of features:

https://wolfram.com/xid/0i1lib1d8-24s1e

Test the accuracy of the classifier on a test set:

https://wolfram.com/xid/0i1lib1d8-cvguka


https://wolfram.com/xid/0i1lib1d8-hlttz3

Generate a confusion matrix of the classifier on this test set:

https://wolfram.com/xid/0i1lib1d8-ne53ez

Train a classifier that classifies movie review snippets as "positive" or "negative":

https://wolfram.com/xid/0i1lib1d8-ocr2tp

Classify an unseen movie review snippet:

https://wolfram.com/xid/0i1lib1d8-ji2h86

Test the accuracy of the classifier on a test set:

https://wolfram.com/xid/0i1lib1d8-cq5y6x

Import examples of the writings of Shakespeare, Oscar Wilde, and Victor Hugo to train a classifier:

https://wolfram.com/xid/0i1lib1d8-49d9yr

https://wolfram.com/xid/0i1lib1d8-qn2yor

https://wolfram.com/xid/0i1lib1d8-b2p3h2
Generate an author classifier from these texts:

https://wolfram.com/xid/0i1lib1d8-cuvwjd

Find which author new texts are from:

https://wolfram.com/xid/0i1lib1d8-tzd6fl

Image Recognition (3)
Train a digit recognizer on 100 examples from the MNIST database of handwritten digits:

https://wolfram.com/xid/0i1lib1d8-h85sr4

Use the classifier to recognize unseen digits:

https://wolfram.com/xid/0i1lib1d8-ynybo

Analyze probabilities of a misclassified example:

https://wolfram.com/xid/0i1lib1d8-mmnsmw

Train a classifier on 32 images of legendary creatures:

https://wolfram.com/xid/0i1lib1d8-vc5nut

Use the classifier to recognize unseen creatures:

https://wolfram.com/xid/0i1lib1d8-75q4ei

Train a classifier to recognize daytime from nighttime:

https://wolfram.com/xid/0i1lib1d8-u8f76m


https://wolfram.com/xid/0i1lib1d8-xqtdwa

Feature Explanation (1)
Import images of handwritten digits and select the 3s, 5s, and 8s:

https://wolfram.com/xid/0i1lib1d8-pvf3vp
Visualize a few of the images:

https://wolfram.com/xid/0i1lib1d8-wdnndg

Convert the images into their pixel values and separate their class:

https://wolfram.com/xid/0i1lib1d8-wf3du3
Train a classifier to identify the digit by its individual pixel values:

https://wolfram.com/xid/0i1lib1d8-t38zi8

Learn a simple distribution of the data that treats each pixel as independent (for speed purposes):

https://wolfram.com/xid/0i1lib1d8-0p02j7

Use the "SHAPValues" property to estimate how each pixel in an example impacted the predicted class:

https://wolfram.com/xid/0i1lib1d8-4tamwi
Take the Log to convert the "odds multiplier" SHAP values onto a scale centered at 0:

https://wolfram.com/xid/0i1lib1d8-09w05z
Look at the impact of each pixel weighted by its darkness by multiplying by the pixel values:

https://wolfram.com/xid/0i1lib1d8-jens4y
Visualize how the pixels increased (red) or decreased (blue) the model's confidence the digit was a 0 or 6:

https://wolfram.com/xid/0i1lib1d8-nksa50


Fraud Detection (1)
Train a classifier to flag suspicious transactions based on a set of features:

https://wolfram.com/xid/0i1lib1d8-7ao58t

Plot the probability of fraud based only on the transaction amount:

https://wolfram.com/xid/0i1lib1d8-jnzzz8

Display the probability of fraud based on the card type and the transaction type:

https://wolfram.com/xid/0i1lib1d8-n4t1xb

Possible Issues (1)Common pitfalls and unexpected behavior
The RandomSeeding option does not always guarantee reproducibility of the result:
Train several classifiers on the "Titanic" dataset:

https://wolfram.com/xid/0i1lib1d8-1m2tdb

https://wolfram.com/xid/0i1lib1d8-hyhthp
Compare the results when tested on a test set:

https://wolfram.com/xid/0i1lib1d8-bxxs1r

https://wolfram.com/xid/0i1lib1d8-zox5dm

Neat Examples (2)Surprising or curious use cases
Define and plot clusters sampled from normal distributions:

https://wolfram.com/xid/0i1lib1d8-5tymg2

Blend colors to reflect the probability density of the different classes for each method:

https://wolfram.com/xid/0i1lib1d8-4hjccz

https://wolfram.com/xid/0i1lib1d8-gwlkx

https://wolfram.com/xid/0i1lib1d8-bqq81r

Draw in the box to test a logistic classifier trained on the dataset ExampleData[{"MachineLearning","MNIST"}]:

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