Skip to content

Commit

Permalink
feat: add adfuller stationary test parameters to config
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarros authored and fabclmnt committed Oct 28, 2024
1 parent fc97cc6 commit 3642b01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/ydata_profiling/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Configuration for the package."""
from enum import Enum
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, List, Literal, Optional, Tuple, Union

import yaml
from pydantic.v1 import BaseModel, BaseSettings, Field, PrivateAttr
Expand Down Expand Up @@ -112,6 +112,8 @@ class TimeseriesVars(BaseModel):
lags: List[int] = [1, 7, 12, 24, 30]
significance: float = 0.05
pacf_acf_lag: int = 100
autolag: Optional[Literal["AIC", "BIC", "t-stat"]] = "AIC"
maxlag: Optional[int] = None


class Univariate(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@


def stationarity_test(config: Settings, series: pd.Series) -> Tuple[bool, float]:
significance_threshold = config.vars.timeseries.significance

# make sure the data has no missing values
adfuller_test = adfuller(series.dropna())
adfuller_test = adfuller(
series.dropna(),
autolag=config.vars.timeseries.autolag,
maxlag=config.vars.timeseries.maxlag
)
p_value = adfuller_test[1]

significance_threshold = config.vars.timeseries.significance
return p_value < significance_threshold, p_value


Expand Down

0 comments on commit 3642b01

Please sign in to comment.