import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from minisom import MiniSom
from neuralforecast.core import NeuralForecast
from neuralforecast.models import NHITS, NBEATS, TimesNet
from neuralforecast.losses.numpy import mae, mse
plt.rcParams["figure.figsize"] = (9, 6)
# 读取数据
df = pd.read_csv('etth1.csv',nrows=500)
# 确保 'ds' 列是日期时间格式
df['ds'] = pd.to_datetime(df['ds'])
# 打印数据前几行
print("数据示例:")
print(df.head())
# 设定预测步数
horizon = 10
# 定义模型
models = [
TimesNet(h=horizon, input_size=2*10, max_steps=50)
]
# 初始化 NeuralForecast
nf = NeuralForecast(models&