intel-analytics / analytics-zoo

Distributed Tensorflow, Keras and PyTorch on Apache Spark/Flink & Ray
https://analytics-zoo.readthedocs.io/
Apache License 2.0
16 stars 3 forks source link

Auto search for AutoTS built-in models API design #307

Closed shanyu-sys closed 3 years ago

shanyu-sys commented 3 years ago

One implementation might be User

from zoo.zouwu.autots import AutoLSTM, AutoSeq2Seq, AutoTCN,...
from zoo.orca.automl import hp
auto_lstm = AutoLSTM(name="auto_lstm", logs_dir="/tmp/auto_lstm", loss="mse")
auto_lstm.set_search_space(lstm_units=hp.choice([32, 64]), 
                           dropout=hp.uniform(0.2, 0.5),
                           lr=hp.choice([0,01, 0.001]),
                           batch_size=hp.grid_search([32, 64, 128]),
                           look_back=hp.qrandint([7, 14]),
                           optimizer=hp.choice(["sgd", "adam"]))
auto_lstm.fit(data, num_rand_samples=4, ...)
auto_lstm.predict(data)
auto_lstm.evaluate(data, metrics=["mse"])
auto_lstm.show_models()
auto_lstm.get_best_model()

Implementation could be


from zoo.orca.automl import AutoEstimator
class AutoLSTM:
    def __init__(self, name="auto_lstm", logs_dir="/tmp/auto_lstm", loss="mse"):
        self.auto_est = AutoEstimator.from_torch(model_creator=lstm_model_creator, loss=loss)

    def set_search_space(self,
                         lstm_units=32,
                         dropout=0.2,
                         lr=0.001,
                         batch_size=32,
                         look_back=7,
                         optimizer="adam",)
         self.search_space = dict()

    def fit(data, ...):
        self.auto_est.fit(data=data, search_space=self.search_space, ...)
shane-huang commented 3 years ago

Maybe users can have a simpler way to use autots?

  1. The simples way
    
    from zoo.zouwu.autots import AutoTimeSeries

m = AutoTimeSeries() m.fit(data) m.predict(data) m.evaluate(data, metric=...)

2. Advanced usage: choose the preference of models
```python
from zoo.zouwu.autots import AutoTimeSeries

m = AutoTimeSeries(model='tcn')
m.fit(data)
...

maybe allow choosing from several models?

from zoo.zouwu.autots import AutoTimeSeries

m = AutoTimeSeries(model=['seq2seq','tcn'])
m.fit(data)
...
  1. Advaced usage: configure the search space
    m = AutoTimeSeries(model='lstm', search_space=...)
    m.fit(data)
    ...
shane-huang commented 3 years ago

IMHO, the relationship between zoo automl AutoEstimator and Zouwu AutoTS could be something like below.

Zouwu AutoTS uses automl AutoEstimator as the underlying component. And autots implements user-defined functions for tuning and provides more convinient facilites for time series for end-user.

Bascially, zoo.orca.automl.AutoEstimator accepts a set of user-defined "creators", i.e. "model_creator", "optimizer_creator", "feature_transformer_creator" (or data creator?), each of which accepts some hyper parameters that can be tuned by the HPO engine.

zouwu.autots provides several built-in "creators". We have simple creators that tunes a single model, but also have advanced creators that supports multiple model selection. And we have creators for various kinds of feature transformation and/or preprocessing. The end-user interfaces wraps different sets of creators to achieve different purposes.

Later we can turn the creator functions into pipeline stages.

shane-huang commented 3 years ago

We have merged most of the implementations, so close this issue.