MachineLearning Package

MachineLearning Package

KNNClassifier Module

class SimpleCV.MachineLearning.KNNClassifier.KNNClassifier(featureExtractors, k=1, dist=None)

This class encapsulates a K- Nearest Neighbor Classifier.

See http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm

classify(image)

Classify a single image. Takes in an image and returns the string of the classification.

Make sure you haved loaded the feauture extractors and the training data.

classmethod load(fname)
Load the classifier from file
save(fname)
Save the classifier to file
setDistanceMetric(dist)
Note that training and testing will need to be redone.
setFeatureExtractors(extractors)
Add a list of feature extractors to the classifier. These feature extractors must match the ones used to train the classifier. If the classifier is already trained then this method will require that you retrain the data.
setK(k)
Note that training and testing will need to be redone.
test(paths, classNames, disp=None, subset=-1, savedata=None, verbose=True)

Train the classifier. paths the order of the paths in the same order as the class type

  • Note all image classes must be in seperate directories
  • The class names must also align to the directories

disp - if display is a display we show images and class label, otherwise nothing is done.

subset - if subset = -1 we use the whole dataset. If subset = # then we use min(#images,subset)

savedata - if save data is None nothing is saved. If savedata is a file name we save the data to a tab delimited file.

verbose - print confusion matrix and file names returns [%Correct %Incorrect Confusion_Matrix]

train(paths, classNames, disp=None, subset=-1, savedata=None, verbose=True)

Train the classifier. paths the order of the paths in the same order as the class type

  • Note all image classes must be in seperate directories
  • The class names must also align to the directories

disp - if display is a display we show images and class label, otherwise nothing is done.

subset - if subset = -1 we use the whole dataset. If subset = # then we use min(#images,subset)

savedata - if save data is None nothing is saved. If savedata is a file name we save the data to a tab delimited file.

verbose - print confusion matrix and file names returns [%Correct %Incorrect Confusion_Matrix]

NaiveBayesClassifier Module

class SimpleCV.MachineLearning.NaiveBayesClassifier.NaiveBayesClassifier(featureExtractors)

This class encapsulates a Naive Bayes Classifier. See: http://en.wikipedia.org/wiki/Naive_bayes

classify(image)

Classify a single image. Takes in an image and returns the string of the classification.

Make sure you haved loaded the feauture extractors and the training data.

classmethod load(fname)
Load the classifier from file
save(fname)
Save the classifier to file
setFeatureExtractors(extractors)
Add a list of feature extractors to the classifier. These feature extractors must match the ones used to train the classifier. If the classifier is already trained then this method will require that you retrain the data.
test(paths, classNames, disp=None, subset=-1, savedata=None, verbose=True)

Train the classifier. paths the order of the paths in the same order as the class type

  • Note all image classes must be in seperate directories
  • The class names must also align to the directories

disp - if display is a display we show images and class label, otherwise nothing is done.

subset - if subset = -1 we use the whole dataset. If subset = # then we use min(#images,subset)

savedata - if save data is None nothing is saved. If savedata is a file name we save the data to a tab delimited file.

verbose - print confusion matrix and file names returns [%Correct %Incorrect Confusion_Matrix]

train(paths, classNames, disp=None, subset=-1, savedata=None, verbose=True)

Train the classifier. paths the order of the paths in the same order as the class type

  • Note all image classes must be in seperate directories
  • The class names must also align to the directories

disp - if display is a display we show images and class label, otherwise nothing is done.

subset - if subset = -1 we use the whole dataset. If subset = # then we use min(#images,subset)

savedata - if save data is None nothing is saved. If savedata is a file name we save the data to a tab delimited file.

verbose - print confusion matrix and file names returns [%Correct %Incorrect Confusion_Matrix]

SVMClassifier Module

class SimpleCV.MachineLearning.SVMClassifier.SVMClassifier(featureExtractors, properties=None)

