공지사항: 
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 액세스 권한을 유지하기 위해 
비상업용 자격 요건을 인증해야 합니다. 2025년 9월 26일까지 인증하지 않으면 액세스가 보류될 수 있습니다.
  
        
 
       
     
  
  
  
    
  
  
  
    
      ee.FeatureCollection.errorMatrix
    
    
      
    
    
      
      컬렉션을 사용해 정리하기
    
    
      
      내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
    
  
  
      
    
  
  
  
  
  
    
  
  
    
    
    
  
  
컬렉션의 두 열을 비교하여 컬렉션의 2D 오류 행렬을 계산합니다. 한 열에는 실제 값이 포함되고 다른 열에는 예측 값이 포함됩니다. 값은 0부터 시작하는 작은 연속된 정수여야 합니다. 행렬의 축 0 (행)은 실제 값에 해당하고 축 1 (열)은 예측 값에 해당합니다.
| 사용 | 반환 값 | 
|---|
| FeatureCollection.errorMatrix(actual, predicted, order) | ConfusionMatrix | 
| 인수 | 유형 | 세부정보 | 
|---|
| 다음과 같은 경우: collection | FeatureCollection | 입력 컬렉션입니다. | 
| actual | 문자열 | 실제 값이 포함된 속성의 이름입니다. | 
| predicted | 문자열 | 예측된 값을 포함하는 속성의 이름입니다. | 
| order | 목록, 기본값: null | 예상 값 목록입니다. 이 인수를 지정하지 않으면 값이 연속적이고 0~maxValue 범위에 걸쳐 있는 것으로 간주됩니다. 지정된 경우 이 목록과 일치하는 값만 사용되며 매트릭스에는 이 목록과 일치하는 측정기준과 순서가 있습니다. | 
  
  
  예
  
    
  
  
    
    
  
  
  
  
    
    
    
      코드 편집기 (JavaScript)
    
    
  /**
 * Classifies features in a FeatureCollection and computes an error matrix.
 */
// Combine Landsat and NLCD images using only the bands representing
// predictor variables (spectral reflectance) and target labels (land cover).
var spectral =
    ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_038032_20160820').select('SR_B[1-7]');
var landcover =
    ee.Image('USGS/NLCD_RELEASES/2016_REL/2016').select('landcover');
var sampleSource = spectral.addBands(landcover);
// Sample the combined images to generate a FeatureCollection.
var sample = sampleSource.sample({
  region: spectral.geometry(),  // sample only from within Landsat image extent
  scale: 30,
  numPixels: 2000,
  geometries: true
})
// Add a random value column with uniform distribution for hold-out
// training/validation splitting.
.randomColumn({distribution: 'uniform'});
print('Sample for classifier development', sample);
// Split out ~80% of the sample for training the classifier.
var training = sample.filter('random < 0.8');
print('Training set', training);
// Train a random forest classifier.
var classifier = ee.Classifier.smileRandomForest(10).train({
  features: training,
  classProperty: landcover.bandNames().get(0),
  inputProperties: spectral.bandNames()
});
// Classify the sample.
var predictions = sample.classify(
    {classifier: classifier, outputName: 'predicted_landcover'});
print('Predictions', predictions);
// Split out the validation feature set.
var validation = predictions.filter('random >= 0.8');
print('Validation set', validation);
// Get a list of possible class values to use for error matrix axis labels.
var order = sample.aggregate_array('landcover').distinct().sort();
print('Error matrix axis labels', order);
// Compute an error matrix that compares predicted vs. expected values.
var errorMatrix = validation.errorMatrix({
  actual: landcover.bandNames().get(0),
  predicted: 'predicted_landcover',
  order: order
});
print('Error matrix', errorMatrix);
// Compute accuracy metrics from the error matrix.
print("Overall accuracy", errorMatrix.accuracy());
print("Consumer's accuracy", errorMatrix.consumersAccuracy());
print("Producer's accuracy", errorMatrix.producersAccuracy());
print("Kappa", errorMatrix.kappa());
  
    
  
  
    
  
  
  
  
    
  
    
  Python 설정
  Python API 및 geemap를 사용한 대화형 개발에 관한 자세한 내용은 
    Python 환경 페이지를 참고하세요.
  import ee
import geemap.core as geemap
  
    
    
      Colab (Python)
    
    
  # Classifies features in a FeatureCollection and computes an error matrix.
# Combine Landsat and NLCD images using only the bands representing
# predictor variables (spectral reflectance) and target labels (land cover).
spectral = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_038032_20160820').select(
    'SR_B[1-7]')
landcover = ee.Image('USGS/NLCD_RELEASES/2016_REL/2016').select('landcover')
sample_source = spectral.addBands(landcover)
# Sample the combined images to generate a FeatureCollection.
sample = sample_source.sample(**{
    # sample only from within Landsat image extent
    'region': spectral.geometry(),
    'scale': 30,
    'numPixels': 2000,
    'geometries': True
    })
# Add a random value column with uniform distribution for hold-out
# training/validation splitting.
sample = sample.randomColumn(**{'distribution': 'uniform'})
display('Sample for classifier development:', sample)
# Split out ~80% of the sample for training the classifier.
training = sample.filter('random < 0.8')
display('Training set:', training)
# Train a random forest classifier.
classifier = ee.Classifier.smileRandomForest(10).train(**{
    'features': training,
    'classProperty': landcover.bandNames().get(0),
    'inputProperties': spectral.bandNames()
    })
# Classify the sample.
predictions = sample.classify(
    **{'classifier': classifier, 'outputName': 'predicted_landcover'})
display('Predictions:', predictions)
# Split out the validation feature set.
validation = predictions.filter('random >= 0.8')
display('Validation set:', validation)
# Get a list of possible class values to use for error matrix axis labels.
order = sample.aggregate_array('landcover').distinct().sort()
display('Error matrix axis labels:', order)
# Compute an error matrix that compares predicted vs. expected values.
error_matrix = validation.errorMatrix(**{
    'actual': landcover.bandNames().get(0),
    'predicted': 'predicted_landcover',
    'order': order
    })
display('Error matrix:', error_matrix)
# Compute accuracy metrics from the error matrix.
display('Overall accuracy:', error_matrix.accuracy())
display('Consumer\'s accuracy:', error_matrix.consumersAccuracy())
display('Producer\'s accuracy:', error_matrix.producersAccuracy())
display('Kappa:', error_matrix.kappa())
  
  
  
  
  
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
  최종 업데이트: 2025-10-30(UTC)
  
  
  
    
      [null,null,["최종 업데이트: 2025-10-30(UTC)"],[],["The `errorMatrix` method computes a 2D confusion matrix by comparing actual and predicted values from two columns within a FeatureCollection. It takes `actual` and `predicted` column names as inputs, and an optional `order` list to define the matrix's dimensions and included values. The function uses small contiguous integers starting from 0, and returns a `ConfusionMatrix` object that includes overall accuracy, consumer's accuracy, producer's accuracy and kappa.\n"]]