def raceuma_info_render(shap_df_win, shap_df_jiku, shap_df_are): # 勝ち根拠 fig1 = wp.cp_controlling_text_fontsize_with_uniformtext_win_basis( shap_df_win) # 軸根拠 fig2 = wp.cp_controlling_text_fontsize_with_uniformtext_jiku_basis( shap_df_jiku) # 荒れ根拠 fig3 = wp.cp_controlling_text_fontsize_with_uniformtext_are_basis( shap_df_are) return [ dbc.Row([ wp.dbc_graph("fig1", 4, fig1, "勝ち根拠", 300, bottom=100), wp.dbc_graph("fig2", 4, fig2, "軸根拠", 300, bottom=100), wp.dbc_graph("fig3", 4, fig3, "荒れ根拠", 300, bottom=100), ], className="h-50"), ]
def race_result_render(race_df, raceuma_df, bet_df, haraimodoshi_dict): race_sr = race_df.iloc[0] raceuma_df = raceuma_df.sort_values("タイム指数") raceuma_df.loc[:, "馬名表用"] = raceuma_df["馬名"] raceuma_df.loc[:, "馬名"] = raceuma_df.apply( lambda x: x["馬名"] + "<br>(" + str(x["単勝人気"]) + "番人気 " + str(x[ "確定着順"]) + "着 " + str(x["馬券評価順位"]) + "位)", axis=1) haraimodoshi_df = pd.DataFrame() for key, val in haraimodoshi_dict.items(): if len(val.index) != 0: val.loc[:, "式別"] = key haraimodoshi_df = haraimodoshi_df.append(val) # 得点 fig1 = wp.cp_basic_horizontal_bar_chart_score(raceuma_df) # 得点バブル #fig3_df = raceuma_df[["確定着順", "デフォルト得点", "SCORE", "得点V3", "馬名"]].sort_values("確定着順") #fig3 = wp.cp_buble_chart_score(fig3_df) # テーブル fig4_df = raceuma_df[[ "枠番", "馬番", "馬名表用", "性別コード", "タイム", "タイム指数", "デフォルト得点", "得点", "馬券評価順位", "単勝オッズ", "単勝人気", "複勝オッズ1", "複勝オッズ2", "展開コード", "騎手名", "馬齢", "調教師名", "負担重量", "馬体重", "確定着順", "コーナー順位1", "コーナー順位2", "コーナー順位3", "コーナー順位4", "上がりタイム", "所属", "得点V3", "WIN_RATE", "JIKU_RATE", "ANA_RATE", "WIN_RANK", "JIKU_RANK", "ANA_RANK", "SCORE", "SCORE_RANK", "CK1_RATE", "CK2_RATE", "CK3_RATE", "CK1_RANK", "CK2_RANK", "CK3_RANK" ]].sort_values("タイム指数", ascending=False) # 払戻・投票 if len(haraimodoshi_df.index) != 0: fig5_haraimodoshi_df = haraimodoshi_df[["式別", "馬番", "払戻"]] else: fig5_haraimodoshi_df = haraimodoshi_df fig5_bet_df = bet_df[["式別名", "番号", "金額", "結果", "合計"]] # タイム指数、予想タイム指数 fig6 = wp.cp_basic_dot_plot_time_record(raceuma_df) # タイム指数、単勝オッズ fig10 = wp.cp_bar_chart_with_line_plot_time_record_tansho(raceuma_df) # ラップ #fig11 = wp.cp_simple_line_rap(race_sr, 500) # 単勝支持率 fig12 = wp.cp_pie_chart_tansho_approval_rate(raceuma_df) return dcc.Loading( id="race-result-render-loading", children=[ dbc.Row([ wp.dbc_race_info(race_sr, 8), wp.dbc_race_result(race_sr, haraimodoshi_df, 4), ], className="h-8", no_gutters=True), dbc.Row([ wp.dbc_graph("fig12", 4, fig12, "単勝支持率", 400), wp.dbc_graph("fig10", 4, fig10, "タイム指数、単勝オッズ", 500), wp.dbc_haraimodoshi_table("fig5_1", 2, fig5_haraimodoshi_df), wp.dbc_bet_table("fig5_2", 2, fig5_bet_df), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig1", 6, fig1, "得点", 400), wp.dbc_graph("fig6", 6, fig6, "タイム指数、予想タイム指数", 500), ], className="h-50", no_gutters=True), # dbc.Row([ # wp.dbc_graph("fig3", 6, fig3, "得点バブル", 500), # wp.dbc_graph("fig11", 4, fig11, "ラップ", 400), # ], className="h-50", no_gutters=True), wp.dbc_race_result_table("fig4", 16, fig4_df) ])
def toppage_render(race_df, raceuma_df, bet_df, haraimodoshi_dict): daily_bet_df = cd.get_daily_bet_df(bet_df) daily_rank1_raceuma_df = cd.get_daily_rank1_raceuma_df(raceuma_df) summary_bet_df = cd.get_summary_bet_df(bet_df) place_bet_df = cd.get_place_bet_df(bet_df) prev_daily_bet_df = daily_bet_df.drop(daily_bet_df.tail(1).index) prev_daily_rank1_raceuma_df = daily_rank1_raceuma_df.drop( daily_bet_df.tail(1).index) place_bet_df = place_bet_df[place_bet_df["金額"] != 0].copy() raceuma_df.loc[:, "競走馬コード"] = raceuma_df.apply( lambda x: str(x["競走コード"]) + str(x["馬番"]).zfill(2), axis=1) # 回収 fig1 = wp.cp_data_cards_return(daily_bet_df, prev_daily_bet_df) # 回収率 fig2 = wp.cp_showing_information_above_return_rate(daily_bet_df, prev_daily_bet_df) # 単勝回収率 fig3 = wp.cp_add_steps_threshold_anda_delta_tansho_return( daily_rank1_raceuma_df, prev_daily_rank1_raceuma_df) # 複勝回収率 fig4 = wp.cp_add_steps_threshold_anda_delta_fukusho_return( daily_rank1_raceuma_df, prev_daily_rank1_raceuma_df) # 残高推移1 fig5 = wp.cp_time_series_with_range_selector_buttions_balance_change( daily_bet_df) # 残高推移2 fig6 = wp.cp_simple_waterfall_chart_balance_change(summary_bet_df) # 場所別回収率的中率払戻 fig7 = wp.cp_buble_chart_place_return_hit(place_bet_df) # 券種毎回収率 fig8 = wp.cp_multi_bullet(summary_bet_df) # 得点1位着順 fig9 = wp.cp_pie_chart_score_1(raceuma_df) # 場所別単複回収率・的中率 fig10 = wp.cp_multiple_line_and_bar_chart_place_tanpuku_return( race_df, raceuma_df) # 場所別馬券回収率・的中率 fig11 = wp.cp_multiple_line_and_bar_chart_place_bet_return(bet_df) # 馬連的中1 fig12 = wp.cp_basic_funnel_plot_umaren_1(race_df, raceuma_df, haraimodoshi_dict) # 馬連的中2 fig13 = wp.cp_basic_funnel_plot_umaren_2(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中1 fig14 = wp.cp_basic_funnel_plot_umatan_1(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中2 fig15 = wp.cp_basic_funnel_plot_umatan_2(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中3 fig16 = wp.cp_basic_funnel_plot_umatan_3(race_df, raceuma_df, haraimodoshi_dict) # ワイド的中1 fig17 = wp.cp_basic_funnel_plot_wide_1(race_df, raceuma_df, haraimodoshi_dict) # 馬連配当分布 fig18 = wp.cp_choosing_the_algorithm_umaren_dist(race_df, haraimodoshi_dict) # 馬単配当分布 fig19 = wp.cp_choosing_the_algorithm_umatan_dist(race_df, haraimodoshi_dict) # ワイド配当分布 fig20 = wp.cp_choosing_the_algorithm_wide_dist(race_df, haraimodoshi_dict) # 三連複配当分布 fig21 = wp.cp_choosing_the_algorithm_sanrenpuku_dist( race_df, haraimodoshi_dict) return dcc.Loading( id="top-detail-loading", children=[ dbc.Row([ wp.dbc_graph("fig1", 2, fig1, "回収", 130), wp.dbc_graph("fig2", 4, fig2, "回収率", 130), wp.dbc_graph("fig9", 2, fig9, "得点1位着順", 130), wp.dbc_graph("fig3", 2, fig3, "単勝回収率", 130), wp.dbc_graph("fig4", 2, fig4, "複勝回収率", 130), ], className="h-20", no_gutters=True), dbc.Row([ wp.dbc_graph("fig8", 3, fig8, "券種毎回収率", 450), dbc.Col([ dbc.Row(wp.dbc_graph("fig5", 12, fig5, "残高推移", 250), ), dbc.Row(wp.dbc_graph("fig6", 12, fig6, "", 200), ) ], width=4), wp.dbc_graph("fig7", 5, fig7, "場所別回収率的中率払戻", 450), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig10", 6, fig10, "場所別単複回収率・的中率", 300), wp.dbc_graph("fig11", 6, fig11, "場所別馬券回収率・的中率", 300), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig12", 2, fig12, "馬連的中1", 300), wp.dbc_graph("fig13", 2, fig13, "馬連的中2", 300), wp.dbc_graph("fig14", 2, fig14, "馬単的中1", 300), wp.dbc_graph("fig15", 2, fig15, "馬単的中2", 300), wp.dbc_graph("fig16", 2, fig16, "馬単的中3", 300), wp.dbc_graph("fig17", 2, fig17, "ワイド的中1", 300), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig18", 6, fig18, "馬連配当分布", 250), wp.dbc_graph("fig19", 6, fig19, "馬単配当分布", 250), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig20", 6, fig20, "ワイド配当分布", 250), wp.dbc_graph("fig21", 6, fig21, "三連複配当分布", 250), ], className="h-50", no_gutters=True), ])
def race_info_render(race_df, raceuma_df, shap_df_umaren_are, shap_df_umatan_are, shap_df_sanrenpuku_are): race_sr = race_df.iloc[0] term_start_date = "2019-12-01" term_end_date = race_sr["月日"].strftime("%Y-%m-%d") ketto_toroku_bango_list = raceuma_df["血統登録番号"].tolist() raceuma_prev_df = GetData.get_raceuma_prev_df(term_start_date, term_end_date, ketto_toroku_bango_list) raceuma_prev_df = pd.merge(raceuma_df[["血統登録番号", "馬名"]], raceuma_prev_df, on="血統登録番号") raceuma_df = raceuma_df.sort_values("馬番", ascending=False) raceuma_prev_df = raceuma_prev_df.sort_values("馬名", ascending=False) # 得点 fig1 = wp.cp_basic_horizontal_bar_chart_score(raceuma_df) # 最大得点分布 #fig2 = wp.cp_basic_dot_plot_max_score(raceuma_df) # 得点バブル #fig3 = wp.cp_buble_chart_score(raceuma_df.sort_values("馬番")) # レーダーチャート fig4 = wp.cp_multiple_trace_rader_chart_score(raceuma_df.sort_values("馬番")) # 先行率 fig5 = wp.cp_basic_horizontal_box_plot_senko_rate(raceuma_prev_df) # タイム指数 fig6 = wp.cp_basic_horizontal_box_plot_time_score(raceuma_prev_df) # テーブルデータ fig7_df = raceuma_df[[ "枠番", "馬番", "馬名", "性別コード", "馬齢", "負担重量", "予想タイム指数順位", "予想タイム指数", "デフォルト得点", "得点", "馬券評価順位", "先行指数", "予想展開", "騎手名", "調教師名", "所属", "得点V3", "WIN_RATE", "JIKU_RATE", "ANA_RATE", "WIN_RANK", "JIKU_RANK", "ANA_RANK", "SCORE", "SCORE_RANK", "CK1_RATE", "CK2_RATE", "CK3_RATE", "CK1_RANK", "CK2_RANK", "CK3_RANK" ]].sort_values("馬番") # 馬連荒れ根拠 #fig8 = wp.cp_controlling_text_fontsize_with_uniformtext_umaren_basis(shap_df_umaren_are) # 馬単荒れ根拠 #fig9 = wp.cp_controlling_text_fontsize_with_uniformtext_umatan_basis(shap_df_umatan_are) # 三連複荒れ根拠 #fig10 = wp.cp_controlling_text_fontsize_with_uniformtext_sanrenpuku_basis(shap_df_sanrenpuku_are) raceuma_dropdown_option = raceuma_df[["馬名", "馬番"]].rename(columns={ "馬名": "label", "馬番": "value" }).to_dict(orient='record') return dcc.Loading( id="race-info-render-loading", children=[ dbc.Row([ wp.dbc_race_info(race_sr, 12), ], className="h-8"), # dbc.Row([ # wp.dbc_graph("fig8", 4, fig8, "馬連荒れ根拠", 300, bottom=100), # wp.dbc_graph("fig9", 4, fig9, "馬単荒れ根拠", 300, bottom=100), # wp.dbc_graph("fig10", 4, fig10, "三連複荒れ根拠", 300, bottom=100), # ], className="h-30", no_gutters=True), dbc.Row([ wp.dbc_graph("fig1", 6, fig1, "得点", 500), wp.dbc_graph("fig4", 6, fig4, "レーダーチャート", 500), ], className="h-50", no_gutters=True), # dbc.Row([ # wp.dbc_graph("fig2", 6, fig2, "最大得点分布", 500), # wp.dbc_graph("fig3", 6, fig3, "得点バブル", 500), # ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig5", 6, fig5, "先行率", 500), wp.dbc_graph("fig6", 6, fig6, "タイム指数", 500), ], className="h-50", no_gutters=True), wp.dbc_race_info_table("fig7", 16, fig7_df), dbc.Row([ wp.dbc_title("得点根拠", 6), dcc.Dropdown(id="raceinfo-dropdown-raceuma", options=raceuma_dropdown_option, style={"width": "300px"}), ], className="h-8"), dcc.Loading(id="raceuma-info-loading", children=[html.Div(id="raceinfo-raceuma-detail")]) ])
def return_analytics_render(raceuma_df, bet_df, haraimodoshi_dict): daily_summary_bet_df = cd.get_daily_summary_bet_df(bet_df) # 単勝 fig1 = wp.cp_add_steps_threshold_anda_delta_tansho(daily_summary_bet_df) # 複勝 fig2 = wp.cp_add_steps_threshold_anda_delta_fukusho(daily_summary_bet_df) # 馬連 fig3 = wp.cp_add_steps_threshold_anda_delta_umaren(daily_summary_bet_df) # 馬単 fig4 = wp.cp_add_steps_threshold_anda_delta_umatan(daily_summary_bet_df) # ワイド fig5 = wp.cp_add_steps_threshold_anda_delta_wide(daily_summary_bet_df) # 三連複 fig6 = wp.cp_add_steps_threshold_anda_delta_sanrenpuku( daily_summary_bet_df) # 月別券種別回収率推移 #fig7 = wp.cp_label_lines_with_annotations_bet_return_balance(bet_df) # 券種別配当分布 #fig8 = wp.cp_visualizing_the_distribution_haraimodoshi_dist(haraimodoshi_dict) # 場所別回収的中率 fig9 = wp.cp_bar_chart_with_line_plot_place_bet_return(bet_df) # 単勝配当分布 #fig10 = wp.cp_pie_chart_tansho_dist(haraimodoshi_dict) # 複勝配当分布 #fig11 = wp.cp_pie_chart_fukusho_dist(haraimodoshi_dict) # 馬連配当分布 #fig12 = wp.cp_pie_chart_umaren_dist(haraimodoshi_dict) # 馬単配当分布 #fig13 = wp.cp_pie_chart_umatan_dist(haraimodoshi_dict) # ワイド配当分布 #fig14 = wp.cp_pie_chart_wide_dist(haraimodoshi_dict) # 三連複配当分布 #fig15 = wp.cp_pie_chart_sanrenpuku_dist(haraimodoshi_dict) # 券種別配当分布比較 fig16 = wp.cp_choosing_the_algorithm_haraimodoshi_dist(haraimodoshi_dict) # 券種別配当中央値比較 #fig17 = wp.cp_styled_categorical_dot_plot_haraimodoshi_median(haraimodoshi_dict) return dcc.Loading( id="return-analytics-render-loading", children=[ dbc.Row([ wp.dbc_graph("fig1", 2, fig1, "単勝", 130), wp.dbc_graph("fig2", 2, fig2, "複勝", 130), wp.dbc_graph("fig3", 2, fig3, "馬連", 130), wp.dbc_graph("fig4", 2, fig4, "馬単", 130), wp.dbc_graph("fig5", 2, fig5, "ワイド", 130), wp.dbc_graph("fig6", 2, fig6, "三連複", 130), ], className="h-20", no_gutters=True), # dbc.Row([ # wp.dbc_graph("fig10", 2, fig10, "単勝配当分布", 200), # wp.dbc_graph("fig11", 2, fig11, "複勝配当分布", 200), # wp.dbc_graph("fig12", 2, fig12, "馬連配当分布", 200), # wp.dbc_graph("fig13", 2, fig13, "馬単配当分布", 200), # wp.dbc_graph("fig14", 2, fig14, "ワイド配当分布", 200), # wp.dbc_graph("fig15", 2, fig15, "三連複配当分布", 200), # ], className="h-20", no_gutters=True), dbc.Row([ wp.dbc_graph("fig9", 5, fig9, "場所別回収的中率", 600), wp.dbc_graph("fig16", 7, fig16, "券種別配当分布比較", 600), ], className="h-50", no_gutters=True), # dbc.Row([ # wp.dbc_graph("fig7", 4, fig7, "月別券種別回収率推移", 400), # wp.dbc_graph("fig8", 4, fig8, "券種別配当分布", 400), # wp.dbc_graph("fig17", 5, fig17, "券種別配当中央値比較", 400), # ], className="h-50", no_gutters=True) ])
def graph_example(): fig01 = gp.simple_line() fig02 = gp.line_with_column_encoding_color() fig03 = gp.label_lines_with_annotations() fig04 = gp.filled_line() fig05 = gp.bar_chart() fig06 = gp.customized_bar_chart() fig07 = gp.facetted_subplots() fig08 = gp.basic_bar_chart_with_plotly() fig09 = gp.grouped_bar_chart() fig10 = gp.stacked_bar_chart() fig11 = gp.bar_chart_with_hover_text() fig12 = gp.bar_chart_with_direct_labels() fig13 = gp.controlling_text_fontsize_with_uniformtext() fig14 = gp.pie_chart() fig15 = gp.buble_chart() fig16 = gp.basic_dot_plot() fig17 = gp.styled_categorical_dot_plot() fig18 = gp.basic_horizontal_bar_chart() fig19 = gp.color_palette_for_bar_chart() fig20 = gp.bar_chart_with_line_plot() fig21 = gp.sunburst_of_a_rectangular() fig22 = gp.sankey_diagram() fig23 = gp.treemap() fig24 = gp.bar_chart_with_error_bars() fig25 = gp.display_the_underlying_data() fig26 = gp.choosing_the_algorithm() fig27 = gp.difference_between_quartile_algorithms() fig28 = gp.basic_horizontal_box_plot() fig29 = gp.grouped_box_plot() fig30 = gp.rainbow_box_plot() return \ dbc.Container([ dbc.Row([ wp.dbc_top_title("グラフサンプル") ],className="h-30"), dbc.Row([ wp.dbc_title("simple_line", 4), wp.dbc_title("line_with_column_encoding_color", 4), wp.dbc_title("label_lines_with_annotations", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig01", 4, fig01), wp.dbc_graph("fig02", 4, fig02), wp.dbc_graph("fig03", 4, fig03), ], className="h-50"), dbc.Row([ wp.dbc_title("filled_line", 4), wp.dbc_title("bar_chart", 4), wp.dbc_title("customized_bar_chart", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig04", 4, fig04), wp.dbc_graph("fig05", 4, fig05), wp.dbc_graph("fig06", 4, fig06), ], className="h-50"), dbc.Row([ wp.dbc_title("facetted_subplots", 4), wp.dbc_title("basic_bar_chart_with_plotly", 4), wp.dbc_title("grouped_bar_chart", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig07", 4, fig07), wp.dbc_graph("fig08", 4, fig08), wp.dbc_graph("fig09", 4, fig09), ], className="h-50"), dbc.Row([ wp.dbc_title("stacked_bar_chart", 4), wp.dbc_title("bar_chart_with_hover_text", 4), wp.dbc_title("bar_chart_with_direct_labels", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig10", 4, fig10), wp.dbc_graph("fig11", 4, fig11), wp.dbc_graph("fig12", 4, fig12), ], className="h-50"), dbc.Row([ wp.dbc_title("controlling_text_fontsize_with_uniformtext", 4), wp.dbc_title("pie_chart", 4), wp.dbc_title("buble_chart", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig13", 4, fig13), wp.dbc_graph("fig14", 4, fig14), wp.dbc_graph("fig15", 4, fig15), ], className="h-50"), dbc.Row([ wp.dbc_title("basic_dot_plot", 4), wp.dbc_title("styled_categorical_dot_plot", 4), wp.dbc_title("basic_horizontal_bar_chart", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig16", 4, fig16), wp.dbc_graph("fig17", 4, fig17), wp.dbc_graph("fig18", 4, fig18), ], className="h-50"), dbc.Row([ wp.dbc_title("color_palette_for_bar_chart", 4), wp.dbc_title("bar_chart_with_line_plot", 4), wp.dbc_title("sunburst_of_a_rectangular", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig19", 4, fig19), wp.dbc_graph("fig20", 4, fig20), wp.dbc_graph("fig21", 4, fig21), ], className="h-50"), dbc.Row([ wp.dbc_title("sankey_diagram", 4), wp.dbc_title("treemap", 4), wp.dbc_title("bar_chart_with_error_bars", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig22", 4, fig22), wp.dbc_graph("fig23", 4, fig23), wp.dbc_graph("fig24", 4, fig24), ], className="h-50"), dbc.Row([ wp.dbc_title("display_the_underlying_data", 4), wp.dbc_title("choosing_the_algorithm", 4), wp.dbc_title("difference_between_quartile_algorithms", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig25", 4, fig25), wp.dbc_graph("fig26", 4, fig26), wp.dbc_graph("fig27", 4, fig27), ], className="h-50"), dbc.Row([ wp.dbc_title("basic_horizontal_box_plot", 4), wp.dbc_title("grouped_box_plot", 4), wp.dbc_title("rainbow_box_plot", 4), ], className="h-8"), dbc.Row([ wp.dbc_graph("fig28", 4, fig28), wp.dbc_graph("fig29", 4, fig29), wp.dbc_graph("fig30", 4, fig30), ], className="h-50"), ], style={"height": "90vh"}, fluid=True )
def kpi_analytics_render(race_df, raceuma_df, bet_df, haraimodoshi_dict, end_date): raceuma_df.loc[:, "競走馬コード"] = raceuma_df.apply(lambda x : str(x["競走コード"]) + str(x["馬番"]).zfill(2), axis=1) # 得点1位着順 fig1 = wp.cp_pie_chart_score_1(raceuma_df) # 単勝回収率 fig2_df = raceuma_df[raceuma_df["馬券評価順位"] == 1].copy() fig2_df_diff = fig2_df[fig2_df["年月日"] != end_date] fig2 = wp.cp_add_steps_threshold_anda_delta_tansho_return(fig2_df, fig2_df_diff) # 複勝回収率 fig3_df = raceuma_df[raceuma_df["馬券評価順位"] == 1].copy() fig3_df_diff = fig3_df[fig3_df["年月日"] != end_date] fig3 = wp.cp_add_steps_threshold_anda_delta_fukusho_return(fig3_df, fig3_df_diff) # 1番人気 fig4 = wp.cp_pie_chart_ninki_1(raceuma_df) # 単勝回収率 fig5_df = raceuma_df[raceuma_df["単勝人気"] == 1].copy() fig5_df_diff = fig5_df[fig5_df["年月日"] != end_date] fig5 = wp.cp_add_steps_threshold_anda_delta_tansho_return(fig5_df, fig5_df_diff) # 複勝回収率 fig6_df = raceuma_df[raceuma_df["単勝人気"] == 1].copy() fig6_df_diff = fig6_df[fig6_df["年月日"] != end_date] fig6 = wp.cp_add_steps_threshold_anda_delta_fukusho_return(fig6_df, fig6_df_diff) # 場所別単複回収率・的中率 #fig7 = wp.cp_multiple_line_and_bar_chart_place_tanpuku_return(race_df, raceuma_df) # 場所別馬券回収率・的中率 #fig8 = wp.cp_multiple_line_and_bar_chart_place_bet_return(bet_df) # 馬連的中1 fig10 = wp.cp_stacked_funnel_plot_umaren_1(race_df, raceuma_df, haraimodoshi_dict) # 馬連的中2 fig11 = wp.cp_stacked_funnel_plot_umaren_2(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中1 fig12 = wp.cp_stacked_funnel_plot_umatan_1(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中2 fig13 = wp.cp_stacked_funnel_plot_umatan_2(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中3 fig14 = wp.cp_stacked_funnel_plot_umatan_3(race_df, raceuma_df, haraimodoshi_dict) # ワイド的中1 fig15 = wp.cp_stacked_funnel_plot_wide_1(race_df, raceuma_df, haraimodoshi_dict) # 馬連的中1 fig20 = wp.cp_parallel_categories_diagram_umaren_1(race_df, raceuma_df, haraimodoshi_dict) # 馬連的中2 fig21 = wp.cp_parallel_categories_diagram_umaren_2(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中1 fig22 = wp.cp_parallel_categories_diagram_umatan_1(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中2 fig23 = wp.cp_parallel_categories_diagram_umatan_2(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中3 fig24 = wp.cp_parallel_categories_diagram_umatan_3(race_df, raceuma_df, haraimodoshi_dict) # ワイド的中1 fig25 = wp.cp_parallel_categories_diagram_wide_1(race_df, raceuma_df, haraimodoshi_dict) return dcc.Loading(id="kpi-analytics-lender-loading", children=[ dbc.Row([ wp.dbc_graph("fig1", 2, fig1, "得点1位着順", 130), wp.dbc_graph("fig2", 2, fig2, "単勝回収率", 130), wp.dbc_graph("fig3", 2, fig3, "複勝回収率", 130), wp.dbc_graph("fig4", 2, fig4, "1番人気", 130), wp.dbc_graph("fig5", 2, fig5, "単勝回収率", 130), wp.dbc_graph("fig6", 2, fig6, "複勝回収率", 130), ], className="h-20", no_gutters=True), # dbc.Row([ # wp.dbc_graph("fig7", 6, fig7, "場所別単複回収率・的中率", 400), # wp.dbc_graph("fig8", 6, fig8, "場所別馬券回収率・的中率", 400), # ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig10", 5, fig10, "馬連的中1", 400), wp.dbc_graph("fig20", 7, fig20, "", 400), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig11", 5, fig11, "馬連的中2", 400), wp.dbc_graph("fig21", 7, fig21, "", 400), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig12", 5, fig12, "馬単的中1", 400), wp.dbc_graph("fig22", 7, fig22, "", 400), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig13", 5, fig13, "馬単的中2", 400), wp.dbc_graph("fig23", 7, fig23, "", 400), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig14", 5, fig14, "馬単的中3", 400), wp.dbc_graph("fig24", 7, fig24, "", 400), ], className="h-50", no_gutters=True), dbc.Row([ wp.dbc_graph("fig15", 5, fig15, "ワイド的中1", 400), wp.dbc_graph("fig25", 7, fig25, "", 400), ], className="h-50", no_gutters=True), ])
def race_trend(): race_df = GetData.get_race_data_real().query("データ区分 == '7'") raceuma_df = GetData.get_raceuma_data_real().query("データ区分 == '7'") raceuma_df.loc[:, "競走馬コード"] = raceuma_df.apply(lambda x : str(x["競走コード"]) + str(x["馬番"]).zfill(2), axis=1) bet_df = GetData.get_bet_data_real() haraimodoshi_dict = GetData.get_haraimodoshi_dict_real() if len(race_df.index) == 0 or len(raceuma_df.index) == 0: return html.P("no data") # 得点1位着順 fig1 = wp.cp_pie_chart_score_1(raceuma_df) # 単勝回収率 fig2_df = raceuma_df[raceuma_df["馬券評価順位"] == 1].copy() fig2_value = fig2_df["単勝配当"].mean() fig2_reference = 0 fig2 = gp.add_steps_threshold_anda_delta(fig2_value, fig2_reference) # 複勝回収率 fig3_df = raceuma_df[raceuma_df["馬券評価順位"] == 1].copy() fig3_value = fig3_df["複勝配当"].mean() fig3_reference = 0 fig3 = gp.add_steps_threshold_anda_delta(fig3_value, fig3_reference) # 1番人気 fig4 = wp.cp_pie_chart_ninki_1(raceuma_df) # 単勝回収率 fig5_df = raceuma_df[raceuma_df["単勝人気"] == 1].copy() fig5_value = fig5_df["単勝配当"].mean() fig5_reference = 0 fig5 = gp.add_steps_threshold_anda_delta(fig5_value, fig5_reference) # 複勝回収率 fig6_df = raceuma_df[raceuma_df["単勝人気"] == 1].copy() fig6_value = fig6_df["複勝配当"].mean() fig6_reference = 0 fig6 = gp.add_steps_threshold_anda_delta(fig6_value, fig6_reference) # 場所別単複回収率・的中率 fig7 = wp.cp_multiple_line_and_bar_chart_place_tanpuku_return(race_df, raceuma_df) if len(bet_df.index) != 0: # 場所別馬券回収率・的中率 fig8 = wp.cp_multiple_line_and_bar_chart_place_bet_return(bet_df) # 券種別結果 summary_bet_df = cd.get_summary_bet_df(bet_df) fig9 = wp.cp_simple_waterfall_chart_balance_change(summary_bet_df) else: fig8 = "" fig9 = "" # 単勝配当分布 #fig10 = wp.cp_pie_chart_tansho_dist(haraimodoshi_dict) # 複勝配当分布 #fig11 = wp.cp_pie_chart_fukusho_dist(haraimodoshi_dict) # 馬連配当分布 #fig12 = wp.cp_pie_chart_umaren_dist(haraimodoshi_dict) # 馬単配当分布 #fig13 = wp.cp_pie_chart_umatan_dist(haraimodoshi_dict) # ワイド配当分布 #fig14 = wp.cp_pie_chart_wide_dist(haraimodoshi_dict) # 三連複配当分布 #fig15 = wp.cp_pie_chart_sanrenpuku_dist(haraimodoshi_dict) # 馬連的中1 fig20 = wp.cp_stacked_funnel_plot_umaren_1(race_df, raceuma_df, haraimodoshi_dict) # 馬連的中2 fig21 = wp.cp_stacked_funnel_plot_umaren_2(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中1 fig22 = wp.cp_stacked_funnel_plot_umatan_1(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中2 fig23 = wp.cp_stacked_funnel_plot_umatan_2(race_df, raceuma_df, haraimodoshi_dict) # 馬単的中3 fig24 = wp.cp_stacked_funnel_plot_umatan_3(race_df, raceuma_df, haraimodoshi_dict) # ワイド的中1 fig25 = wp.cp_stacked_funnel_plot_wide_1(race_df, raceuma_df, haraimodoshi_dict) return dcc.Loading(id="racetrend-loading", children=[ dbc.Container([ dbc.Row([ wp.dbc_top_title("todays race trend") ], className="h-30"), dbc.Row([ wp.dbc_graph("fig1", 2, fig1, "得点1位着順", 130), wp.dbc_graph("fig2", 2, fig2, "単勝回収率", 130), wp.dbc_graph("fig3", 2, fig3, "複勝回収率", 130), wp.dbc_graph("fig4", 2, fig4, "1番人気", 130), wp.dbc_graph("fig5", 2, fig5, "単勝回収率", 130), wp.dbc_graph("fig6", 2, fig6, "複勝回収率", 130), ], className="h-20", no_gutters=True), # dbc.Row([ # wp.dbc_graph("fig10", 2, fig10, "単勝配当分布", 200), # wp.dbc_graph("fig11", 2, fig11, "複勝配当分布", 200), # wp.dbc_graph("fig12", 2, fig12, "馬連配当分布", 200), # wp.dbc_graph("fig13", 2, fig13, "馬単配当分布", 200), # wp.dbc_graph("fig14", 2, fig14, "ワイド配当分布", 200), # wp.dbc_graph("fig15", 2, fig15, "三連複配当分布", 200), # ], className="h-20", no_gutters=True), dbc.Row([ wp.dbc_graph("fig7", 4, fig7, "場所別単複回収率・的中率", 300), wp.dbc_graph("fig8", 4, fig8, "場所別馬券回収率・的中率", 300), wp.dbc_graph("fig9", 4, fig9, "券種別結果", 300), ], className="h-30", no_gutters=True), dbc.Row([ wp.dbc_graph("fig20", 2, fig20, "馬連的中1", 400), wp.dbc_graph("fig21", 2, fig21, "馬連的中2", 400), wp.dbc_graph("fig22", 2, fig22, "馬単的中1", 400), wp.dbc_graph("fig23", 2, fig23, "馬単的中2", 400), wp.dbc_graph("fig24", 2, fig24, "馬単的中3", 400), wp.dbc_graph("fig25", 2, fig25, "ワイド的中1", 400), ], className="h-30", no_gutters=True), ], style={"height": "90vh"}, fluid=True )])