Sir,
I am doing OBC for my data using 16_performobjectclass.py.
I have generated training shapefiles for each class using QGIS. In each shapefiles I have included around 30 shapes / polygons of that class.
This shapefiles are called by this 16_performobjectclass.py but I found the error for Training data size and Training data IDs size with message
"ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required"
Bellow is the terminal running messages:
SIr, please give your valuable suggestion to this error.
I will be very thankful to you for your kind support and help.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Writing Stats (Mean, ) to Output RAT
Building
Building.shp
./tmp/Building_22dd1e3f2b.kea
Creating output image using input image
Started Complete.
Running Rasterise now...
Building.shp
<osgeo.ogr.DataSource; proxy of <Swig Object of type 'OGRDataSourceShadow *' at 0x7f2e42cc1b40> >
Adding Colour Table
Get Image Min and Max.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Calculating Image Pyramids.
Started .0..20..50..70..100. Complete.
Completed
Land
Land.shp
./tmp/Land_22dd1e3f2b.kea
....
....
....
....
Water.shp
<osgeo.ogr.DataSource; proxy of <Swig Object of type 'OGRDataSourceShadow *' at 0x7f2e42cc1b40> >
Adding Colour Table
Get Image Min and Max.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Calculating Image Pyramids.
Started .0..20..50..70..100. Complete.
Completed
New image width = 1160 height = 980 bands = 1Started .0..10..20..30..40..50..60..70..80..90. Complete.
Opening Clumps Image: 23997_BAND432_subset_Clumps_Mean_1.kea
Opening Input Image: ./tmp/CombinedClasses_22dd1e3f2b.kea
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Min 0
Max 0
Range 1
[0]
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Writing Stats to RAT
Deleting file: ./tmp/Building_22dd1e3f2b.kea
Deleting file: ./tmp/Land_22dd1e3f2b.kea
Deleting file: ./tmp/Road_22dd1e3f2b.kea
Deleting file: ./tmp/Water_22dd1e3f2b.kea
Deleting file: ./tmp/CombinedClasses_22dd1e3f2b.kea
Number of input samples:
Number of output samples:
Reading NIRMean
Reading RedMean
Reading GreenMean
Input data size: 256 x 3classesInt are [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
Training data size: 0 x 3
Training data IDs size: 0[]
/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_split.py:2053: FutureWarning: You should specify a value for 'cv' instead of relying on the default value. The default value will change from 3 to 5 in version 0.22.
warnings.warn(CV_WARNING, FutureWarning)
Traceback (most recent call last):
File "PerformObjClass.py", line 85, in <module>
classifier = classratutils.findClassifierParameters(clumpsImg, classesIntCol, variables, preProcessor=None, gridSearch=gSearch) #Find the optimal parameters for a classifier using a grid search and return a classifier instance with those optimal parameters
File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/rsgislib/classification/classratutils.py", line 688, in findClassifierParameters
gridSearch.fit(trainingData, classesInt)
File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_search.py", line 722, in fit
self._run_search(evaluate_candidates)
File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_search.py", line 1191, in _run_search
evaluate_candidates(ParameterGrid(self.param_grid))
File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_search.py", line 711, in evaluate_candidates
cv.split(X, y, groups)))
File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_split.py", line 719, in split
y = check_array(y, ensure_2d=False, dtype=None)
File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/utils/validation.py", line 582, in check_array
context))
ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required.