Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Theano
import pymc3 as pm import pandas as pd import numpy as np import theano.tensor as tt from bokeh.plotting import figure, show from bokeh.models import BoxAnnotation, Span, Label, Legend from bokeh.io import output_notebook from bokeh.palettes import brewer data_monthly = pd.read_csv(pm.get_data("monthly_in_situ_co2_mlo.csv"), header=56) # - replace -99.99 with NaN data_monthly.replace(to_replace=-99.99, value=np.nan, inplace=True) # fix column names cols = ["year", "month", "--", "--", "CO2", "seasonaly_adjusted", "fit", "seasonally_adjusted_fit", "CO2_filled", "seasonally_adjusted_filled"] data_monthly.columns = cols cols.remove("--"); cols.remove("--") data_monthly = data_monthly[cols] # drop rows with nan data_monthly.dropna(inplace=True) # fix time index data_monthly["day"] = 15 data_monthly.index = pd.to_datetime(data_monthly[[...