rosacastillo
commited on
Commit
·
d06f0ed
1
Parent(s):
399b74f
updating the weighted accuracy formula
Browse files- app.py +4 -0
- tabs/tool_accuracy.py +29 -1
app.py
CHANGED
@@ -292,6 +292,10 @@ with demo:
|
|
292 |
|
293 |
with gr.Row():
|
294 |
gr.Markdown("# Weighted accuracy ranking per tool")
|
|
|
|
|
|
|
|
|
295 |
with gr.Row():
|
296 |
gr.Markdown(
|
297 |
"The data used for this metric is from the past two months. This metric is computed using both the tool accuracy and the volume of requests received by the tool"
|
|
|
292 |
|
293 |
with gr.Row():
|
294 |
gr.Markdown("# Weighted accuracy ranking per tool")
|
295 |
+
with gr.Row():
|
296 |
+
gr.Markdown(
|
297 |
+
"This metric is an approximation to the real metric used by the trader since some parameters are only dynamically generated."
|
298 |
+
)
|
299 |
with gr.Row():
|
300 |
gr.Markdown(
|
301 |
"The data used for this metric is from the past two months. This metric is computed using both the tool accuracy and the volume of requests received by the tool"
|
tabs/tool_accuracy.py
CHANGED
@@ -2,11 +2,39 @@ import pandas as pd
|
|
2 |
import gradio as gr
|
3 |
import matplotlib.pyplot as plt
|
4 |
import seaborn as sns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
|
7 |
def get_weighted_accuracy(row, global_requests: int):
|
8 |
"""Function to compute the weighted accuracy of a tool"""
|
9 |
-
return (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
def compute_weighted_accuracy(tools_accuracy: pd.DataFrame):
|
|
|
2 |
import gradio as gr
|
3 |
import matplotlib.pyplot as plt
|
4 |
import seaborn as sns
|
5 |
+
from typing import Tuple
|
6 |
+
|
7 |
+
VOLUME_FACTOR_REGULARIZATION = 0.5
|
8 |
+
UNSCALED_WEIGHTED_ACCURACY_INTERVAL = (-0.5, 100.5)
|
9 |
+
SCALED_WEIGHTED_ACCURACY_INTERVAL = (0, 1)
|
10 |
+
|
11 |
+
|
12 |
+
def scale_value(
|
13 |
+
value: float,
|
14 |
+
min_max_bounds: Tuple[float, float],
|
15 |
+
scale_bounds: Tuple[float, float] = (0, 1),
|
16 |
+
) -> float:
|
17 |
+
"""Perform min-max scaling on a value."""
|
18 |
+
min_, max_ = min_max_bounds
|
19 |
+
current_range = max_ - min_
|
20 |
+
# normalize between 0-1
|
21 |
+
std = (value - min_) / current_range
|
22 |
+
# scale between min_bound and max_bound
|
23 |
+
min_bound, max_bound = scale_bounds
|
24 |
+
target_range = max_bound - min_bound
|
25 |
+
return std * target_range + min_bound
|
26 |
|
27 |
|
28 |
def get_weighted_accuracy(row, global_requests: int):
|
29 |
"""Function to compute the weighted accuracy of a tool"""
|
30 |
+
return scale_value(
|
31 |
+
(
|
32 |
+
row["tool_accuracy"]
|
33 |
+
+ (row["total_requests"] / global_requests) * VOLUME_FACTOR_REGULARIZATION
|
34 |
+
),
|
35 |
+
UNSCALED_WEIGHTED_ACCURACY_INTERVAL,
|
36 |
+
SCALED_WEIGHTED_ACCURACY_INTERVAL,
|
37 |
+
)
|
38 |
|
39 |
|
40 |
def compute_weighted_accuracy(tools_accuracy: pd.DataFrame):
|