Spaces:
Sleeping
Sleeping
cyberosa
commited on
Commit
·
c9eef1d
1
Parent(s):
72f2521
Adjusting config of graphs
Browse files- app.py +3 -1
- notebooks/analysis_of_markets_data.ipynb +0 -0
- tabs/dist_gap.py +15 -0
- tabs/tokens_votes_dist.py +6 -4
app.py
CHANGED
|
@@ -60,7 +60,7 @@ def get_extreme_cases(live_fpmms: pd.DataFrame):
|
|
| 60 |
live_fpmms["id"].isin(markets_with_multiple_samples)
|
| 61 |
]
|
| 62 |
selected_markets.sort_values(by="dist_gap_perc", ascending=False, inplace=True)
|
| 63 |
-
return selected_markets.iloc[
|
| 64 |
|
| 65 |
|
| 66 |
demo = gr.Blocks()
|
|
@@ -77,6 +77,7 @@ with demo:
|
|
| 77 |
|
| 78 |
with gr.Row():
|
| 79 |
gr.Markdown("Best case: a market with a low distribution gap metric")
|
|
|
|
| 80 |
gr.Markdown(f"Market id = {best_market_id}")
|
| 81 |
with gr.Row():
|
| 82 |
best_market_tokens_dist = get_based_tokens_distribution(
|
|
@@ -85,6 +86,7 @@ with demo:
|
|
| 85 |
|
| 86 |
with gr.Row():
|
| 87 |
gr.Markdown("Worst case: a market with a high distribution gap metric")
|
|
|
|
| 88 |
gr.Markdown(f"Market id = {worst_market_id}")
|
| 89 |
|
| 90 |
with gr.Row():
|
|
|
|
| 60 |
live_fpmms["id"].isin(markets_with_multiple_samples)
|
| 61 |
]
|
| 62 |
selected_markets.sort_values(by="dist_gap_perc", ascending=False, inplace=True)
|
| 63 |
+
return selected_markets.iloc[-1].id, selected_markets.iloc[0].id
|
| 64 |
|
| 65 |
|
| 66 |
demo = gr.Blocks()
|
|
|
|
| 77 |
|
| 78 |
with gr.Row():
|
| 79 |
gr.Markdown("Best case: a market with a low distribution gap metric")
|
| 80 |
+
with gr.Row():
|
| 81 |
gr.Markdown(f"Market id = {best_market_id}")
|
| 82 |
with gr.Row():
|
| 83 |
best_market_tokens_dist = get_based_tokens_distribution(
|
|
|
|
| 86 |
|
| 87 |
with gr.Row():
|
| 88 |
gr.Markdown("Worst case: a market with a high distribution gap metric")
|
| 89 |
+
with gr.Row():
|
| 90 |
gr.Markdown(f"Market id = {worst_market_id}")
|
| 91 |
|
| 92 |
with gr.Row():
|
notebooks/analysis_of_markets_data.ipynb
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tabs/dist_gap.py
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
import seaborn as sns
|
| 5 |
+
from seaborn import FacetGrid
|
| 6 |
+
import plotly.express as px
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def plot_top_best_behaviour_markets(markets_data: pd.DataFrame):
|
| 10 |
+
"""Function to paint the top markets with the lowest metric of distribution gap"""
|
| 11 |
+
sorted_data = markets_data.sort_values(by="dist_gap_perc", ascending=False)
|
| 12 |
+
top_best_markets = sorted_data[["title", "sample_datetime", "dist_gap_perc"]].head(
|
| 13 |
+
5
|
| 14 |
+
)
|
| 15 |
+
return gr.DataFrame(top_best_markets)
|
tabs/tokens_votes_dist.py
CHANGED
|
@@ -8,6 +8,8 @@ import plotly.express as px
|
|
| 8 |
|
| 9 |
def get_based_tokens_distribution(market_id: str, all_markets: pd.DataFrame):
|
| 10 |
"""Function to paint the evolution of the probability of the outcomes based on the tokens distributions over time"""
|
|
|
|
|
|
|
| 11 |
selected_market = all_markets.loc[all_markets["id"] == market_id]
|
| 12 |
ax = selected_market.plot(
|
| 13 |
x="sample_datetime",
|
|
@@ -18,7 +20,7 @@ def get_based_tokens_distribution(market_id: str, all_markets: pd.DataFrame):
|
|
| 18 |
)
|
| 19 |
# add overall title
|
| 20 |
plt.title(
|
| 21 |
-
"Outcomes probability over time based on tokens distributions", fontsize=
|
| 22 |
)
|
| 23 |
|
| 24 |
# add axis titles
|
|
@@ -36,6 +38,8 @@ def get_based_tokens_distribution(market_id: str, all_markets: pd.DataFrame):
|
|
| 36 |
|
| 37 |
def get_based_votes_distribution(market_id: str, all_markets: pd.DataFrame):
|
| 38 |
"""Function to paint the evolution of the probability of the outcomes based on the votes distributions over time"""
|
|
|
|
|
|
|
| 39 |
selected_market = all_markets.loc[all_markets["id"] == market_id]
|
| 40 |
ax = selected_market.plot(
|
| 41 |
x="sample_datetime",
|
|
@@ -45,9 +49,7 @@ def get_based_votes_distribution(market_id: str, all_markets: pd.DataFrame):
|
|
| 45 |
stacked=True,
|
| 46 |
)
|
| 47 |
# add overall title
|
| 48 |
-
plt.title(
|
| 49 |
-
"Outcomes probability over time based on votes distributions", fontsize=16
|
| 50 |
-
)
|
| 51 |
|
| 52 |
# add axis titles
|
| 53 |
plt.xlabel("Sample date")
|
|
|
|
| 8 |
|
| 9 |
def get_based_tokens_distribution(market_id: str, all_markets: pd.DataFrame):
|
| 10 |
"""Function to paint the evolution of the probability of the outcomes based on the tokens distributions over time"""
|
| 11 |
+
sns.set_style("darkgrid")
|
| 12 |
+
sns.set_theme(palette="viridis")
|
| 13 |
selected_market = all_markets.loc[all_markets["id"] == market_id]
|
| 14 |
ax = selected_market.plot(
|
| 15 |
x="sample_datetime",
|
|
|
|
| 20 |
)
|
| 21 |
# add overall title
|
| 22 |
plt.title(
|
| 23 |
+
"Outcomes probability over time based on tokens distributions", fontsize=8
|
| 24 |
)
|
| 25 |
|
| 26 |
# add axis titles
|
|
|
|
| 38 |
|
| 39 |
def get_based_votes_distribution(market_id: str, all_markets: pd.DataFrame):
|
| 40 |
"""Function to paint the evolution of the probability of the outcomes based on the votes distributions over time"""
|
| 41 |
+
sns.set_style("darkgrid")
|
| 42 |
+
sns.set_theme(palette="viridis")
|
| 43 |
selected_market = all_markets.loc[all_markets["id"] == market_id]
|
| 44 |
ax = selected_market.plot(
|
| 45 |
x="sample_datetime",
|
|
|
|
| 49 |
stacked=True,
|
| 50 |
)
|
| 51 |
# add overall title
|
| 52 |
+
plt.title("Outcomes probability over time based on votes distributions", fontsize=8)
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# add axis titles
|
| 55 |
plt.xlabel("Sample date")
|