def run_ts_forecasting_example(with_plot=True, with_pipeline_vis=True, timeout=None): train_data_path = f'{fedot_project_root()}/examples/data/salaries.csv' target = pd.read_csv(train_data_path)['target'] # Define forecast length and define parameters - forecast length forecast_length = 30 task_parameters = TsForecastingParams(forecast_length=forecast_length) # init model for the time series forecasting model = Fedot(problem='ts_forecasting', task_params=task_parameters, timeout=timeout) # run AutoML model design in the same way pipeline = model.fit(features=train_data_path, target='target') if with_pipeline_vis: pipeline.show() # use model to obtain forecast forecast = model.predict(features=train_data_path) print( model.get_metrics(metric_names=['rmse', 'mae', 'mape'], target=target)) # plot forecasting result if with_plot: model.plot_prediction() return forecast
def run_metocean_forecasting_problem(train_file_path, test_file_path, forecast_length=1, is_visualise=False, timeout=5): # Prepare data for train and test ssh_history, ws_history, ssh_obs = prepare_input_data( train_file_path, test_file_path) historical_data = { 'ws': ws_history, # additional variable 'ssh': ssh_history, # target variable } fedot = Fedot( problem='ts_forecasting', task_params=TsForecastingParams(forecast_length=forecast_length), timeout=timeout, verbose_level=4) pipeline = fedot.fit(features=historical_data, target=ssh_history) fedot.forecast(historical_data, forecast_length=forecast_length) metric = fedot.get_metrics(target=ssh_obs) if is_visualise: pipeline.show() fedot.plot_prediction() return metric