Search code examples
pythonrvisualizationwindows-subsystem-for-linuxfacebook-prophet

Save Neural Prophet output to a file in WSL


I am quite new to python, data analysis and all this stuff, so I apologize if my question is silly or trivial.

I have a time series of server CPU usage percentage. I would like to make a prediction of how the usage will evolve in the future to decide whether we should upgrade, or whether it is ok to stay at the current configuration. I have read a lot about this amazing library called Neural Prophet which should do the job.

So, I went ahead and installed WSL, Ubuntu, Python 3, pip, venv and Neural Prophet. I have copied the trivial example from the Neural Prophet homepage and added a simple line to plot the forecast

from neuralprophet import NeuralProphet
import pandas as pd

df = pd.read_csv('cpusample.csv')

m = NeuralProphet()

metrics = m.fit(df, freq="D")

forecast = m.predict(df)
m.plot(forecast)

I ran python3 forecast.py and the console output showed some info, but that's it. Now, is there a way to actually see the forecast plot and data? Can I export the results to a PNG, JPEG? Or at least save the values to a CSV, so I can visualize them somewhere else (like Excel, because I am a noob :D )?

P.S.: I heard there was a thing called R, but I have never used it. Would that help?


Solution

  • It is possible to save the plot using m.plot(forecast).savefig('1.png').

    The method plot returns an object of matplotlib.pyplot.figure, which has a method to save the data to a file.