Giter Site home page Giter Site logo

pm-prophet's Issues

Updated readme for project direction?

As it is, it is hard to gain a sense of where this project is going, or what needs to still be done (and what exactly has been accomplished), which an updated readme would solve.

Not only would this improve readability, but help others help out with contributions as well.

auto_changepoint issue

Hi!
I am trying to use the pm-prophet feature auto_changepoints to detect changepoints in a dataset. It gives seemingly good results, but when running the script on the same dataset twice, the inferred changepoints are located different places. How can i make the auto_changepoints more accurate? does this have to do with my sample size?

additive_seasonality *= self.data.y.max()

I've been reading through the code and I met this line at model.py, line 293:
additive_seasonality *= self.data.y.max()
and in a few other places around the code. Could anyone comment on its exact purpose?

This seems to me to be related to data standartisation, but data standartisation is also done later, in the model specification:
observed=(self.data['y'] - self.data['y'].mean()) / self.data['y'].std()

At the very least, shouldn't it be
additive_seasonality *= self.data.y.abs().max()
to account for the possiblity that, say, range of y is [-1,0] and thus y.max()==0 ?

PyMC3 has been renamed PyMC

Hi,
PyMC3 has been renamed PyMC. If this affects you and you have questions, or you want someone to direct your rage at I'm available! Do let me know how i, or any of the PyMC devs can help.

Ravin

AttributeError: 'str' object has no attribute 'value'

Trying to run the same simple model with version 0.2.1, I get the error below.

m = PMProphet(df_city, name='model')

# Fit the model (using NUTS)
m.fit(method='NUTS')
~/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pmprophet/model.py in fit(self, draws, chains, trace_size, method, map_initialization, finalize, step_kwargs, sample_kwargs)
    610             if draws:
    611                 if method != Sampler.ADVI:
