初始化AutoTS模型时触发JSONDecodeError错误的技术求助
问题排查:AutoTS初始化时触发JSONDecodeError
已安装依赖
!pip install auto_ts !pip install autots
测试代码
from autots import AutoTS model = AutoTS(forecast_length=10, frequency='infer',ensemble='simple', drop_data_older_than_periods=200) model = model.fit(data, date_col='Date', value_col='Close', id_col=None)
触发错误
Using 1 cpus for n_jobs. --------------------------------------------------------------------------- JSONDecodeError Traceback (most recent call last) <ipython-input-9-eb76a397227f> in <cell line: 2>() 1 from autots import AutoTS ----> 2 model = AutoTS(forecast_length=10, frequency='infer',ensemble='simple', drop_data_older_than_periods=200) 3 model = model.fit(data, date_col='Date', value_col='Close', id_col=None) 2 frames /usr/lib/python3.10/json/decoder.py in decode(self, s, _w) 338 end = _w(s, end).end() 339 if end != len(s): --> 340 raise JSONDecodeError("Extra data", s, end) 341 return obj 342 JSONDecodeError: Extra data: line 1 column 4 (char 3)
排查方向
- 卸载冲突库:
auto_ts和autots是两个独立库,代码使用的是autots的AutoTS,同时安装可能导致依赖或配置冲突,执行pip uninstall -y auto_ts后重试 - 清理AutoTS缓存:AutoTS初始化时会读取本地缓存的配置文件,若文件损坏会触发JSON解析错误,找到缓存目录(通常为
~/.autots/或系统临时目录),删除其中的JSON格式配置文件 - 避免自动推断频率:将
frequency='infer'替换为数据实际的频率值(如日度数据用'D',小时度用'H'),跳过初始化时的频率推断流程 - 检查Python环境:确认环境中无自定义JSON解码器或异常版本的json库,可通过
import json; print(json.__version__)查看版本,确保为标准库版本
内容的提问来源于stack exchange,提问作者theunknown
相关产品推荐
相关产品推荐

