Skip to content

Commit

Permalink
Fix automl-2.0 imports (#1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Geekman authored Jun 19, 2023
1 parent 4b1e8f4 commit ec40caf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ pip install etna

The default version doesn't contain all the dependencies, because some of them are needed only for specific models, e.g. Prophet, PyTorch.
Available user extensions are the following:
* `prophet`
* `torch`
* `wandb`
* `prophet`: adds prophet model`,
* `torch`: adds models based on neural nets,
* `wandb`: adds wandb logger,
* `auto`: adds AutoML functionality,
* `classiciation`: adds time series classification functionality.

Install extension:
```bash
Expand Down
18 changes: 12 additions & 6 deletions etna/models/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
from optuna.distributions import CategoricalDistribution
from optuna.distributions import LogUniformDistribution
from optuna.distributions import UniformDistribution
else:
from unittest.mock import Mock

CategoricalDistribution = Mock # type: ignore
UniformDistribution = Mock # type: ignore
LogUniformDistribution = Mock # type: ignore

LINEAR_GRID: Dict[str, "BaseDistribution"] = {

_LINEAR_GRID: Dict[str, "BaseDistribution"] = {
"fit_intercept": CategoricalDistribution([False, True]),
}

ELASTIC_GRID: Dict[str, "BaseDistribution"] = {
_ELASTIC_GRID: Dict[str, "BaseDistribution"] = {
"fit_intercept": CategoricalDistribution([False, True]),
"l1_ratio": UniformDistribution(0, 1),
"alpha": LogUniformDistribution(low=1e-5, high=1e3),
Expand Down Expand Up @@ -92,7 +98,7 @@ def params_to_tune(self) -> Dict[str, "BaseDistribution"]:
:
Grid to tune.
"""
return LINEAR_GRID
return _LINEAR_GRID


class ElasticPerSegmentModel(
Expand Down Expand Up @@ -155,7 +161,7 @@ def params_to_tune(self) -> Dict[str, "BaseDistribution"]:
:
Grid to tune.
"""
return ELASTIC_GRID
return _ELASTIC_GRID


class LinearMultiSegmentModel(
Expand Down Expand Up @@ -195,7 +201,7 @@ def params_to_tune(self) -> Dict[str, "BaseDistribution"]:
:
Grid to tune.
"""
return LINEAR_GRID
return _LINEAR_GRID


class ElasticMultiSegmentModel(
Expand Down Expand Up @@ -258,4 +264,4 @@ def params_to_tune(self) -> Dict[str, "BaseDistribution"]:
:
Grid to tune.
"""
return ELASTIC_GRID
return _ELASTIC_GRID
11 changes: 11 additions & 0 deletions examples/automl.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@
"HORIZON = 14"
]
},
{
"cell_type": "markdown",
"id": "e5c2c568",
"metadata": {},
"source": [
"Many features from this notebook require `auto` extension. You can install it by the command:\n",
"```bash\n",
"pip install etna[auto]\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "33ad7417",
Expand Down

0 comments on commit ec40caf

Please sign in to comment.