Почему я получаю сообщение «AttributeError: объект 'str' не имеет атрибута 'value'» при попытке использовать дартс ExponPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Почему я получаю сообщение «AttributeError: объект 'str' не имеет атрибута 'value'» при попытке использовать дартс Expon

Сообщение Anonymous »

Вот код, который у меня есть:

Код: Выделить всё

# Define models
models = {
'ExponentialSmoothing': [
ExponentialSmoothing(trend='add', seasonal='add', seasonal_periods=52),
ExponentialSmoothing(trend='add', seasonal='mul', seasonal_periods=12)
],
'SeasonalARIMA': [
ARIMA(p=1, d=1, q=1, seasonal_order=(1, 1, 1, 52)),
ARIMA(p=1, d=1, q=1, seasonal_order=(1, 1, 1, 12))
],
'FFT': [
FFT(nr_freqs_to_keep=10),
FFT(nr_freqs_to_keep=5)
]
}

def evaluate_models(train, test, model_list):
performance = []
for model in model_list:
start_time = time.time()
model.fit(train)
forecast = model.predict(len(test))
end_time = time.time()
# Ensure forecast and test are TimeSeries objects
if not isinstance(forecast, TimeSeries):
raise ValueError(f"Forecast is not a TimeSeries object: {forecast}")
if not isinstance(test, TimeSeries):
raise ValueError(f"Test is not a TimeSeries object: {test}")
performance.append({
'Model': type(model).__name__,
'MAE': mae(test, forecast),
'MSE': mse(test, forecast),
'MASE': mase(test, forecast, train),
'Forecast Bias': (forecast.mean() - test.mean()).values()[0],
'Time Elapsed (s)': end_time - start_time
})
return pd.DataFrame(performance)

# Evaluate weekly data
performance_weekly = {}
for name, model_list in models.items():
performance_weekly[name] = evaluate_models(train_weekly, test_weekly, model_list)

# Evaluate monthly data
performance_monthly = {}
for name, model_list in models.items():
performance_monthly[name] = evaluate_models(train_monthly, test_monthly, model_list)

# Display results
display(pd.concat(performance_weekly.values()))
display(pd.concat(performance_monthly.values()))
Я получаю такую ​​ошибку:

Код: Выделить всё

 AttributeError: 'str' object has no attribute 'value'
File , line 42
40 performance_weekly = {}
41 for name, model_list in models.items():
---> 42    performance_weekly[name] = evaluate_models(train_weekly, test_weekly, model_list)
44 # Evaluate monthly data
45 performance_monthly = {}
File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.11/site-packages/darts/models/forecasting/exponential_smoothing.py:123, in ExponentialSmoothing.fit(self, series)
118 if self.seasonal_periods is None and series.has_range_index:
119     seasonal_periods_param = 12
121 hw_model = hw.ExponentialSmoothing(
122     series.values(copy=False),
--> 123     trend=self.trend if self.trend is None else self.trend.value,
124     damped_trend=self.damped,
125     seasonal=self.seasonal if self.seasonal is None else self.seasonal.value,
126     seasonal_periods=seasonal_periods_param,
127     freq=series.freq if series.has_datetime_index else None,
Контекст:
Я занимаюсь прогнозированием временных рядов.
Это из-за методологии, которую я использую разделить набор обучающих и тестовых данных?

Подробнее здесь: https://stackoverflow.com/questions/793 ... hen-trying
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»