使用先知将数据框中的数据导出到csv

时间:2019-11-24 18:34:42

标签: python facebook-prophet

我预测很多文章都将使用先知。我是否编写了所有代码,但不知道如何导出它并确定每篇文章的值。这是我的代码:

import pandas as pd
from fbprophet import Prophet  
data = pd.read_csv(r'C:\Users\XXXX.csv')
data=data.rename(columns={'fecha':'ds', 'cantidad':'y'})
ids = data['codigo'].unique()
series = []
for id in ids:
    f = data[data['codigo'] == id]
    series.append(f)

def run_prophet(timeserie):
    model = Prophet(yearly_seasonality=False,daily_seasonality=False, uncertainty_samples=100)
    model.fit(timeserie)
    forecast = model.make_future_dataframe(periods=90, include_history=False)
    forecast = model.predict(forecast)
    return forecast

from multiprocessing import Pool
from tqdm import tqdm
import multiprocessing
import mati

if __name__ ==  '__main__': 
 num_processors = multiprocessing.cpu_count()
 p=Pool(processes = num_processors)
 predictions = list(tqdm(p.imap(mati.run_prophet, mati.series), total=len(mati.series)))
 print(predictions)

0 个答案:

没有答案