I ran a time-series model on colab and save the station-wise best-fitted model as a pkl file in the colab local directory, But when i tried to fectch the save model for further prediction, i am getting error that file could not be found. How to give the path for the models,
Copied path from the colab (/content/trained_modelsa.pkl)
Models are saved in the below name and fotmat
Code i used for fetching the models,
from pycaret.regression import load_model, predict_model
all_score_df = []
list_ = ['a','b','c']
j = 0
for i in tqdm(df['ds'].unique()):
l = load_model("trained_models" list_[j], verbose=False)
p = predict_model(l, data=score_df)
p['time_series'] = i
all_score_df.append(p)
j=j 1
concat_df = pd.concat(all_score_df, axis=0)
concat_df.head()
Error line
"['t'] not in index" (Line no 7)
CodePudding user response:
make a list of a,b,c and append it rather than a string(i).
list_ = ['a','b','c']
j =0
for i in tqdm(df['ds'].unique()):
l = load_model("trained_models" list_[j], verbose=False)
p = predict_model(l, data=score_df)
p['time_series'] = i
all_score_df.append(p)
j=j 1
concat_df = pd.concat(all_score_df, axis=0)
concat_df.head()
CodePudding user response:
When you store folders/files in the /content
folder, they only persist as long as the runtime environment is active. To store folders/files directly in any of your Google Drive folders, making the files persist even if you close the running runtime, you must use the /content/drive/MyDrive/YourFolderInDrive
path.
Specifically, to use any folder/file from your Google Drive, follow these steps:
- Click on "Mount Drive" button and follow the steps.
- Click on "Refresh" button.
- Using the folder tree, scroll through the folders until you find the folder/file you want.
- Right click the folder/file and click "Copy path". This is the path you must use in your Python code.