Рет қаралды 6
import pandas as pd
from prophet import Prophet
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
#load dataset
df = pd.read_csv('/komputasi/polisi.csv')
#Split data
df_train, df_test = train_test_split(df, shuffle=False)
#create and fit model
m = Prophet()
m.fit(df_train)
#make future dataframe
future = m.make_future_dataframe(periods=730)
#predict
forecast = m.predict(future)
#evaluate
forecast_df = forecast[['ds', 'yhat']]
actual = df_test['y']
#plot hasil
m.plot(forecast)
m.plot_components(forecast)