summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiclas Dobbertin <niclas.dobbertin@stud.tu-darmstadt.de>2023-10-04 15:43:24 +0200
committerNiclas Dobbertin <niclas.dobbertin@stud.tu-darmstadt.de>2023-10-04 15:43:24 +0200
commita6594776753504e7c6c0c389e6dcfd9dbc713cec (patch)
tree473a1cf405bd9d18bda72244bd86cc570411bf3b
parent152ec0e2f948e2fcdc4ae63ac2d8837f28c75d46 (diff)
improve avg dist metrics
-rw-r--r--bjoern/videoanalyse/utils.py39
1 files changed, 26 insertions, 13 deletions
diff --git a/bjoern/videoanalyse/utils.py b/bjoern/videoanalyse/utils.py
index b1eaa4f..df00482 100644
--- a/bjoern/videoanalyse/utils.py
+++ b/bjoern/videoanalyse/utils.py
@@ -130,22 +130,35 @@ def write_grouped_metrics(df, url_groups, data_path):
def evaluate_results(vp_results):
vp_code = [df["vp_code"].values[0] for df in vp_results]
- mean_lev = [
- sum(df["levenshtein-distance"].values) / len(df["levenshtein-distance"])
- for df in vp_results
- ]
- mean_long = [
- sum(df["longest-distance"].values) / len(df["longest-distance"])
- for df in vp_results
- ]
- mean_freq = [
- sum(df["most_frequent-distance"].values) / len(df["most_frequent-distance"])
- for df in vp_results
- ]
+ # mean_lev = [
+ # sum(df["levenshtein-distance"].values) / len(df["levenshtein-distance"])
+ # for df in vp_results
+ # ]
+ mean_long = []
+ mean_freq = []
+ for df in vp_results:
+ groups = set(df["group"].values)
+ group_long = 0
+ group_freq = 0
+ for group in groups:
+ group_df = df.loc[df['group'] == group]
+ group_long += group_df["longest-distance"].values[0]
+ group_freq += group_df["most_frequent-distance"].values[0]
+ mean_long.append(group_long / len(groups))
+ mean_freq.append(group_freq / len(groups))
+
+ # mean_long = [
+ # sum(df["longest-distance"].values) / len(df["longest-distance"])
+ # for df in vp_results
+ # ]
+ # mean_freq = [
+ # sum(df["most_frequent-distance"].values) / len(df["most_frequent-distance"])
+ # for df in vp_results
+ # ]
metrics = {
"vp_code": vp_code,
- "mean_lev": mean_lev,
+ # "mean_lev": mean_lev,
"mean_long": mean_long,
"mean_freq": mean_freq,
}