cyberosa
commited on
Commit
·
773f144
1
Parent(s):
c9eef1d
adding votes graphs
Browse files- app.py +26 -0
- tabs/dist_gap.py +9 -0
- tabs/tokens_votes_dist.py +1 -2
app.py
CHANGED
@@ -9,6 +9,7 @@ from tabs.tokens_votes_dist import (
|
|
9 |
get_based_tokens_distribution,
|
10 |
get_based_votes_distribution,
|
11 |
)
|
|
|
12 |
|
13 |
|
14 |
def get_logger():
|
@@ -96,5 +97,30 @@ with demo:
|
|
96 |
|
97 |
with gr.Row():
|
98 |
gr.Markdown("# Evolution of outcomes probability based on votes")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
demo.queue(default_concurrency_limit=40).launch()
|
|
|
9 |
get_based_tokens_distribution,
|
10 |
get_based_votes_distribution,
|
11 |
)
|
12 |
+
from tabs.dist_gap import get_distribution_plot
|
13 |
|
14 |
|
15 |
def get_logger():
|
|
|
97 |
|
98 |
with gr.Row():
|
99 |
gr.Markdown("# Evolution of outcomes probability based on votes")
|
100 |
+
with gr.Row():
|
101 |
+
gr.Markdown("Best case: a market with a low distribution gap metric")
|
102 |
+
with gr.Row():
|
103 |
+
gr.Markdown(f"Market id = {best_market_id}")
|
104 |
+
with gr.Row():
|
105 |
+
best_market_votes_dist = get_based_votes_distribution(
|
106 |
+
best_market_id, markets_data
|
107 |
+
)
|
108 |
+
with gr.Row():
|
109 |
+
gr.Markdown("Worst case: a market with a high distribution gap metric")
|
110 |
+
with gr.Row():
|
111 |
+
gr.Markdown(f"Market id = {worst_market_id}")
|
112 |
+
|
113 |
+
with gr.Row():
|
114 |
+
worst_market_tokens_dist = get_based_votes_distribution(
|
115 |
+
worst_market_id, markets_data
|
116 |
+
)
|
117 |
|
118 |
+
with gr.TabItem("📏 Distribution gap metric"):
|
119 |
+
with gr.Row():
|
120 |
+
gr.Markdown(
|
121 |
+
"This metric measures the difference between the probability distribution based on the tokens distribution and the one based on the votes distribution"
|
122 |
+
)
|
123 |
+
|
124 |
+
with gr.Row():
|
125 |
+
dist_plot = get_distribution_plot(markets_data)
|
126 |
demo.queue(default_concurrency_limit=40).launch()
|
tabs/dist_gap.py
CHANGED
@@ -13,3 +13,12 @@ def plot_top_best_behaviour_markets(markets_data: pd.DataFrame):
|
|
13 |
5
|
14 |
)
|
15 |
return gr.DataFrame(top_best_markets)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
5
|
14 |
)
|
15 |
return gr.DataFrame(top_best_markets)
|
16 |
+
|
17 |
+
|
18 |
+
def get_distribution_plot(markets_data: pd.DataFrame):
|
19 |
+
"""Function to paint the density plot of the metric distribution gap percentage"""
|
20 |
+
plt.figure(figsize=(25, 10))
|
21 |
+
plot = sns.kdeplot(markets_data, x="dist_gap_perc", fill=True)
|
22 |
+
# TODO Add title and labels
|
23 |
+
# Display the plot using gr.Plot
|
24 |
+
return gr.Plot(value=plot.get_figure())
|
tabs/tokens_votes_dist.py
CHANGED
@@ -29,7 +29,6 @@ def get_based_tokens_distribution(market_id: str, all_markets: pd.DataFrame):
|
|
29 |
first_outcome = selected_market.iloc[0].first_outcome
|
30 |
second_outcome = selected_market.iloc[0].second_outcome
|
31 |
ax.legend(
|
32 |
-
bbox_to_anchor=(1, 1.02),
|
33 |
loc="upper left",
|
34 |
labels=[first_outcome, second_outcome],
|
35 |
)
|
@@ -48,6 +47,7 @@ def get_based_votes_distribution(market_id: str, all_markets: pd.DataFrame):
|
|
48 |
rot=0,
|
49 |
stacked=True,
|
50 |
)
|
|
|
51 |
# add overall title
|
52 |
plt.title("Outcomes probability over time based on votes distributions", fontsize=8)
|
53 |
|
@@ -57,7 +57,6 @@ def get_based_votes_distribution(market_id: str, all_markets: pd.DataFrame):
|
|
57 |
first_outcome = selected_market.iloc[0].first_outcome
|
58 |
second_outcome = selected_market.iloc[0].second_outcome
|
59 |
ax.legend(
|
60 |
-
bbox_to_anchor=(1, 1.02),
|
61 |
loc="upper left",
|
62 |
labels=[first_outcome, second_outcome],
|
63 |
)
|
|
|
29 |
first_outcome = selected_market.iloc[0].first_outcome
|
30 |
second_outcome = selected_market.iloc[0].second_outcome
|
31 |
ax.legend(
|
|
|
32 |
loc="upper left",
|
33 |
labels=[first_outcome, second_outcome],
|
34 |
)
|
|
|
47 |
rot=0,
|
48 |
stacked=True,
|
49 |
)
|
50 |
+
plt.figure(figsize=(25, 10))
|
51 |
# add overall title
|
52 |
plt.title("Outcomes probability over time based on votes distributions", fontsize=8)
|
53 |
|
|
|
57 |
first_outcome = selected_market.iloc[0].first_outcome
|
58 |
second_outcome = selected_market.iloc[0].second_outcome
|
59 |
ax.legend(
|
|
|
60 |
loc="upper left",
|
61 |
labels=[first_outcome, second_outcome],
|
62 |
)
|