Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pandas as pd | |
from tabs.market_plots import ( | |
plot_top_10_ranking_by_nr_trades, | |
plot_trades_and_traders_ranking, | |
plot_wordcloud_topics, | |
) | |
import logging | |
from huggingface_hub import hf_hub_download | |
def get_logger(): | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) | |
# stream handler and formatter | |
stream_handler = logging.StreamHandler() | |
stream_handler.setLevel(logging.DEBUG) | |
formatter = logging.Formatter( | |
"%(asctime)s - %(name)s - %(levelname)s - %(message)s" | |
) | |
stream_handler.setFormatter(formatter) | |
logger.addHandler(stream_handler) | |
return logger | |
def load_data(): | |
# closed_markets metrics | |
closed_markets_df = hf_hub_download( | |
repo_id="valory/Olas-predict-dataset", | |
filename="closed_market_metrics.parquet", | |
repo_type="dataset", | |
) | |
df = pd.read_parquet(closed_markets_df) | |
return df | |
logger = get_logger() | |
logger.info("Loading data from Olas predict dataset") | |
market_metrics = load_data() | |
demo = gr.Blocks(theme=gr.themes.Origin()) | |
with demo: | |
gr.HTML("<h1>Prediction markets popularity dashboard (WIP)</h1>") | |
gr.Markdown( | |
"""This app shows the popularity ranking of prediction markets in Olas Predict. Popularity based on two main metrics: | |
* number of generated trades on the market | |
* number of traders active on the market. | |
These are computed only for closed markets.""" | |
) | |
with gr.Tabs(): | |
with gr.TabItem("π₯ Market Popularity metrics"): | |
with gr.Row(): | |
gr.Markdown("# π Top 10 markets based on number of trades") | |
with gr.Row(): | |
top_10_plot = plot_top_10_ranking_by_nr_trades( | |
market_metrics=market_metrics | |
) | |
with gr.Row(equal_height=True): | |
gr.Markdown( | |
"# π Classification based on nr of trades and nr of traders" | |
) | |
with gr.Row(): | |
scatterplot = plot_trades_and_traders_ranking( | |
market_metrics=market_metrics | |
) | |
with gr.Row(): | |
gr.Markdown( | |
"# βοΈ Wordcloud composed with words from most popular markets" | |
) | |
with gr.Row(): | |
wordcloud = plot_wordcloud_topics(market_metrics=market_metrics) | |
demo.queue(default_concurrency_limit=40).launch() | |