ITMO-NSS-team / fedot-examples

The repository contains examples for the AutoML framework FEDOT
https://github.com/nccr-itmo/FEDOT
47 stars 14 forks source link

Composer on MulModal data #5

Closed rnjv closed 2 years ago

rnjv commented 2 years ago

Hi,

I tried the composer on MultiModalData and it failed, any other options I will be able to use?

nicl-nno commented 2 years ago

Hi!

Please provide the example of your code and data to reproduce this error.

rnjv commented 2 years ago

Hi!

Similar to the examples, with some modifications:

# Specify forecast length
len_forecast = 8
task = Task(TaskTypesEnum.ts_forecasting,
            TsForecastingParams(forecast_length=len_forecast))

# Got train, test parts, and the entire data
true_values = np.array(df['value'])
train_array = true_values[:-len_forecast]
test_array = true_values[-len_forecast:]

# Data for lagged transformation
train_lagged = InputData(idx=np.arange(0, len(train_array)),
                         features=train_array,
                         target=train_array,
                         task=task,
                         data_type=DataTypesEnum.ts)
start_forecast = len(train_array)
end_forecast = start_forecast + len_forecast
predict_lagged = InputData(idx=np.arange(start_forecast, end_forecast),
                           features=train_array,
                           target=test_array,
                           task=task,
                           data_type=DataTypesEnum.ts)
exog_arr = np.array(df['mp'])
exog_train = exog_arr[:-len_forecast]
exog_test = exog_arr[-len_forecast:]

# Data for exog operation
train_exog = InputData(idx=np.arange(0, len(exog_train)),
                       features=exog_train,
                       target=train_array,
                       task=task,
                       data_type=DataTypesEnum.ts)
start_forecast = len(exog_train)
end_forecast = start_forecast + len_forecast
predict_exog = InputData(idx=np.arange(start_forecast, end_forecast),
                         features=exog_test,
                         target=test_array,
                         task=task,
                         data_type=DataTypesEnum.ts)
from fedot.core.data.multi_modal import MultiModalData

train_dataset = MultiModalData({
    'lagged': train_lagged,
    'exog_ts_data_source': train_exog
})

predict_dataset = MultiModalData({
    'lagged': predict_lagged,
    'exog_ts_data_source': predict_exog
})

# Composer parameters
timeout = datetime.timedelta(minutes=5)
composer_requirements = GPComposerRequirements(
    primary=primary_operations,
    secondary=secondary_operations, 
    max_arity=3,
    max_depth=8, 
    pop_size=10, 
    num_of_generations=20,
    crossover_prob=0.8,
    mutation_prob=0.8,
    timeout=timeout, 
    cv_folds=2)
nicl-nno commented 2 years ago

If you are using the composer directly, the initial_pipeline should be specified for the multi-modal data (see https://github.com/nccr-itmo/FEDOT/blob/master/cases/multi_modal_rating_prediction.py)

The other way is to use the FEDOT API (see https://github.com/nccr-itmo/FEDOT/blob/master/cases/industrial/multivariate_forecasting.py) instead of direct composer call.

rnjv commented 2 years ago

Thanks, these are helpful will check them out!