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

[Minor] Structure component configurations to be more consistent #1645

Merged
merged 33 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e3c625c
remove double features map
ourownstory Sep 3, 2024
1a6fab6
remove empty features map init
ourownstory Sep 3, 2024
831a72f
add n_forecasts to config_model
ourownstory Sep 3, 2024
58d8abf
rename n_forecasts in forecaster to config_model.n_forecasts and remo…
ourownstory Sep 3, 2024
3c236bb
remove features_map, add pass of config_ar to TimeDataset
ourownstory Sep 3, 2024
e3e997a
remove features_map, add pass of config_ar to TimeDataset
ourownstory Sep 3, 2024
dfd8819
reset predict_component stacker after seaonal predict
ourownstory Sep 3, 2024
0259cfb
keep self.n_forecasts for now
ourownstory Sep 3, 2024
8108ebb
fixes
ourownstory Sep 3, 2024
f524892
remove unused TimeDataset args
ourownstory Sep 3, 2024
f5a836f
fix predict_steps
ourownstory Sep 3, 2024
1f463a4
fix predict_steps
ourownstory Sep 3, 2024
aadae53
fixes
ourownstory Sep 3, 2024
7258339
fix seasonal_componetns
ourownstory Sep 3, 2024
a5acc13
rename autoregression
ourownstory Sep 3, 2024
08b34ea
fix n_forecasts references
ourownstory Sep 4, 2024
af1806f
ruff
ourownstory Sep 4, 2024
52d61eb
replace model_config.n_forecasts with config_model.n_forecasts
ourownstory Sep 4, 2024
803bf3c
move component configs to new file
ourownstory Sep 4, 2024
5ddd299
separation of config_components
ourownstory Sep 4, 2024
7a0d300
fix imports
ourownstory Sep 4, 2024
ab24a85
fix comp imports
ourownstory Sep 4, 2024
d8c48db
fix config imports
ourownstory Sep 4, 2024
5c6541e
fix
ourownstory Sep 4, 2024
dca0cc8
fix typos
ourownstory Sep 4, 2024
6d6d0c8
fix lagged_reg
ourownstory Sep 4, 2024
fbabf44
fox
ourownstory Sep 4, 2024
5a3c13b
fix reg
ourownstory Sep 4, 2024
c7006b0
fut
ourownstory Sep 4, 2024
e3cf8f6
standardize regressors
ourownstory Sep 4, 2024
95f9542
create add functions for regressors
ourownstory Sep 4, 2024
76521e2
d
ourownstory Sep 4, 2024
fcbdd9c
remove unused import
ourownstory Sep 4, 2024
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: 2 additions & 0 deletions docs/source/code/forecaster.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Core Module Documentation
:maxdepth: 1

configure.py <configure>
configure_components.py <configure_components>
df_utils.py <df_utils>
event_utils.py <event_utils>
plot_forecast_plotly.py <plot_forecast_plotly>
Expand All @@ -14,6 +15,7 @@ Core Module Documentation
plot_model_parameters_matplotlib.py <plot_model_parameters_matplotlib>
time_dataset.py <time_dataset>
time_net.py <time_net>
utils_time_dataset.py <utils_time_dataset>
utils.py <utils>

.. automodule:: neuralprophet.forecaster
Expand Down
2 changes: 2 additions & 0 deletions docs/source/code/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Code Documentation

