@plotting.customize<EOL>def create_bayesian_tear_sheet(returns, benchmark_rets=None,<EOL>live_start_date=None, samples=<NUM_LIT>,<EOL>return_fig=False, stoch_vol=False,<EOL>progressbar=True):
if not have_bayesian:<EOL><INDENT>raise NotImplementedError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>if live_start_date is None:<EOL><INDENT>raise NotImplementedError(<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>live_start_date = ep.utils.get_utc_timestamp(live_start_date)<EOL>df_train = returns.loc[returns.index < live_start_date]<EOL>df_test = returns.loc[returns.index >= live_start_date]<EOL>print("<STR_LIT>")<EOL>previous_time = time()<EOL>start_time = previous_time<EOL>trace_t, ppc_t = bayesian.run_model('<STR_LIT:t>', df_train,<EOL>returns_test=df_test,<EOL>samples=samples, ppc=True,<EOL>progressbar=progressbar)<EOL>previous_time = timer("<STR_LIT>", previous_time)<EOL>print("<STR_LIT>")<EOL>trace_best = bayesian.run_model('<STR_LIT>', df_train,<EOL>returns_test=df_test,<EOL>samples=samples,<EOL>progressbar=progressbar)<EOL>previous_time = timer("<STR_LIT>", previous_time)<EOL>fig = plt.figure(figsize=(<NUM_LIT>, <NUM_LIT:10> * <NUM_LIT:2>))<EOL>gs = gridspec.GridSpec(<NUM_LIT:9>, <NUM_LIT:2>, wspace=<NUM_LIT>, hspace=<NUM_LIT>)<EOL>axs = []<EOL>row = <NUM_LIT:0><EOL>ax_cone = plt.subplot(gs[row, :])<EOL>bayesian.plot_bayes_cone(df_train, df_test, ppc_t, ax=ax_cone)<EOL>previous_time = timer("<STR_LIT>", previous_time)<EOL>row += <NUM_LIT:1><EOL>axs.append(plt.subplot(gs[row, <NUM_LIT:0>]))<EOL>axs.append(plt.subplot(gs[row, <NUM_LIT:1>]))<EOL>row += <NUM_LIT:1><EOL>axs.append(plt.subplot(gs[row, <NUM_LIT:0>]))<EOL>axs.append(plt.subplot(gs[row, <NUM_LIT:1>]))<EOL>row += <NUM_LIT:1><EOL>axs.append(plt.subplot(gs[row, <NUM_LIT:0>]))<EOL>axs.append(plt.subplot(gs[row, <NUM_LIT:1>]))<EOL>row += <NUM_LIT:1><EOL>axs.append(plt.subplot(gs[row, :]))<EOL>bayesian.plot_best(trace=trace_best, axs=axs)<EOL>previous_time = timer("<STR_LIT>", previous_time)<EOL>row += <NUM_LIT:1><EOL>ax_ret_pred_day = plt.subplot(gs[row, <NUM_LIT:0>])<EOL>ax_ret_pred_week = plt.subplot(gs[row, <NUM_LIT:1>])<EOL>day_pred = ppc_t[:, <NUM_LIT:0>]<EOL>p5 = scipy.stats.scoreatpercentile(day_pred, <NUM_LIT:5>)<EOL>sns.distplot(day_pred,<EOL>ax=ax_ret_pred_day<EOL>)<EOL>ax_ret_pred_day.axvline(p5, linestyle='<STR_LIT>', linewidth=<NUM_LIT>)<EOL>ax_ret_pred_day.set_xlabel('<STR_LIT>')<EOL>ax_ret_pred_day.set_ylabel('<STR_LIT>')<EOL>ax_ret_pred_day.text(<NUM_LIT>, <NUM_LIT>, '<STR_LIT>' % p5,<EOL>verticalalignment='<STR_LIT>',<EOL>horizontalalignment='<STR_LIT:right>',<EOL>transform=ax_ret_pred_day.transAxes)<EOL>previous_time = timer("<STR_LIT>", previous_time)<EOL>week_pred = (<EOL>np.cumprod(ppc_t[:, :<NUM_LIT:5>] + <NUM_LIT:1>, <NUM_LIT:1>) - <NUM_LIT:1>)[:, -<NUM_LIT:1>]<EOL>p5 = scipy.stats.scoreatpercentile(week_pred, <NUM_LIT:5>)<EOL>sns.distplot(week_pred,<EOL>ax=ax_ret_pred_week<EOL>)<EOL>ax_ret_pred_week.axvline(p5, linestyle='<STR_LIT>', linewidth=<NUM_LIT>)<EOL>ax_ret_pred_week.set_xlabel('<STR_LIT>')<EOL>ax_ret_pred_week.set_ylabel('<STR_LIT>')<EOL>ax_ret_pred_week.text(<NUM_LIT>, <NUM_LIT>, '<STR_LIT>' % p5,<EOL>verticalalignment='<STR_LIT>',<EOL>horizontalalignment='<STR_LIT:right>',<EOL>transform=ax_ret_pred_week.transAxes)<EOL>previous_time = timer("<STR_LIT>", previous_time)<EOL>if benchmark_rets is not None:<EOL><INDENT>print("<STR_LIT>")<EOL>benchmark_rets = benchmark_rets.loc[df_train.index]<EOL>trace_alpha_beta = bayesian.run_model('<STR_LIT>', df_train,<EOL>bmark=benchmark_rets,<EOL>samples=samples,<EOL>progressbar=progressbar)<EOL>previous_time = timer("<STR_LIT>", previous_time)<EOL>row += <NUM_LIT:1><EOL>ax_alpha = plt.subplot(gs[row, <NUM_LIT:0>])<EOL>ax_beta = plt.subplot(gs[row, <NUM_LIT:1>])<EOL>sns.distplot((<NUM_LIT:1> + trace_alpha_beta['<STR_LIT>'][<NUM_LIT:100>:])**<NUM_LIT> - <NUM_LIT:1>,<EOL>ax=ax_alpha)<EOL>sns.distplot(trace_alpha_beta['<STR_LIT>'][<NUM_LIT:100>:], ax=ax_beta)<EOL>ax_alpha.set_xlabel('<STR_LIT>')<EOL>ax_alpha.set_ylabel('<STR_LIT>')<EOL>ax_beta.set_xlabel('<STR_LIT>')<EOL>ax_beta.set_ylabel('<STR_LIT>')<EOL>previous_time = timer("<STR_LIT>", previous_time)<EOL><DEDENT>if stoch_vol:<EOL><INDENT>returns_cutoff = <NUM_LIT><EOL>print(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(returns_cutoff)<EOL>)<EOL>if df_train.size > returns_cutoff:<EOL><INDENT>df_train_truncated = df_train[-returns_cutoff:]<EOL><DEDENT>_, trace_stoch_vol = bayesian.model_stoch_vol(df_train_truncated)<EOL>previous_time = timer(<EOL>"<STR_LIT>", previous_time)<EOL>row += <NUM_LIT:1><EOL>ax_volatility = plt.subplot(gs[row, :])<EOL>bayesian.plot_stoch_vol(<EOL>df_train_truncated, trace=trace_stoch_vol, ax=ax_volatility)<EOL>previous_time = timer(<EOL>"<STR_LIT>", previous_time)<EOL><DEDENT>total_time = time() - start_time<EOL>print("<STR_LIT>".format(total_time))<EOL>gs.tight_layout(fig)<EOL>if return_fig:<EOL><INDENT>return fig<EOL><DEDENT>
Generate a number of Bayesian distributions and a Bayesian
cone plot of returns.

Plots: Sharpe distribution, annual volatility distribution,
annual alpha distribution, beta distribution, predicted 1 and 5
day returns distributions, and a cumulative returns cone plot.

Parameters
----------
returns : pd.Series
    Daily returns of the strategy, noncumulative.
     - See full explanation in create_full_tear_sheet.
benchmark_rets : pd.Series, optional
    Daily noncumulative returns of the benchmark.
     - This is in the same style as returns.
live_start_date : datetime, optional
    The point in time when the strategy began live
    trading, after its backtest period.
samples : int, optional
    Number of posterior samples to draw.
return_fig : boolean, optional
    If True, returns the figure that was plotted on.
stoch_vol : boolean, optional
    If True, run and plot the stochastic volatility model
progressbar : boolean, optional
    If True, show a progress bar