-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_statis_update.py
97 lines (74 loc) · 4.35 KB
/
compute_statis_update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import pandas as pd
import os
df_all = pd.DataFrame({})
for year in [2017,2021]:
for county in ['shufuxian','xixiangxian','guanghexian','danfengxian','jiangzixian','honghexian','liboxian']:#,'linquanxian','jingyuxian','lingqiuxian']:
if os.path.exists('../output/'+county+'_'+str(year)+'_d500_recall.csv'):
df = pd.read_csv('../output/'+county+'_'+str(year)+'_d500_recall.csv')
df_all = pd.concat([df_all, df])
df_all.to_csv('validation_statistics_first10_d500_recall.csv', index=False)
df_all = pd.DataFrame({})
for year in [2017,2021]:
for county in ['shufuxian','xixiangxian','guanghexian','danfengxian','jiangzixian','honghexian','liboxian']:#,'linquanxian','jingyuxian','lingqiuxian']:
if os.path.exists('../output/'+county+'_'+str(year)+'_OSM_recall.csv'):
df = pd.read_csv('../output/'+county+'_'+str(year)+'_OSM_recall.csv')
df_all = pd.concat([df_all, df])
df_all.to_csv('validation_statistics_first10_OSM_recall.csv', index=False)
df_all = pd.DataFrame({})
for year in [2017,2021]:
for county in ['shufuxian','xixiangxian','guanghexian','danfengxian','jiangzixian','honghexian','liboxian']:#,'linquanxian','jingyuxian','lingqiuxian']:
if os.path.exists('../output/'+county+'_'+str(year)+'_b1_recall.csv'):
df = pd.read_csv('../output/'+county+'_'+str(year)+'_b1_recall.csv')
df_all = pd.concat([df_all, df])
df_all.to_csv('validation_statistics_first10_b1_recall.csv', index=False)
df_all = pd.DataFrame({})
for year in [2017,2021]:
for county in ['shufuxian','xixiangxian','guanghexian','danfengxian','jiangzixian','honghexian','liboxian']:#,'linquanxian','jingyuxian','lingqiuxian']:
if os.path.exists('../output/'+county+'_'+str(year)+'_b2_recall.csv'):
df = pd.read_csv('../output/'+county+'_'+str(year)+'_b2_recall.csv')
df_all = pd.concat([df_all, df])
df_all.to_csv('validation_statistics_first10_b2_recall.csv', index=False)
data = pd.read_csv('validation_statistics_first10_d500_recall.csv')
# 按照指定列进行分组,计算每组的 pre, rec, f1s 值
grouped = data.groupby(['roadclass', 'year', 'i']).apply(lambda x: pd.Series({
'pre': x['pre'].mean(), # 计算 pre 值
'rec': x['rec'].mean(), # 计算 rec 值
'f1s': x['f1s'].mean() # 计算 f1s 值
}))
# 重置索引
grouped = grouped.reset_index()
# 保存结果为新的 CSV 文件
grouped.to_csv('validation_statistics_first10_d500_recall_grouped.csv', index=False) # 保存为 result_grouped.csv,可以根据需要修改文件名
data = pd.read_csv('validation_statistics_first10_OSM_recall.csv')
# 按照指定列进行分组,计算每组的 pre, rec, f1s 值
grouped = data.groupby([ 'roadclass', 'year', 'i']).apply(lambda x: pd.Series({
'pre': x['pre'].mean(), # 计算 pre 值
'rec': x['rec'].mean(), # 计算 rec 值
'f1s': x['f1s'].mean() # 计算 f1s 值
}))
# 重置索引
grouped = grouped.reset_index()
# 保存结果为新的 CSV 文件
grouped.to_csv('validation_statistics_first10_OSM_recall_grouped.csv', index=False) # 保存为 result_grouped.csv,可以根据需要修改文件名
data = pd.read_csv('validation_statistics_first10_b1_recall.csv')
# 按照指定列进行分组,计算每组的 pre, rec, f1s 值
grouped = data.groupby(['roadclass', 'year', 'i']).apply(lambda x: pd.Series({
'pre': x['pre'].mean(), # 计算 pre 值
'rec': x['rec'].mean(), # 计算 rec 值
'f1s': x['f1s'].mean() # 计算 f1s 值
}))
# 重置索引
grouped = grouped.reset_index()
# 保存结果为新的 CSV 文件
grouped.to_csv('validation_statistics_first10_b1_recall_grouped.csv', index=False) # 保存为 result_grouped.csv,可以根据需要修改文件名
data = pd.read_csv('validation_statistics_first10_b2_recall.csv')
# 按照指定列进行分组,计算每组的 pre, rec, f1s 值
grouped = data.groupby(['roadclass', 'year', 'i']).apply(lambda x: pd.Series({
'pre': x['pre'].mean(), # 计算 pre 值
'rec': x['rec'].mean(), # 计算 rec 值
'f1s': x['f1s'].mean() # 计算 f1s 值
}))
# 重置索引
grouped = grouped.reset_index()
# 保存结果为新的 CSV 文件
grouped.to_csv('validation_statistics_first10_b2_recall_grouped.csv', index=False) # 保存为 result_grouped.csv,可以根据需要修改文件名