I'm doing a prophet prediction for a dataframe with call count and I tried to do a logistic growth model for it. Dataframe has ds column; 30min datetime bins and y column; call count for each bin
Here's the prediction code
dataframe['cap']=10000
dataframe['floor']=0
m = Prophet(growth='logistic')
m.fit(dataframe)
future = m.make_future_dataframe(periods=periods, freq='H')
future['cap']=10000
future['floor']=0
forecast = m.predict(future)
fig1 = m.plot(forecast, xlabel='Date-time DD-MM-YY:HH-MM-SS', ylabel='Call Count')
plt.title('Forecast Prediction')
plt.show()
and graph
Even after that the detected pattern graph and forecast both goes below zero. Why is this happening and What can I do?
Generally speaking, a common technique to handle negative values in prediction models is the logarithmic trasformation.
To transform your target variable , you can use Y=log(x + c)
where c
is the constant.
People usually choose something like Y=log(x+1)
or any other "very small" positive number.
After this transformation, it's impossible to get negative values from forecasting.
To come back to original scale just use the inverse function of y=log(x+1)
, that is y = exp(x)-1