--> 612                     step_method = method.value(**step_kwargs)
    613                     self.trace = pm.sample(
    614                         draws,

AttributeError: 'str' object has no attribute 'value'

[Feature Request] Simplify API for regressors

  1. Can the prior definition for each regressor be moved within the add_regressor() method by passing the distribution object as a parameter?

  2. Can a regressor_coefficients() method be created similar to what Prophet has to get the distribution of coefficients?

fourier_series coefficients

Hi!
I have been working with the source code to pm-prophet for a while, and I am wondering about how the fourier-series and the accompanying coefficients a1,b1,a2,b2,....,an,bn in the standard fourier series are sampled. As far as I can tell, the fourier_series() function returns both sine and cosine series with length of input data t, but self.data["f%s_%s"%(seasonality,order_idx)]_ only uses the sine series. As an example, a fourier_series of order 4 should have 8 self.priors["seasonality"] -RVs but has only 4.

How is this fourier series modelled?
Thank you in advance!

Heteroskedasticity

Hi,

Great package. I was considering attempting something similar, but was very grateful to find your implementation!

I'm modelling data that is generally periodic and trending but is heteroskedastic and rather than transform the heteroskedasticity out of the data as is usually recommended, I would like to model it specifically. My sense is that the GAM approach used by Prophet could model the data very well if I could model the varying variance explicitly.

My initial desire is to try to model the variance itself, as opposed to the original timeseries, and see if I can identify the points where the variance changes.

To that end, I'm trying to better understand how the truncated dirichlet process used herein and copied below accomplishes this. In particular, I don't understand the use of tt.extra_ops.cumprod(1 - beta)[:-1] is this the stickbreaking function?

Also, how does the switch work exactly at tt.switch(tt.gt(x, 1e-4), x, 0)

                    k = self.n_changepoints
                    alpha = pm.Gamma("alpha_%s" % self.name, 1.0, 1.0)
                    beta = pm.Beta("beta_%s" % self.name, 1.0, alpha, shape=k)
                    w1 = pm.Deterministic(
                        "w1_%s" % self.name,
                        tt.concatenate([[1], tt.extra_ops.cumprod(1 - beta)[:-1]])
                        * beta,
                    )
                    w, _ = theano.map(
                        fn=lambda x: tt.switch(tt.gt(x, 1e-4), x, 0), sequences=[w1]
                    )
                    self.w = pm.Deterministic("w_%s" % self.name, w)

can I access the probabilities for a given time-step being a changepoint after sampling?

Thanks in advance

Categorical Variables

can you package work with multivariate categorical time series and multivariate time series when some features are categorical and some some features are continues

Example not working on Pandas 1.0

I am really excited about this library but cannot get it to work past fitting the model because of an error where it says "AttributeError": Dataframe object has no attribute 'ix'.

I have tried downgrading pandas to .19 and .23 but still won't work. Would love to get this working.

Screen Shot 2020-04-30 at 9 14 23 AM

AttributeError when fitting example model

Hi and thank you for this very useful project! It's been a while since I wanted to give it a try and I finally found a use case :)
However, trying to get started, I couldn't run the model you have in the examples: when hitting m.fit(method='NUTS') I encountered:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-f9eeec8c375f> in <module>
      1 # Fit the model (using NUTS)
----> 2 m.fit(method='NUTS')

~/opt/anaconda3/envs/fund/lib/python3.7/site-packages/pmprophet/model.py in fit(self, draws, chains, trace_size, method, map_initialization, finalize, step_kwargs, sample_kwargs)
    610             if draws:
    611                 if method != Sampler.ADVI:
--> 612                     step_method = method.value(**step_kwargs)
    613                     self.trace = pm.sample(
    614                         draws,

AttributeError: 'str' object has no attribute 'value'

I also tried on the dataframe I'm trying to fit and it has the same behavior. Does it look like an issue? Or could it come from my installation? I'm running on pm-prophet 0.2.8, PyMC3 master and theano 1.0.4.
Thanks in advance for your help, and thanks again for your work!

Would you like to consider adding this to pymc-learn and pymc3-models?

As per title! ๐Ÿ˜„ I like a lot of what's going on here, and would love to see a few things happen:

  • Reduce your maintenance burden.
  • Package this model implementation with other "standard" but also "flexible" models.
  • Reduce end-user environment complexity by packaging together things that are clearly related.

cc: @Emaasit, creator of pymc-learn, and @parsing-science, creator of pymc_models.

Is GPU included?

Hello Developers of this wonderful repository,
I have tried samples. It looks good. But I haven't got any settings for the usage of GPU. It works with the CPU only. What if I am willing to go with the GPUs in my system for the training?
Can you help and guide me?

Multiple extra data

Hello,
I use PMProphet with several features. Since I don't know the future value of the features, I generate a lot of scenarios. Is there any way to pass all these scenarios to model so that the uncertainty of the result consists of two (uncertainty of the model coefficients and uncertainty of the features)? Or is there any way to introduce such functionality using the capabilities of pymc3 (without making a loop through the scenarios) ?

AttributeError: 'DataFrame' object has no attribute 'ix'

Hi-- first off. thank you for making this. i have been looking for a pymc3 based prophet alternative for a while (not a fan of the installation process for pystan)..

I am trying to run this peyton manning example from the read me, and the underlying module is using the deprecated ix function. Any way we could upgrade the module for the latest version of pandas? Ive never submitted a pull requests but I can potentially help.

UnboundLocalError: local variable 'w' referenced before assignment

I tried to run a very simple model with weekly data from a pandas dataframe and get the below error. I'm not sure how to troubleshoot this. I get the same error if I add more explicit params for changepoints etc.

FYI, this exact dataset has been fit with fbprophet successfully.

Version: pmprophet-0.2
Python: Python 3.6.7

m = PMProphet(df_city, name='model')
m.fit(method='NUTS')
~/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pmprophet/model.py in generate_priors(self)
    243                 else:
    244                     k = len(self.changepoints)
--> 245                 cgpt = pm.Deterministic('cgpt', w * pm.Laplace('cgpt_inner', 0, self.changepoints_prior_scale, shape=k))
    246                 self.priors['changepoints'] = pm.Deterministic('changepoints_%s' % self.name, cgpt)
    247             if self.intercept and 'intercept' not in self.priors:

UnboundLocalError: local variable 'w' referenced before assignment

Non-Linear Forecasting with pm-prophet

Hi,
I am trying to use pm-prophet to forecast data with little seasonality. When using the predict function, I would assume that the forecast gets less and less certain over time, some kind of diverging confidence interval. It however seems to me there is only a linear forecast being performed. Does the pm-prophet support what I am looking for?

Here is my code for convenience:
sd = .1
N = 200
deltas = np.random.normal(scale=sd, size=N)
y = np.cumsum(deltas)
x = np.arange(N)
df = pd.DataFrame() ## label
df["ds"] = pd.date_range(start="2018-01-01", periods=200)
df["y"] = y
print(df)
m = PMProphet(df, auto_changepoints=True, growth=True, name="model")
m.fit(method=Sampler.METROPOLIS, chains=1, draws=2000)
pm.traceplot(m.trace)
plt.show()
m.predict(50, alpha=0.2, include_history=True, plot=True)
m.plot_components(intercept=False)

plt.show()

image

question

Hi
How is this different from FBProphet?
Is there some reference document available for this? Thanks

prediction dependent on the order of the added sesonality

hi,
I have discovered that altering the order of which I add the weekly and monthly seasonalities to my model affects the outcome. The two figures below show weekly added before monthly, and monthly added before weekly. What causes this order depencency?

7then30
30then7

Example code not working in Python 2.7

I am trying to reproduce the example using example_wp_log_peyton_manning.csv with Python 2.7. I have all of the correct dependencies from the requirements file, but I keep getting the error

ValueError: Mass matrix contains zeros on the diagonal. 
The derivative of RV `intercept_model`.ravel()[0] is zero.
The derivative of RV `changepoints_model`.ravel()[0] is zero.
The derivative of RV `seasonality_model`.ravel()[2] is zero.
The derivative of RV `seasonality_model`.ravel()[3] is zero.
The derivative of RV `seasonality_model`.ravel()[4] is zero.
The derivative of RV `seasonality_model`.ravel()[5] is zero.
The derivative of RV `sigma_model_log__`.ravel()[0] is zero.

The code I used is attached with references to matplotlib removed
test.txt
with versions:
theano == 1.0.3
numpy == 1.15.3
pandas == 0.23.4
pymc3 == 3.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.