GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • All gists
  • Back to GitHub
  • Sign in
  • Sign up
  • Code
  • Revisions 2
  • Stars 17
  • Forks 3
  • Terms
  • Privacy
  • Security
  • Status
  • Community
  • Docs

This view

  • Original page
  • New address

GeezerVison is showing gist.github.com — TimeSeries Decomposition in Python with statsmodels and Pandas

Instantly share code, notes, and snippets.

@balzer82

balzer82/TimeSeries-Decomposition.ipynb

Last active June 20, 2022 14:38
Show Gist options
  • Download ZIP
  • Star 17 (17) You must be signed in to star a gist
  • Fork 3 (3) You must be signed in to fork a gist
  • Clone this repository at <script src="https://gist.github.com/balzer82/5cec6ad7adc1b550e7ee.js"></script>
  • Save balzer82/5cec6ad7adc1b550e7ee to your computer and use it in GitHub Desktop.
Clone this repository at <script src="https://gist.github.com/balzer82/5cec6ad7adc1b550e7ee.js"></script>
Save balzer82/5cec6ad7adc1b550e7ee to your computer and use it in GitHub Desktop.
Download ZIP
TimeSeries Decomposition in Python with statsmodels and Pandas
Display the source blob
Display the rendered blob
Raw
TimeSeries-Decomposition.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Cyberguille

Cyberguille commented Apr 19, 2018

Copy link
Copy Markdown

I follow the steps that you follow and I got
image

In my case I have a huge amount of data so is difficult review this data
What do you suggest me?
How can I create more big graph?
Is there a procedure for big time series??

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lotusirous

lotusirous commented Apr 24, 2018

Copy link
Copy Markdown

@Cyberguille.

res = sm.tsa.seasonal_decompose(centrumGalerie.Belegung.interpolate(),
                                freq=decompfreq,
                                model='additive')

You can plot a bigger graph by plotting each graph separately. For example,

import matplotlib.pyplot as plt 

fig, (ax1,ax2,ax3) = plt.subplots(3,1, figsize=(15,8))
res.trend.plot(ax=ax1)
res.resid.plot(ax=ax2)
res.seasonal.plot(ax=ax3)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@IanQS

IanQS commented Nov 22, 2018

Copy link
Copy Markdown

Knowing the trend, seasonality and residuals, what do we do with them?

We want a trend that is fairly stable (like a straight line) before we do ARMA or ARIMA on the data, correct? We would do things like difference or log difference to address this issue?

What would we like from seasonal? Would we like it to be flat as well? How do we interpret the sinusoidal shape? And what cn we do to address seasonality?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mekomlusa

mekomlusa commented Mar 15, 2019

Copy link
Copy Markdown

@IanQS That's what I'm trying to figure out as well. I got the nice plots from seasonal_decompose, now have no idea how to proceed...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fclesio

fclesio commented Oct 10, 2019

Copy link
Copy Markdown

@Cyberguille

Just use that before the plot and you will be fine:

pylab.rcParams['figure.figsize'] = (14, 9)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XiaoLaoDi

XiaoLaoDi commented Jan 20, 2020

Copy link
Copy Markdown

when we get the decomposition components, how to predict the future steps?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DavidD32-svg

DavidD32-svg commented May 3, 2020

Copy link
Copy Markdown

Thanks for your comments,

I also want to know how can i use this data in ARIMA or FOURIER.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jcarless

jcarless commented Oct 5, 2020

Copy link
Copy Markdown

@Cyberguille

Just use that before the plot and you will be fine:

pylab.rcParams['figure.figsize'] = (14, 9)

Worked for me, thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pratikask

pratikask commented Feb 1, 2021

Copy link
Copy Markdown

Hi..am trying to use your method in my project and am using many issues. Can anyone help me decompose my time series??

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Ibitayoabiodun

Ibitayoabiodun commented Jan 10, 2022

Copy link
Copy Markdown

Just use that before the plot and you will be fine:

pylab.rcParams['figure.figsize'] = (14, 9)

Works perfectly!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@simonyelisey

simonyelisey commented Jun 20, 2022

Copy link
Copy Markdown

@pratikask if you still need a help I can help you

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.