示例#1
0
def fbprophet_univariate_best_r() -> float:
    """
      :return:  Provides best r for a randomly chosen data stream
                Takes about 12 hrs to run
    """
    mr = MicroReader()
    names = mr.get_stream_names()
    okay = False
    while not okay:
        name = random.choice(names)
        n_obs = len(mr.get_lagged_values(name=name))
        okay = n_obs > PROPHET_META['n_warm'] + 50 and '~' not in name
    url = 'https://www.microprediction.org/stream_dashboard.html?stream=' + name.replace(
        '.json', '')
    print('We will find the best fbprophet hyper-parameters for ' + url)
    print('There are ' + str(n_obs) + ' observations in the series.')
    print(
        "Prophet will be fit for most of them, after a burn_in, and for many different hyper-params. Don't hold your breathe."
    )

    best_r, best_value, info = optimal_r_for_stream(
        f=fbprophet_univariate_r2,
        name=name,
        k=10,
        optimizer=dlib_default_cube,
        n_burn=PROPHET_META['n_warm'] + 20,
        n_trials=50,
        n_dim=2)
    pprint(info)
    params = prophet_params(r=best_r, dim=2)
    pprint(params)
示例#2
0
 def random_regular(min_len=500):
     """ Randomly selected univariate series
     :return:  y, t, url
     """
     mr = MicroReader()
     names = mr.get_stream_names()
     okay = False
     while not okay:
         name = random.choice(names)
         n_obs = len(mr.get_lagged_values(name=name,count=10000))
         okay = n_obs > min_len and '~' not in name
     url = 'https://www.microprediction.org/stream_dashboard.html?stream=' +name.replace('.json','')
     return name, url
示例#3
0
 def random_stream_name(min_len=500, exclude_str=None, include_str=None):
     """ Randomly selected univariate series
             :return:  y, t, url
             """
     mr = MicroReader()
     names = mr.get_stream_names()
     okay = False
     while not okay:
         name = random.choice(names)
         n_obs = len(mr.get_lagged_values(name=name, count=10000))
         okay = True
         if exclude_str is not None and exclude_str in name:
             okay = False
         if include_str is not None and include_str not in name:
             okay = False
         if n_obs < min_len:
             okay = False
     url = 'https://www.microprediction.org/stream_dashboard.html?stream=' + name.replace(
         '.json', '')
     return name, url
示例#4
0
def plot_helicopter_lags():
    """ Plot a subset of the SciML helicopter challenge data .. psi only """
    mr = MicroReader()
    xs = mr.get_lagged_values('helicopter_psi.json')
    plt.plot(xs)
示例#5
0
def test_imports():
    mr = MicroReader()
    values = mr.get_lagged_values(name='cop.json')
    assert len(values)>500