mirror of
https://git.victorphan.net/basketballcantho/CSIROBoeingPhase5-Vietnam.git
synced 2026-08-05 05:43:10 +07:00
add caculate accuracy
This commit is contained in:
+35
-1
@@ -317,4 +317,38 @@ def save_result(result, HT_MAP):
|
||||
# cbar.ax.set_yticklabels(labels)
|
||||
# plt.title(f'{HT_MAP[k]["name"]}')
|
||||
# plt.axis('off')
|
||||
# plt.show()
|
||||
# plt.show()
|
||||
|
||||
|
||||
def accuracy_test(test, data_array):
|
||||
# cấu hình nhãn dữ liệu
|
||||
label_mapping = {
|
||||
"Lua tom": "0",
|
||||
"Lua": "1",
|
||||
"CHN": "2",
|
||||
"CLN": "3",
|
||||
"TS": "4",
|
||||
"Song": "5",
|
||||
"Dat xay dung": "6",
|
||||
"Rung": "7"
|
||||
}
|
||||
|
||||
chk = []
|
||||
pred = []
|
||||
dd = []
|
||||
for idx, point in test.iterrows():
|
||||
label = point.LULC
|
||||
predict = data_array.sel(x=point.geometry.x, y=point.geometry.y, method='nearest').values
|
||||
pred.append(label_mapping[label])
|
||||
dd.append(str(predict))
|
||||
chk.append(predict == int(label_mapping[label]))
|
||||
test["code"] = pred
|
||||
test["dd"] = dd
|
||||
test["check"] = chk
|
||||
path = "ThuanHoa/TestAccuracy"
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
test.to_file(f"{path}/result.shp")
|
||||
|
||||
percentage_true = np.mean(chk) * 100
|
||||
print(f"độ chính xác: {percentage_true:.2f}%")
|
||||
Reference in New Issue
Block a user