User and producer accuracies with nan

I would usggest to use larger training areas which don’t contain invalid pixels.

As an alternative you can perform the accuracy assessment manually, for example in QGIS: http://web.pdx.edu/~nauna/resources/9-accuracyassessment.pdf

But, again, this is only the training accuracy which doesn’t tell you anything about the accuracy of the classification. Please also see here: GLCM worsening accuracy results?