RF classification error #1923
-
I want to classify the image based on just one class.(crop area and non crop area)...the code is working but while generating the output it says - Classifier training failed: 'Only one class.' cant i classify the image as binary classfication....code is below The code - #ndvi_new is an median image with band ndvi and plant is a feature collection of set of points with property crop class as 1 for all points def func_gtv(feature): plant =ee.FeatureCollection('users/species').map(func_gtv) label = "crop_class" training = ndvi_new.sampleRegions( bands = ["ndvi"] trained = ee.Classifier.smileCart().train(training, label, bands) trained print(training.first().getInfo()) result = ndvi_new.classify(trained) m.addLayer(result, {}, "classified") #error at this step as - EEException: Classifier training failed: 'Only one class.'. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You need two classes: crop and non-crop. Add training samples for non-crop area. |
Beta Was this translation helpful? Give feedback.
You need two classes: crop and non-crop. Add training samples for non-crop area.