thatsIt's my first time writing here, but hope iI might give you some insight. I used the code from your post, with some minor changes it worked… kind of. I checked the correlation matrices that iI get by comparing some of minemy classification data with data rasterized in qgisthe QGIS tool and raster generated by this code. Raster generated by your code had kappa coefficient near 0.4, while that generated by qgisQGIS was near 0.9. I think the problem lies somwheresomewhere in
target_ds.SetGeoTransform((x_min, pixel_width, 0, y_min, 0, pixel_width))
Using .GetGeoTransform() solved the problem for me (got same correlation matrices as from QGIS data)
target_ds.SetGeoTransform(data.GetGeTransform())