Skip to content

BUG: ExponentialSmoothing AICC Divide By Zero Error - #4825

Closed
andrewcking wants to merge 1 commit into
statsmodels:masterfrom
andrewcking:master
Closed

andrewcking wants to merge 1 commit into
statsmodels:masterfrom
andrewcking:master

Conversation

@andrewcking

Copy link
Copy Markdown

ExponentialSmoothing can fail in some circumstances due to AICC having zero in the denominator when calculating. This simply catches a ZeroDivisionError when calculating AICC and sets AICC to np.inf in those cases. Custom build appears to be working (building and running yes but also giving good results) where it would simply fail before.

See #4796

@coveralls

coveralls commented Aug 2, 2018 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.03%) to 83.681% when pulling 9d0759c on andrewcking:master into 2c76850 on statsmodels:master.

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #4825 into master will decrease coverage by <.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4825      +/-   ##
==========================================
- Coverage   81.14%   81.13%   -0.01%     
==========================================
  Files         581      581              
  Lines       89901    89904       +3     
  Branches    10041    10041              
==========================================
+ Hits        72946    72947       +1     
- Misses      14675    14678       +3     
+ Partials     2280     2279       -1
Impacted Files Coverage Δ
statsmodels/tsa/holtwinters.py 94.57% <50%> (-0.51%) ⬇️
statsmodels/stats/descriptivestats.py 24.13% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c76850...9d0759c. Read the comment docs.

aicc = aic + (2 * (k + 2) * (k + 3)) / (self.nobs - k - 3)
try:
aicc = aic + (2 * (k + 2) * (k + 3)) / (self.nobs - k - 3)
except ZeroDivisionError:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to check that self.nobs - k - 3 > 0 since will get wrong result if self.nobs - k - 3 is negative.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I tried to edit holtwinter.py. Unfortunately, I can't change it... do you know how to fix it ?

@ChadFulton ChadFulton changed the title Fix ExponentialSmoothing AICC Divide By Zero Error BUG: ExponentialSmoothing AICC Divide By Zero Error Aug 7, 2018
bashtage added a commit to bashtage/statsmodels that referenced this pull request Aug 7, 2018
Add check that nobs-k-3>0 before calculating aicc, and return inf if not

closes statsmodels#4796
closes statsmodels#4825
closes statsmodels#4762
@josef-pkt josef-pkt closed this in 63112cc Aug 12, 2018
gaborfeher pushed a commit to gaborfeher/statsmodels that referenced this pull request Dec 23, 2018
Add check that nobs-k-3>0 before calculating aicc, and return inf if not

closes statsmodels#4796
closes statsmodels#4825
closes statsmodels#4762
@bashtage

Copy link
Copy Markdown
Member

This is fixed in master.

@lingyaw

lingyaw commented Mar 22, 2019 via email

Copy link
Copy Markdown

ikalyvas pushed a commit to 5GinFIRE/osm_autoscaler that referenced this pull request Aug 31, 2019
is fixed (statsmodels/statsmodels#4825)
Length of cpu_load_to_vdus list increased to 30 since load can now
exceed 1140 (corresponding to 20 vdus)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants