Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/databricks/automl_runtime/forecast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
}
}

QUATERLY_OFFSET_ALIAS = [
QUARTERLY_OFFSET_ALIAS = [
'Q', 'QS', 'BQ', 'BQS'
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, horizon: int, frequency_unit: str, metric: str, seasonal_peri
:param frequency_quantity: The number of frequency units in the frequency. Default is 1.
it is the starting point of cutoffs for cross validation.
For tuning job, it is the cutoff between train and validate split.
For training job, it is the cutoff bewteen validate and test split.
For training job, it is the cutoff between validate and test split.
"""
self._horizon = horizon
self._frequency_unit = OFFSET_ALIAS_MAP[frequency_unit]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __init__(self, horizon: int, frequency_unit: str, metric: str, interval_widt
:param split_cutoff: Optional cutoff specified by user. If provided,
it is the starting point of cutoffs for cross validation.
For tuning job, it is the cutoff between train and validate split.
For training job, it is the cutoff bewteen validate and test split.
For training job, it is the cutoff between validate and test split.
:param prophet_kwargs: Optional keyword arguments for Prophet model.
For information about the parameters see:
`The Prophet source code <https://github.com/facebook/prophet/blob/master/python/prophet/forecaster.py>`_.
Expand Down
4 changes: 2 additions & 2 deletions runtime/databricks/automl_runtime/forecast/prophet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from databricks.automl_runtime.forecast import OFFSET_ALIAS_MAP, DATE_OFFSET_KEYWORD_MAP
from databricks.automl_runtime.forecast.model import ForecastModel, mlflow_forecast_log_model
from databricks.automl_runtime import version
from databricks.automl_runtime.forecast.utils import is_quaterly_alias, make_future_dataframe, apply_preprocess_func
from databricks.automl_runtime.forecast.utils import is_quarterly_alias, make_future_dataframe, apply_preprocess_func


PROPHET_ADDITIONAL_PIP_DEPS = [
Expand Down Expand Up @@ -71,7 +71,7 @@ def __init__(self,
self._frequency_unit = frequency_unit
self._frequency_quantity = frequency_quantity
self._time_col = time_col
self._is_quaterly = is_quaterly_alias(frequency_unit)
self._is_quarterly = is_quarterly_alias(frequency_unit)
self._split_col = split_col
self._preprocess_func = preprocess_func
super().__init__()
Expand Down
12 changes: 6 additions & 6 deletions runtime/databricks/automl_runtime/forecast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import logging
from typing import Dict, List, Optional, Tuple, Union
from databricks.automl_runtime.forecast import DATE_OFFSET_KEYWORD_MAP,\
QUATERLY_OFFSET_ALIAS, NON_DAILY_OFFSET_ALIAS, OFFSET_ALIAS_MAP, PERIOD_ALIAS_MAP
QUARTERLY_OFFSET_ALIAS, NON_DAILY_OFFSET_ALIAS, OFFSET_ALIAS_MAP, PERIOD_ALIAS_MAP

import pandas as pd

Expand Down Expand Up @@ -155,7 +155,7 @@ def generate_cutoffs(df: pd.DataFrame, horizon: int, frequency_unit: str,
"""
period = max(0.5 * horizon, 1) # avoid empty cutoff buckets

# avoid non-integer months, quaters ands years.
# avoid non-integer months, quarters ands years.
if frequency_unit in NON_DAILY_OFFSET_ALIAS:
period = int(period)
period_dateoffset = pd.DateOffset(**DATE_OFFSET_KEYWORD_MAP[frequency_unit])*frequency_quantity*period
Expand Down Expand Up @@ -208,15 +208,15 @@ def generate_custom_cutoffs(df: pd.DataFrame, horizon: int, frequency_unit: str,
:param split_cutoff: the user-specified cutoff, as the starting point of cutoffs.
:param frequency_quantity: frequency quantity of the time series.
For tuning job, it is the cutoff between train and validate split.
For training job, it is the cutoff bewteen validate and test split.
For training job, it is the cutoff between validate and test split.
:return: list of pd.Timestamp cutoffs for cross-validation.
"""
# TODO: [ML-43528] expose period as input.
period = 1
period_dateoffset = pd.DateOffset(**DATE_OFFSET_KEYWORD_MAP[frequency_unit])*period*frequency_quantity
horizon_dateoffset = pd.DateOffset(**DATE_OFFSET_KEYWORD_MAP[frequency_unit])*horizon*frequency_quantity

# First cutoff is the cutoff bewteen splits
# First cutoff is the cutoff between splits
cutoff = split_cutoff
result = []
max_cutoff = max(df["ds"])
Expand All @@ -230,8 +230,8 @@ def generate_custom_cutoffs(df: pd.DataFrame, horizon: int, frequency_unit: str,
cutoff += period_dateoffset
return result

def is_quaterly_alias(freq: str):
return freq in QUATERLY_OFFSET_ALIAS
def is_quarterly_alias(freq: str):
return freq in QUARTERLY_OFFSET_ALIAS

def is_frequency_consistency(
start_time: pd.Timestamp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def preprocess_func(df):

def test_make_future_dataframe(self):
for feq_unit in OFFSET_ALIAS_MAP:
# Temporally disable the year, month and quater since we
# Temporally disable the year, month and quarter since we
# don't have full support yet.
if OFFSET_ALIAS_MAP[feq_unit] in ['YS', 'MS', 'QS']:
continue
Expand Down
8 changes: 4 additions & 4 deletions runtime/tests/automl_runtime/forecast/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_truncate(self):
validation_horizon = get_validation_horizon(df, 17, "YS")
self.assertEqual(validation_horizon, 2)

# for dataframe with 12 quaters of data, maximum horizon is 3 quaters.
# for dataframe with 12 quarters of data, maximum horizon is 3 quarters.
df = pd.DataFrame(pd.date_range(start="2012-01-14", periods=13, freq=pd.DateOffset(months=3)), columns=["ds"])
validation_horizon = get_validation_horizon(df, 17, "QS")
self.assertEqual(validation_horizon, 3)
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_generate_cutoffs_success_monthly(self):
cutoffs = generate_cutoffs(df, horizon=2, frequency_unit="MS", num_folds=3, seasonal_period=1)
self.assertEqual([pd.Timestamp('2021-08-12 00:00:00'), pd.Timestamp('2021-9-12 00:00:00'), pd.Timestamp('2021-10-12 00:00:00')], cutoffs)

def test_generate_cutoffs_success_quaterly(self):
def test_generate_cutoffs_success_quarterly(self):
df = pd.DataFrame(
pd.date_range(start="2020-07-12", periods=9, freq=pd.DateOffset(months=3)), columns=["ds"]
).rename_axis("y").reset_index()
Expand Down Expand Up @@ -277,14 +277,14 @@ def test_generate_custom_cutoffs_success_monthly(self):
cutoffs = generate_custom_cutoffs(df, horizon=7, frequency_unit="MS", split_cutoff=pd.Timestamp('2021-03-12 00:00:00'))
self.assertEqual([pd.Timestamp('2021-03-12 00:00:00'), pd.Timestamp('2021-04-12 00:00:00'), pd.Timestamp('2021-05-12 00:00:00')], cutoffs)

def test_generate_custom_cutoffs_success_quaterly(self):
def test_generate_custom_cutoffs_success_quarterly(self):
df = pd.DataFrame(
pd.date_range(start="2020-07-12", periods=9, freq=pd.DateOffset(months=3)), columns=["ds"]
).rename_axis("y").reset_index()
cutoffs = generate_custom_cutoffs(df, horizon=7, frequency_unit="QS", split_cutoff=pd.Timestamp('2020-07-12 00:00:00'))
self.assertEqual([pd.Timestamp('2020-07-12 00:00:00'), pd.Timestamp('2020-10-12 00:00:00')], cutoffs)

def test_generate_custom_cutoffs_success_quaterly_end(self):
def test_generate_custom_cutoffs_success_quarterly_end(self):
df = pd.DataFrame(
pd.date_range(start="2020-03-31", periods=3, freq=pd.DateOffset(months=3)), columns=["ds"]
).rename_axis("y").reset_index()
Expand Down
Loading