Reputation: 53
How to save multiple SVM models by using python
I am trying to save multiple model to save in a path by taking name from list by using for loop range.
My model is working fine but while trying to save each in unique name getting error.
city_id = ['1', '2', '18', '19', '21', '23', '26', '27', '28', '32', '35', '36', '37', '38', '39', '40', '41',
'42', '43', '44', '45', '46', '47', '49', '50', '51', '58', '65', '67', '68', '69', '70', '71']
for i in range(len(city_id)):
joblib.dump(model, 'D:/Model/model_Predict_Locality_predictor_'+ str(city_id[i]) +'.pkl', compress=1)
but getting out of range error
I have check range also but both range are same.
Error
1
Model Pipeline Created Successfully...
Data fitted Successfully...
Data Predicted Successfully...
Accuracy: 0.9908892595919415
list index out of range
2
Model Pipeline Created Successfully...
Data fitted Successfully...
Data Predicted Successfully...
Accuracy: 0.9790685504971219
list index out of range
After the accuracy, getting error as above.
Please suggest
Upvotes: 0
Views: 1691
Reputation: 16966
You have used i
as the index variable for both for
loops. Correct that and then try!
Upvotes: 1