Views
No views yet

1
2import numpy as np
3import pandas as pd
4import matplotlib.pyplot as plt
5from model.model import ChatTime
6
7dataset = "Traffic"
8hist_len = 120
9pred_len = 24
10model_path = "ChengsenWang/ChatTime-1-7B-Chat"
11
12df = pd.read_csv(f"./dataset/{dataset}.csv")
13hist_data = np.array(df["Hist"].apply(eval).values.tolist())[:, -hist_len:][0]
14pred_data = np.array(df["Pred"].apply(eval).values.tolist())[:, :pred_len][0]
15
16model = ChatTime(hist_len=hist_len, pred_len=pred_len, model_path=model_path)
17
18out = model.predict(hist_data)
19
20hist_x = np.linspace(0, hist_len-1, hist_len)
21pred_x = np.linspace(hist_len, hist_len+pred_len-1, pred_len)
22
23plt.figure(figsize=(8, 2), dpi=500)
24plt.plot(hist_x, hist_data, color='#000000')
25plt.plot(pred_x, pred_data, color='#000000', label='true')
26plt.plot(pred_x, out, color='#FF7F0E', label='pred')
27plt.axvline(hist_len, color='red')
28plt.legend(loc="upper left")
29plt.show()
301
2import numpy as np
3import pandas as pd
4import matplotlib.pyplot as plt
5from model.model import ChatTime
6
7dataset = "PTF"
8hist_len = 120
9pred_len = 24
10model_path = "ChengsenWang/ChatTime-1-7B-Chat"
11
12df = pd.read_csv(f"./dataset/{dataset}.csv")
13hist_data = np.array(df["Hist"].apply(eval).values.tolist())[:, -hist_len:][0]
14pred_data = np.array(df["Pred"].apply(eval).values.tolist())[:, :pred_len][0]
15context = df["Text"].values[0]
16
17model = ChatTime(hist_len=hist_len, pred_len=pred_len, model_path=model_path)
18
19out_text = model.predict(hist_data, context)
20out = model.predict(hist_data)
21
22hist_x = np.linspace(0, hist_len-1, hist_len)
23pred_x = np.linspace(hist_len, hist_len+pred_len-1, pred_len)
24
25plt.figure(figsize=(8, 2), dpi=500)
26plt.plot(hist_x, hist_data, color='#000000')
27plt.plot(pred_x, pred_data, color='#000000', label='true')
28plt.plot(pred_x, out_text, color='#FF7F0E', label='pred_text')
29plt.plot(pred_x, out, color='#1F77B4', label='pred')
30plt.axvline(hist_len, color='red')
31plt.legend(loc="upper left")
32plt.show()
331
2import numpy as np
3import pandas as pd
4import matplotlib.pyplot as plt
5from model.model import ChatTime
6
7dataset = "TSQA"
8model_path = "ChengsenWang/ChatTime-1-7B-Chat"
9
10df = pd.read_csv(f"./dataset/{dataset}.csv")
11series = np.array(df["Series"].apply(eval).values.tolist())[0]
12question = df["Question"].values[0]
13answer = df["Answer"].values[0]
14
15model = ChatTime(model_path=model_path)
16
17out = model.analyze(question, series)
18
19plt.figure(figsize=(8, 2), dpi=500)
20plt.plot(series, color='#000000')
21plt.show()
22
23print(question)
24print(f"\n{out} / {answer}\n")
251@inproceedings{
2 author = {Chengsen Wang and Qi Qi and Jingyu Wang and Haifeng Sun and Zirui Zhuang and Jinming Wu and Lei Zhang and Jianxin Liao},
3 title = {ChatTime: A Unified Multimodal Time Series Foundation Model Bridging Numerical and Textual Data},
4 booktitle = {AAAI Conference on Artificial Intelligence},
5 year = {2025},
6}