ee.Classifier.amnhMaxent

创建最大熵分类器。Maxent 使用已知存在位置和大量“背景”位置的环境数据来模拟物种分布概率。如需了解详情和引用信息,请访问:https://biodiversityinformatics.amnh.org/open_source/maxent/,并参阅参考出版物:Phillips 等人,2004 年,一种用于物种分布建模的最大熵方法,第二十一届国际机器学习会议论文集。输出是一个名为“probability”的单波段,其中包含模型化概率;如果“writeClampGrid”实参为 true,则还会包含一个名为“clamp”的额外波段。

用法返回
ee.Classifier.amnhMaxent(categoricalNames, outputFormat, autoFeature, linear, quadratic, product, threshold, hinge, hingeThreshold, l2lqThreshold, lq2lqptThreshold, addSamplesToBackground, addAllSamplesToBackground, betaMultiplier, betaHinge, betaLqp, betaCategorical, betaThreshold, extrapolate, doClamp, writeClampGrid, randomTestPoints, seed)分类器
参数类型详细信息
categoricalNames列表,默认值:null分类输入的名称列表。此实参中未列出的任何输入都被视为连续输入。
outputFormat字符串,默认值:“cloglog”输出中概率的表示形式。
autoFeature布尔值,默认值:true根据训练样本数量自动选择要使用的特征类。
linear布尔值,默认值:true允许使用线性功能。当 autofeature 为 true 时,系统会忽略此参数。
quadratic布尔值,默认值:true允许使用二次方特征。当 autofeature 为 true 时,系统会忽略此参数。
product布尔值,默认值:true允许使用产品功能。当 autofeature 为 true 时,系统会忽略此参数。
threshold布尔值,默认值:false允许使用阈值功能。当 autofeature 为 true 时,系统会忽略此参数。
hinge布尔值,默认值:true允许使用铰链功能。当 autofeature 为 true 时,系统会忽略此参数。
hingeThreshold整数,默认值:15开始使用铰链特征的样本数。如果 autofeature 为 false,则忽略。
l2lqThreshold整数,默认值:10开始使用二次方特征的样本数。如果 autofeature 为 false,则忽略。
lq2lqptThreshold整数,默认值:80开始使用商品和阈值功能的样本数量。如果 autofeature 为 false,则忽略。
addSamplesToBackground布尔值,默认值:true将具有环境值组合(尚未出现在背景中)的任何样本添加到背景中。
addAllSamplesToBackground布尔值,默认值:false将所有样本添加到背景中,即使这些样本的环境值组合已存在于背景中也是如此。
betaMultiplier浮点数,默认值:1正则化乘数。将所有自动正则化形参乘以相应数字。数值越大,分布越分散。
betaHinge浮点数,默认值:-1要应用于所有 hinge 特征的正则化形参;负值表示启用自动设置。
betaLqp浮点数,默认值:-1要应用于所有线性特征、二次特征和乘积特征的正则化形参;负值表示启用自动设置。
betaCategorical浮点数,默认值:-1要应用于所有类别特征的正则化形参;负值表示启用自动设置。
betaThreshold浮点数,默认值:-1要应用于所有阈值特征的正则化形参;负值表示启用自动设置。
extrapolate布尔值,默认值:true外推。预测训练期间遇到的限制之外的环境空间区域。
doClamp布尔值,默认值:true对输出应用钳制。
writeClampGrid布尔值,默认值:true在输出中添加一个频段(“钳制”),显示钳制的空间分布。在每个点,该值都是采用和不采用钳制时的预测值之间的绝对差。
randomTestPoints整数,默认值:0随机测试百分比。留作测试点的训练点所占的百分比,用于计算 AUX、遗漏等。
seedLong,默认值:0生成随机数时使用的种子。

示例

代码编辑器 (JavaScript)

// Create some sample species presence/absence training data.
var trainingData = ee.FeatureCollection([
  // Species present points.
  ee.Feature(ee.Geometry.Point([-122.39567, 38.02740]), {presence: 1}),
  ee.Feature(ee.Geometry.Point([-122.68560, 37.83690]), {presence: 1}),
  // Species absent points.
  ee.Feature(ee.Geometry.Point([-122.59755, 37.92402]), {presence: 0}),
  ee.Feature(ee.Geometry.Point([-122.47137, 37.99291]), {presence: 0}),
  ee.Feature(ee.Geometry.Point([-122.52905, 37.85642]), {presence: 0}),
  ee.Feature(ee.Geometry.Point([-122.03010, 37.66660]), {presence: 0})
]);

// Import a Landsat 8 surface reflectance image.
var image = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20200606')
                // Select the optical and thermal bands.
                .select(['.._B.*']);

// Sample the image at the location of the points.
var training = image.sampleRegions({collection: trainingData, scale: 30});

// Define and train a Maxent classifier from the image-sampled points.
var classifier = ee.Classifier.amnhMaxent().train({
  features: training,
  classProperty: 'presence',
  inputProperties: image.bandNames()
});

// Classify the image using the Maxent classifier.
var imageClassified = image.classify(classifier);

// Display the layers on the map.
// Species presence probability [0, 1] grades from black to white.
Map.centerObject(image, 9);
Map.addLayer(
    image.select(['SR_B4', 'SR_B3', 'SR_B2']).multiply(0.0000275).add(-0.2),
    {min: 0, max: 0.3}, 'Image');
Map.addLayer(
    imageClassified, {bands: 'probability', min: 0, max: 1}, 'Probability');
Map.addLayer(
    trainingData.filter('presence == 0'), {color: 'red'},
    'Training data (species absent)');
Map.addLayer(
    trainingData.filter('presence == 1'), {color: 'blue'},
    'Training data (species present)');

Python 设置

如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

import ee
import geemap.core as geemap

Colab (Python)

"""Demonstrates the ee.Classifier.amnhMaxent method."""

import ee


# Authenticates to the Earth Engine servers.
ee.Authenticate()
# Initializes the client library.
ee.Initialize()


# Create some sample species presence/absence training data.
training_data = ee.FeatureCollection([
    # Species present points.
    ee.Feature(ee.Geometry.Point([-122.39567, 38.02740]), {'presence': 1}),
    ee.Feature(ee.Geometry.Point([-122.68560, 37.83690]), {'presence': 1}),
    # Species absent points.
    ee.Feature(ee.Geometry.Point([-122.59755, 37.92402]), {'presence': 0}),
    ee.Feature(ee.Geometry.Point([-122.47137, 37.99291]), {'presence': 0}),
    ee.Feature(ee.Geometry.Point([-122.52905, 37.85642]), {'presence': 0}),
    ee.Feature(ee.Geometry.Point([-122.03010, 37.66660]), {'presence': 0})
])

# Import a Landsat 8 image and select the reflectance bands.
image = (ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20200606')
         .select(['SR_B[1-7]'])
         .multiply(0.0000275).add(-0.2))  # Apply scaling factors.

# Sample the image at the location of the points.
training = image.sampleRegions(**{
    'collection': training_data,
    'scale': 30
})

# Define and train a Maxent classifier from the image-sampled points.
classifier = ee.Classifier.amnhMaxent().train(**{
    'features': training,
    'classProperty': 'presence',
    'inputProperties': image.bandNames()
})

# Classify the image using the Maxent classifier.
image_classified = image.classify(classifier)