facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.33k stars 4.52k forks source link

'Prophet' object has no attribute 'stan_backend' Mac OSX #2057

Open vvennela opened 2 years ago

vvennela commented 2 years ago

Hello all, I know this topic has been done to death a couple times but I tried a bunch of different solutions(including downgrading my PyStan and my cmdstanpy). I'm trying to learn Facebook(now Meta!) Prophet using this tutorial: https://www.youtube.com/watch?v=0E_31WqVzCY&t=1303s

My code is pretty much replicated from the youtube video:

## importing various libraries
import streamlit as st 
import yfinance as yf

from fbprophet import Prophet
from fbprophet.plot import plot_plotly
from datetime import date
from plotly import graph_objs as go

START = "2015-01-01"
TODAY = date.today().strftime("%Y-%m-%d")

st.title("Stock Prediction Algorithm")

stocks = ("AAPL", "GOOG", "MSFT", "GME")
selected_stocks = st.selectbox("Select dataset for prediction", stocks)
slider_year = st.slider("Years of Prediction:", 1, 10)
period = slider_year * 365

@st.cache
def load_data(ticker):
    data = yf.download(ticker, START, TODAY)
    data.reset_index(inplace=True)
    return data

data_load_state = st.text("Loading Data")
data = load_data(selected_stocks) ## call the function specified abpve
data_load_state.text("Data has been loaded")

st.subheader('Raw Data')
st.write(data.tail())

def raw_Plot():
    fig = go.Figure()
    fig.add_trace(go.Scatter(x=data["Date"], y=data["Open"], name = "Stock_Open"))
    fig.add_trace(go.Scatter(x=data["Date"], y=data["Close"], name = "Stock_Close"))
    fig.layout.update(title_text = "Time Series Data", xaxis_rangeslider_visible=True)
    st.plotly_chart(fig)

raw_Plot()

df_train = data[['Date','Close']]
df_train = df_train.rename(columns = {"Date": "ds", "Close": "y"})

model = Prophet()
model.fit(df_train)
futureModel = model.make_future_dataframe(periods=period)
forecast = model.predict(futureModel)

st.subheader("Forecasted Data")
st.write(forecast.tail())

And I keep getting the same error, which is Prophet object has no attribute stan_backend.

My device specifics are as follows: Mac OS Monterey MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports) Processor 1.4 GHz Quad-Core Intel Core i5

My apologies if I've done something incorrect in this post, I am really new to opening issues. ``

tcuongd commented 2 years ago

Hello, can you please post the steps you took to install the package (please follow this: https://github.com/facebook/prophet#installation-in-python or install with conda), and the exact error message?

akosfurton commented 2 years ago

This has been resolved in prophet 1.1. You can now pip install prophet directly from PyPI