Train a Classifier Automatically
Author
Wolfram Research, Inc.
Title
Train a Classifier Automatically
Description
Training a classifier requires choosing a method, hyperparameters, preprocessing functions and so on.
Category
Essays, Posts & Presentations
Keywords
High-Level Machine Learning, Train a Classifier Automatically", automatic machine learning, autoML, supervised learning, classification, training, accuracy, learning curve
URL
http://www.notebookarchive.org/2022-07-bzzmjcr/
DOI
https://notebookarchive.org/2022-07-bzzmjcr
Date Added
2022-07-26
Date Last Modified
2022-07-26
File Size
362.82 kilobytes
Supplements
Rights
Redistribution rights reserved
Download
Open in Wolfram Cloud
Train a Classifier Automatically
Train a Classifier Automatically
Training a classifier requires choosing a method, hyperparameters, preprocessing functions and so on. makes all these choices automatically through a procedure consisting of experiments done on data subsets. Here is an example of this function in action.
Classify
Train a classifier on the dataset.
"UCILetter"
In[]:=
data=ExampleData[{"MachineLearning","UCILetter"},"TrainingData"];
In[]:=
RandomSample[data,5]
Out[]=
{{4,2,5,3,2,6,8,5,8,7,10,9,3,9,1,8}U,{7,10,5,5,2,6,8,6,8,11,7,11,2,8,5,9}C,{2,1,3,2,2,7,7,7,4,7,6,8,2,8,2,8}O,{4,7,6,5,3,6,8,6,8,7,9,9,3,9,1,8}U,{4,7,5,5,5,7,7,6,6,7,6,8,6,8,3,8}H}
In[]:=
c=Classify[data]
Out[]=
ClassifierFunction
| |||||
This object cannot be used as input. |
Use the classifier on a new example.
In[]:=
c[{4,10,6,7,9,9,6,4,3,6,7,7,9,8,5,6},"TopProbabilities"]
Out[]=
{U0.730937,H0.185131}
Obtain general information about the classifier and the training procedure.
In[]:=
Information[c]
Out[]=
Classifier information | ||||||||||||||||||||||
|
In[]:=
Information[c,"MethodOption"]
Out[]=
Method{NearestNeighbors,NeighborsNumber5,DistributionSmoothing0.5,NearestMethodScan}
Visualize the learning curve of each method used by the automatic training procedure.
In[]:=
Information[c,"LearningCurve"]
Out[]=
Obtain the accuracy estimated by the training procedure.
In[]:=
Information[c,"Accuracy"]
Out[]=
0.949
±
0.012
Compare with the accuracy measured on a test set.
In[]:=
test=ExampleData[{"MachineLearning","UCILetter"},"TestData"];
In[]:=
ClassifierMeasurements[c,test,"Accuracy",ComputeUncertaintyTrue]
Out[]=
0.947
±
0.004
Retrain the classifier while specifying a training time of 2 minutes.
In[]:=
clong=Classify[data,TimeGoal]
2
min
Out[]=
ClassifierFunction
| |||||
This object cannot be used as input. |
Compare the learning curves with previous ones.
In[]:=
Information[clong,"LearningCurve"]
Out[]=
Cite this as: Wolfram Research, Inc., "Train a Classifier Automatically" from the Notebook Archive (2022), https://notebookarchive.org/2022-07-bzzmjcr
Download