forecaster.py (NeuralProphet) <forecaster>
configure.py <configure>
configure_components.py <configure_components>
time_dataset.py <time_dataset>
time_net.py <time_net>
torch_prophet.py <torch_prophet>
Expand All @@ -23,6 +24,7 @@ Code Documentation
plot_model_parameters_plotly.py <plot_model_parameters_plotly>
plot_model_parameters_matplotlib.py <plot_model_parameters_matplotlib>
utils.py <utils>
utils_time_dataset.py <utils_time_dataset>
df_utils.py <df_utils>
hdays_utils.py <hdays_utils>
plot_utils.py <plot_utils>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"source": [
"if \"google.colab\" in str(get_ipython()):\n",
" # uninstall preinstalled packages from Colab to avoid conflicts\n",
" !pip uninstall -y torch notebook notebook_shim tensorflow tensorflow-datasets prophet torchaudio torchdata torchtext torchvision \n",
" !pip uninstall -y torch notebook notebook_shim tensorflow tensorflow-datasets prophet torchaudio torchdata torchtext torchvision\n",
" !pip install git+https://github.com/ourownstory/neural_prophet.git # may take a while\n",
" #!pip install neuralprophet # much faster, but may not have the latest upgrades/bugfixes\n",
"\n",
Expand Down Expand Up @@ -787,7 +787,7 @@
"outputs": [],
"source": [
"df = pd.read_csv(data_location + \"air_passengers.csv\")\n",
"future = m.make_future_dataframe(df, periods=3) # periods=m.n_forecasts, n_historic_predictions=False"
"future = m.make_future_dataframe(df, periods=3) # periods=m.config_model.n_forecasts, n_historic_predictions=False"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,62 +344,6 @@
"df_local = df_local[[\"ds\", \"y\"]]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# import neuralprophet.configure as configure"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# from dataclasses import dataclass, field\n",
"# from typing import Callable, List, Optional\n",
"# from typing import OrderedDict as OrderedDictType\n",
"# from typing import Type, Union\n",
"# from collections import OrderedDict\n",
"\n",
"# @dataclass\n",
"# class Regressor:\n",
"# reg_lambda: Optional[float]\n",
"# normalize: str\n",
"# mode: str\n",
"\n",
"# @dataclass\n",
"# class ConfigFutureRegressors:\n",
"# model: str\n",
"# regressors: OrderedDict = field(init=False) # contains SeasonConfig objects\n",
"\n",
"# def __post_init__(self):\n",
"# self.regressors = OrderedDictType[str, Regressor]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ConfigFutureRegressors(\n",
"# model='linear',\n",
"# ) # Opti"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# m.config_regressors"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/自回归.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ m = NeuralProphet(
weekly_seasonality=False,
daily_seasonality=False
)
m.highlight_nth_step_ahead_of_each_forecast(step_number=m.n_forecasts)
m.highlight_nth_step_ahead_of_each_forecast(step_number=m.config_model.n_forecasts)
```

您可以指定任何小于或等于`n_forecasts`的值到`step_number`参数。一旦你这样做,指标将看起来像下面。
Expand Down
6 changes: 3 additions & 3 deletions neuralprophet/components/future_regressors/neural_nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def __init__(self, config, id_list, quantiles, n_forecasts, device, config_trend
if self.regressors_dims is not None:
# Regresors params
self.regressor_nets = nn.ModuleDict({})
self.regressors_layers = config.regressors_layers
self.layers = config.layers
# one net per regressor. to be adapted to combined network
for regressor in self.regressors_dims.keys():
# Nets for both additive and multiplicative regressors
regressor_net = nn.ModuleList()
# This will be later 1 + static covariates
d_inputs = 1
for d_hidden_i in self.regressors_layers:
for d_hidden_i in self.layers:
regressor_net.append(nn.Linear(d_inputs, d_hidden_i, bias=True))
d_inputs = d_hidden_i
# final layer has input size d_inputs and output size equal to no. of quantiles
Expand Down Expand Up @@ -77,7 +77,7 @@ def regressor(self, regressor_input, name):
Forecast component of dims (batch, n_forecasts, num_quantiles)
"""
x = regressor_input
for i in range(len(self.regressors_layers) + 1):
for i in range(len(self.layers) + 1):
if i > 0:
x = nn.functional.relu(x)
x = self.regressor_nets[name][i](x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def __init__(self, config, id_list, quantiles, n_forecasts, device, config_trend
if self.regressors_dims is not None:
# Regresors params
self.regressor_nets = nn.ModuleDict({})
self.regressors_layers = config.regressors_layers
self.layers = config.layers
# Combined network
for net_i, size_i in Counter([x["mode"] for x in self.regressors_dims.values()]).items():
# Nets for both additive and multiplicative regressors
regressor_net = nn.ModuleList()
# This will be later size_i(1 + static covariates)
d_inputs = size_i
for d_hidden_i in self.regressors_layers:
for d_hidden_i in self.layers:
regressor_net.append(nn.Linear(d_inputs, d_hidden_i, bias=True))
d_inputs = d_hidden_i
# final layer has input size d_inputs and output size equal to no. of quantiles
Expand Down Expand Up @@ -79,7 +79,7 @@ def regressors(self, regressor_inputs, mode):
Forecast component of dims (batch, n_forecasts, num_quantiles)
"""
x = regressor_inputs
for i in range(len(self.regressors_layers) + 1):
for i in range(len(self.layers) + 1):
if i > 0:
x = nn.functional.relu(x)
x = self.regressor_nets[mode][i](x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def __init__(self, config, id_list, quantiles, n_forecasts, device, config_trend
if self.regressors_dims is not None:
# Regresors params
self.regressor_nets = nn.ModuleDict({})
self.regressors_layers = config.regressors_layers
self.layers = config.layers
# Combined network
for net_i, size_i in Counter([x["mode"] for x in self.regressors_dims.values()]).items():
# Nets for both additive and multiplicative regressors
regressor_net = nn.ModuleList()
# This will be later size_i(1 + static covariates)
d_inputs = size_i
for d_hidden_i in self.regressors_layers:
for d_hidden_i in self.layers:
regressor_net.append(nn.Linear(d_inputs, d_hidden_i, bias=True))
d_inputs = d_hidden_i
# final layer has input size d_inputs and output size equal to no. of quantiles
Expand Down Expand Up @@ -80,7 +80,7 @@ def regressors(self, regressor_inputs, mode):
Forecast component of dims (batch, n_forecasts, num_quantiles)
"""
x = regressor_inputs
for i in range(len(self.regressors_layers) + 1):
for i in range(len(self.layers) + 1):
if i > 0:
x = nn.functional.relu(x)
x = self.regressor_nets[mode][i](x)
Expand Down
2 changes: 1 addition & 1 deletion neuralprophet/components/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_trend(config, n_forecasts, quantiles, id_list, num_trends_modelled, devi

Parameters
----------
config : configure.Trend
config : configure_components.Trend
n_forecasts : int
number of steps to forecast. Aka number of model outputs
quantiles : list
Expand Down
Loading
Loading