Classify
Classify[{example1class1,example2class2,…}]
generates a ClassifierFunction[…] based on the examples and classes given.
Classify[{example1,example2,…}{class1,class2,…}]
also generates a ClassifierFunction[…] based on the examples and classes given.
Classify[class1{example11,example12,…},class2{example21,…},…]
generates a ClassifierFunction[…] based on an association of classes with their examples.
Classify[training,data]
attempts to classify data using a classifier function deduced from the training set given.
Classify["name",data]
attempts to classify data using the built-in classifier function represented by "name".
Classify[…,data,prop]
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"n probabilities for the n most likely classes "Probability"class probability 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 "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 "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 - The following options can be given:
-
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 PerformanceGoal Automatic aspects of performance to try to optimize 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 RandomSeeding 1234 what seeding of pseudorandom generators should be done internally - Possible settings for PerformanceGoal include:
-
"Memory" minimize storage requirements of the predictor "Quality" maximize accuracy of the predictor "Speed" maximize speed of the predictor "TrainingSpeed" minimize time spent producing the predictor Automatic automatic tradeoff among speed, accuracy, and memory {goal1,goal2,…} automatically combine goal1, goal2, etc - Possible settings for Method include:
-
"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 - 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 - 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[…].
- Classify[…,FeatureExtractor"Minimal"] indicates that the internal preprocessing should be as simple as possible.
Examples
open allclose allBasic Examples (2)
Train a classifier function on labeled examples:
| In[1]:= |
Use the classifier function to classify a new unlabeled example:
Obtain classification probabilities for this example:
Plot the probability that the class of an example is "A" as a function of the feature:
The training and the classification can be performed in one step:
Train a classifier with multiple features:
Scope (16)
Options (17)
Applications (7)
Possible Issues (1)
Neat Examples (2)
See Also
ClassifierFunction ClassifierMeasurements ClassifierInformation Predict ActiveClassification SequencePredict ClusterClassify LogitModelFit Nearest FindClusters Interpreter DimensionReduce ExampleData LanguageIdentify ImageIdentify TextRecognize