Skip to content

Commit

Permalink
Merge pull request #79 from VIDA-NYU/update_py311
Browse files Browse the repository at this point in the history
Update py311
  • Loading branch information
EdenWuyifan authored Nov 10, 2023
2 parents f8db1c5 + e38ee9d commit e65da04
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
python-version: ["3.8", "3.11"]

steps:
- uses: actions/checkout@v3
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM python:3.10.11 AS alpha-automl-jupyterhub
FROM python:3.11.6 AS alpha-automl-jupyterhub

# Install JupyterHub and dependencies
RUN pip3 --disable-pip-version-check install --no-cache-dir \
jupyterhub==3.1.1 \
notebook==6.5.2 \
jupyterlab==3.5.3 \
jupyterlab-server==2.16.0
jupyterhub==4.0.2 \
notebook==7.0.6 \
jupyterlab==4.0.8 \
jupyterlab-server==2.25.0

# Install AlphaD3M and dependencies
ADD . /alpha-automl/
Expand Down
16 changes: 8 additions & 8 deletions alpha_automl/builtin_primitives/time_series_forecasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self):
"sin_day",
"cos_day",
"dayofmonth",
"weekofyear",
# weekofyear",
]
self.freq = "d"
self.prediction_length = 1
Expand Down Expand Up @@ -156,7 +156,7 @@ def create_time_features(self, df, date_col=None):
df["sin_day"] = np.sin(df["dayofyear"])
df["cos_day"] = np.cos(df["dayofyear"])
df["dayofmonth"] = df["date"].dt.day
df["weekofyear"] = df["date"].dt.weekofyear
# df["weekofyear"] = df["date"].dt.weekofyear # Not available after pandas 1.6
df = df.drop(["date"], axis=1)
return df

Expand All @@ -170,16 +170,16 @@ def standard_scaling(self, df):

# NBEATS
class NBEATSEstimator(BasePrimitive):
def __init__(self, freq="d", max_epochs=10):
def __init__(self, freq="d", max_steps=10):
self.freq = freq
self.max_epochs = max_epochs
self.max_steps = max_steps

def fit(self, X, y):
horizon = len(y)
date_column = X.columns[0]
X[date_column] = X[date_column].apply(lambda x: pd.Timestamp(x))
nbeats = [
NBEATS(input_size=horizon // 2, h=horizon, max_epochs=self.max_epochs)
NBEATS(input_size=horizon // 2, h=horizon, max_steps=self.max_steps)
]
self.nbeats_nf = NeuralForecast(models=nbeats, freq=self.freq)

Expand All @@ -195,15 +195,15 @@ def predict(self, X):

# NHITS
class NHITSEstimator(BasePrimitive):
def __init__(self, freq="d", max_epochs=10):
def __init__(self, freq="d", max_steps=10):
self.freq = freq
self.max_epochs = max_epochs
self.max_steps = max_steps

def fit(self, X, y):
horizon = len(y)
date_column = X.columns[0]
X[date_column] = X[date_column].apply(lambda x: pd.Timestamp(x))
nhits = [NHITS(input_size=horizon // 2, h=horizon, max_epochs=self.max_epochs)]
nhits = [NHITS(input_size=horizon // 2, h=horizon, max_steps=self.max_steps)]
self.nhits_nf = NeuralForecast(models=nhits, freq=self.freq)

tmp_X = X.copy()
Expand Down
10 changes: 5 additions & 5 deletions extra_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pandas<2.0.0: timeseries
gluonts==0.12.7: timeseries
pandas: timeseries
gluonts: timeseries
numpy==1.23.5: timeseries
neuralforecast==1.5.0: timeseries
mxnet==1.9.1: timeseries
pmdarima==2.0.3: timeseries
neuralforecast: timeseries
mxnet: timeseries
pmdarima: timeseries
fasttext-wheel: nlp
transformers: nlp, image
scikit-image: image
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scipy<=1.9.3
scipy
scikit-learn
torch>=1.7
nltk
Expand All @@ -8,4 +8,4 @@ datamart_profiler
feature_engine
xgboost
lightgbm
numpy<=1.24.3
numpy
20 changes: 11 additions & 9 deletions tests/test_datetime_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@

class TestDatetimeEncoder:
"""This is the testcases for datetime encoder."""

df = pd.DataFrame(
data={
"col1": ["12/1/2009 23:19", "2022-06-30 18:37:00", "2025-09-24 20:37:00"]
},
index=[0, 1, 2],
)
df = None

def setup_method(self, method):
print("starting execution of tc: {}".format(method.__name__))
self.df = pd.DataFrame(
data={
"col1": ["12/1/2009 23:19", "2022-06-30 18:37:00", "2025-09-24 20:37:00"]
},
index=[0, 1, 2],
)

def test_cyclical_feature(self):
encoder = CyclicalFeature()
Expand All @@ -27,5 +30,4 @@ def test_dummy_encoder(self):
encoder = DummyEncoder()
encoder.fit(self.df)
np_array = encoder.transform(self.df)
print(np_array)
assert np_array.shape == (len(self.df), 4 * len(self.df) + 4)
assert np_array.shape == (len(self.df), 4 * len(self.df))

0 comments on commit e65da04

Please sign in to comment.