This class encapsulates a Naive Bayes Classifier. See: http://en.wikipedia.org/wiki/Support_vector_machine

classify(image)

Classify a single image. Takes in an image and returns the string of the classification.

Make sure you haved loaded the feauture extractors and the training data.

classmethod load(fname)
Load the classifier from file
save(fname)
Save the classifier to file
setFeatureExtractors(extractors)
Add a list of feature extractors to the classifier. These feature extractors must match the ones used to train the classifier. If the classifier is already trained then this method will require that you retrain the data.
setProperties(properties)
Note that resetting the properties will reset the SVM and you will need to retrain.
test(paths, classNames, disp=None, subset=-1, savedata=None, verbose=True)

Train the classifier. paths the order of the paths in the same order as the class type

  • Note all image classes must be in seperate directories
  • The class names must also align to the directories

disp - if display is a display we show images and class label, otherwise nothing is done.

subset - if subset = -1 we use the whole dataset. If subset = # then we use min(#images,subset)

savedata - if save data is None nothing is saved. If savedata is a file name we save the data to a tab delimited file.

verbose - print confusion matrix and file names returns [%Correct %Incorrect Confusion_Matrix]

train(paths, classNames, disp=None, subset=-1, savedata=None, verbose=True)

Train the classifier. paths the order of the paths in the same order as the class type

  • Note all image classes must be in seperate directories
  • The class names must also align to the directories

disp - if display is a display we show images and class label, otherwise nothing is done.

subset - if subset = -1 we use the whole dataset. If subset = # then we use min(#images,subset)

savedata - if save data is None nothing is saved. If savedata is a file name we save the data to a tab delimited file.

verbose - print confusion matrix and file names returns [%Correct %Incorrect Confusion_Matrix]

TreeClassifier Module

class SimpleCV.MachineLearning.TreeClassifier.TreeClassifier(featureExtractors=[], flavor='Tree', flavorDict=None)

This method encapsulates a number of tree-based machine learning approaches and associated meta algorithms.

Decision trees: http://en.wikipedia.org/wiki/Decision_trees

boosted adpative decision trees http://en.wikipedia.org/wiki/Adaboost

random forrests http://en.wikipedia.org/wiki/Random_forest

bagging (bootstrap aggregating) http://en.wikipedia.org/wiki/Bootstrap_aggregating

classify(image)

Classify a single image. Takes in an image and returns the string of the classification.

Make sure you haved loaded the feauture extractors and the training data.

classmethod load(fname)
Load the classifier from file
save(fname)
Save the classifier to file
setFeatureExtractors(extractors)
Add a list of feature extractors to the classifier. These feature extractors must match the ones used to train the classifier. If the classifier is already trained then this method will require that you retrain the data.
test(paths, classNames, disp=None, subset=-1, savedata=None, verbose=True)

Train the classifier. paths the order of the paths in the same order as the class type

  • Note all image classes must be in seperate directories
  • The class names must also align to the directories

disp - if display is a display we show images and class label, otherwise nothing is done.

subset - if subset = -1 we use the whole dataset. If subset = # then we use min(#images,subset)

savedata - if save data is None nothing is saved. If savedata is a file name we save the data to a tab delimited file.

verbose - print confusion matrix and file names returns [%Correct %Incorrect Confusion_Matrix]

train(paths, classNames, disp=None, subset=-1, savedata=None, verbose=True)

Train the classifier. paths the order of the paths in the same order as the class type

  • Note all image classes must be in seperate directories
  • The class names must also align to the directories

disp - if display is a display we show images and class label, otherwise nothing is done.

subset - if subset = -1 we use the whole dataset. If subset = # then we use min(#images,subset)

savedata - if save data is None nothing is saved. If savedata is a file name we save the data to a tab delimited file.

verbose - print confusion matrix and file names returns [%Correct %Incorrect Confusion_Matrix]

Table Of Contents

Previous topic

Features Package

Next topic

Segmentation Package

This Page