import_template erro Expecting value: line 1 column 1 (char 0)
import pandas as pd
from autots import AutoTS
symbol='BTCUSDT'
forecast_length=1
df = pd.read_csv(symbol+"-Reverse-Eval.csv")
df=df[-200:]
print(df.head())
# at = AutoTS(
# forecast_length=forecast_length,
# frequency='infer',
# prediction_interval=0.9,
# ensemble='all',
# model_list="fast", # "superfast", "default", "fast_parallel"
# transformer_list="fast", # "superfast",
# drop_most_recent=1,
# max_generations=15,
# subset=100,
# num_validations=2,
# validation_method="backwards"
# )
at = AutoTS(
forecast_length=forecast_length,
frequency='infer',
prediction_interval=0.9,
ensemble='all',
model_list="fast", # "superfast", "default", "fast_parallel"
transformer_list="fast", # "superfast",
drop_most_recent=1,
max_generations=1,
subset=1,
num_validations=0,
validation_method="backwards"
)
model = at.fit(
df,
date_col='StartTime',
value_col='Label',
id_col='Symbol'
)
# prediction = model.predict()
# print(prediction.forecast)
example_filename = "example_export.csv" # .csv/.json
model.export_template(example_filename, models='best')
# print(prediction.forecast)
at2 = AutoTS(
forecast_length=forecast_length,
frequency='infer',
prediction_interval=0.9,
ensemble='all',
model_list="fast", # "superfast", "default", "fast_parallel"
transformer_list="fast", # "superfast",
drop_most_recent=1,
max_generations=1,
subset=1,
num_validations=0,
validation_method="backwards"
)
model2 = at2.import_template(example_filename, method='only') # method='add on'
model2.fit_data(df,
date_col='StartTime',
value_col='Label',
id_col='Symbol')
prediction2 = model2.predict()
print(prediction2.forecast)
prediction2 = model2.predict() Expecting value: line 1 column 1 (char 0)
You should try reformatting your code here on Github with it inside a block of: ``` right now the markdown you have it turning code comments into headers
https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
Edit: I've done it for you
你应该尝试在 Github 上重新格式化你的代码,并将其放在以下块中: ``` 现在,你已经将代码注释转换为标题了
https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
编辑:我已经为你做到了
I’m a little curious. The examples on the official website cannot use already trained models.
Okay, here's the issue, and yes, it's a bit confusing, so sorry about that:
- import_template loads the initial template for a model search (.fit) which is a "seed" for a generation search. It allows a gradually evolving template
- import_best_model imports just the best model and then loads it ready for prediction
so you need to replace
model2 = at2.import_template(example_filename, method='only') # method='add on'
with
model2 = at2.import_best_model(example_filename)
and it should work
thanks