API Transitions Guide

  • On 8/25/2016, Image.trainClassifier() and FeatureCollection.trainClassifier() were replaced by Classifier.train(), which separates training data collection and classifier building for improved control.

  • Creating classifiers now requires using constructors within the ee.Classifier namespace, and training points are extracted with methods like sampleRegions().

  • While bootstrapping isn't directly supported, it can be achieved manually with random sampling using randomColumn().

  • The classifier's mode (classification, regression, or probability) is determined by classifier.setOutputMode().

This page provides information regarding changes to the Earth Engine API and steps necessary to transitions to new API features.

trainClassifier

On 8/25/2016, the Image.trainClassifier() and FeatureCollection.trainClassifier() algorithms were deprecated and replaced with Classifier.train(). The new API separates the steps of collecting training data and building the classifier, in order to allow easier access to the classifier parameters and to facilitate better control over the training data (ie: splitting the training data for validation).

The following example illustrates converting from trainClassifier() to Classifier.train(): (For more information, see the classification section.

Old Style Classifiers

var classifier = image.trainClassifier({
  training_features: collection,
  training_property: "class",
  classifier_name: "Cart",
  scale: 100
})
var result = image.classify(classifier)

New Style Classifiers

var training = image.sampleRegions({
  collection: collection,
  scale: 100,
})
var classifier = ee.Classifier.smileCart().train(
  features: training,
  classProperty: "class",
})
var result = image.classify(classifier)

Summary of changes

  • Classifiers are now explicitly created using one of the constructors in the ee.Classifier namespace.
  • Training points are extracted from images using sample(), sampleRegions() or stratifiedSample()
  • The new classifier system doesn't directly support bootstrapping, however using random sampling (via randomColumn()) on the training points, you can create multiple classifiers and perform bootstrapping manually.
  • The mode of the classifier (classification, regression or probability) is set using classifier.setOutputMode()