Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogluon timeseries #7

Merged
merged 2 commits into from
Oct 18, 2022
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
25 changes: 14 additions & 11 deletions frameworks/GluonTS/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
from gluonts.mx.trainer.callback import Callback
from gluonts.evaluation import make_evaluation_predictions

from gluonts.model.deepar import DeepAREstimator
from gluonts.model.prophet import ProphetPredictor
from gluonts.model.n_beats import NBEATSEstimator

from gluonts.model.npts import NPTSEstimator
from gluonts.model.prophet import ProphetPredictor
from gluonts.model.seasonal_naive import SeasonalNaivePredictor
from gluonts.model.r_forecast import RForecastPredictor

from gluonts.model.deepar import DeepAREstimator
from gluonts.model.n_beats import NBEATSEstimator
from gluonts.model.seq2seq import MQCNNEstimator, MQRNNEstimator
from gluonts.model.simple_feedforward import SimpleFeedForwardEstimator
from gluonts.model.tft import TemporalFusionTransformerEstimator


from frameworks.shared.callee import call_run, result, output_subdir
from frameworks.shared.utils import Timer, zip_path

Expand Down Expand Up @@ -144,17 +147,17 @@ def estimate_predictor(model, prediction_length, freq, dataset_train_gluonts, ti
estimator = TemporalFusionTransformerEstimator(prediction_length=prediction_length, freq=freq, trainer=Trainer(callbacks = [TimeLimitCallback(time_limit)]))
predictor = estimator.train(dataset_train_gluonts)

#elif model == "ARIMA":
# predictor = RForecastPredictor(prediction_length=prediction_length, freq=freq, method_name="arima")
elif model == "ARIMA":
predictor = RForecastPredictor(prediction_length=prediction_length, freq=freq, method_name="arima")

#elif model == "ETS":
# predictor = RForecastPredictor(prediction_length=prediction_length, freq=freq, method_name="ets")
elif model == "ETS":
predictor = RForecastPredictor(prediction_length=prediction_length, freq=freq, method_name="ets")

#elif model == "STL-AR":
# predictor = RForecastPredictor(prediction_length=prediction_length, freq=freq, method_name="stlar")
elif model == "STL-AR":
predictor = RForecastPredictor(prediction_length=prediction_length, freq=freq, method_name="stlar")

#elif model == "Theta":
# predictor = RForecastPredictor(prediction_length=prediction_length, freq=freq, method_name="thetaf")
elif model == "Theta":
predictor = RForecastPredictor(prediction_length=prediction_length, freq=freq, method_name="thetaf")

else:
msg = f"Not implemented model {model}."
Expand Down
74 changes: 69 additions & 5 deletions frameworks/GluonTS/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,87 @@ if [[ "$VERSION" == "latest" ]]; then
VERSION="dev"
fi

OS_NAME=$(cat /etc/os-release | grep '^NAME' | cut -d '"' -f 2)
OS_VERSION=$(cat /etc/os-release | grep '^VERSION_ID' | cut -d '"' -f 2)
OS="${OS_NAME} ${OS_VERSION}"
OS_SUPPORTED="Amazon Linux 2,Ubuntu 18.04,Ubuntu 20.04"

if echo "${OS_SUPPORTED}" | tr "," "\n" | grep -F -x -q "${OS}"; then
echo "INFO: Operating system ${OS} is supported."
else
echo "ERROR: Operating system ${OS} is not supported."
exit 1
fi

# creating local venv
. ${HERE}/../shared/setup.sh ${HERE} true

PIP install --upgrade pip
PIP install --upgrade setuptools wheel

if [[ "${OS}" == "Amazon Linux 2" ]]; then
# TOPIC: update system
echo "updating system..."
SUDO yum clean all
SUDO rm -rf /var/cache/yum
SUDO yum -y update

# TOPIC: install readline-devel (for rpy2)
echo "installing readline-devel..."
SUDO yum install -y readline readline-devel
# ---------------------

# TOPIC: install R
echo "installing R..."
SUDO yum install -y gcc make sqlite-devel zlib-devel libffi-devel openssl-devel bzip2-devel wget tar gzip
SUDO yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
SUDO yum install -y R
# R version=3.6.0
SUDO yum -y install libcurl-devel
SUDO R -e 'install.packages(c("forecast"), repos="https://cloud.r-project.org")'

elif [[ "${OS}" == "Ubuntu 18.04" || "${OS}" == "Ubuntu 20.04" ]]; then
# TOPIC: update system
echo "updating system..."
DEBIAN_FRONTEND=noninteractive
SUDO apt-get update -y
SUDO apt-get upgrade -y
SUDO apt-get install -y apt-utils make cmake build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev \
libffi-dev liblzma-dev libcurl4-openssl-dev p7zip-full awscli python3-dev
# ------------------

# TOPIC: install R
echo "installing R..."
# forecast requires R 3.6 (Which is not available for Ubuntu 18.04 by default.)
if [[ "${OS}" == "Ubuntu 18.04" ]]; then
SUDO apt install -y software-properties-common
SUDO apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
SUDO add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
SUDO apt-get -y update
fi
apt install -y r-base
SUDO R -e 'install.packages(c("forecast", "nnfor"), repos="https://cloud.r-project.org")'
# ---------------------
fi

# TOPIC: installing Prophet
echo "installing Prophet..."
PIP install "prophet"
# -------------------------

# TOPIC: installing orjson
echo "installing orjson..."
PIP install "orjson"
# -------------------------

#PIP install 'pystan~=2.19'
#PIP install 'mxnet<2.0'

if [[ "$VERSION" == "stable" ]]; then
PIP install --no-cache-dir -U "${PKG}[mxnet,pro,Prophet]"
PIP install --no-cache-dir -U "${PKG}[mxnet,pro,Prophet,R]"
elif [[ "$VERSION" =~ ^[0-9] ]]; then
PIP install --no-cache-dir -U "${PKG}[mxnet,pro,Prophet]==${VERSION}"
PIP install --no-cache-dir -U "${PKG}[mxnet,pro,Prophet,R]==${VERSION}"
else
TARGET_DIR="${HERE}/lib/${PKG}"
rm -Rf ${TARGET_DIR}
Expand All @@ -31,9 +97,7 @@ else
PY_EXEC_NO_ARGS="$(cut -d' ' -f1 <<<"$py_exec")"
PY_EXEC_DIR=$(dirname "$PY_EXEC_NO_ARGS")
env PATH="$PY_EXEC_DIR:$PATH"
PIP install -e ".[mxnet,pro,Prophet]"
PIP install -e ".[mxnet,pro,Prophet,R]"
fi


PY -c "from gluonts import __version__; print(__version__)" >> "${HERE}/.setup/installed"
PIP install "mxnet<2.0"
30 changes: 29 additions & 1 deletion resources/frameworks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ AutoGluonTS:
MODULE: timeseries

GluonTS:
version: "stable"
version: "0.10.0"
description: |
GluonTS
project: https://ts.gluon.ai
Expand Down Expand Up @@ -282,6 +282,34 @@ GluonTS_TFT:
params:
model: TFT

GluonTS_ARIMA:
extends: GluonTS
description: |
GluonTS, ARIMA.
params:
model: ARIMA

GluonTS_ETS:
extends: GluonTS
description: |
GluonTS, ETS.
params:
model: ETS

GluonTS_STL-AR:
extends: GluonTS
description: |
GluonTS, STL-AR.
params:
model: STL-AR

GluonTS_Theta:
extends: GluonTS
description: |
GluonTS, Theta.
params:
model: Theta

#######################################
### Non AutoML reference frameworks ###
#######################################
Expand Down