Я пытаюсь сохранить результат моего прогноза в указанном каталоге c, но получаю эту ошибку. Я работаю на сервере:
Traceback (most recent call last):
File "/home/ge/kelo/anaconda3/lib/python3.7/site-packages/xlsxwriter/workbook.py", line 311, in close
self._store_workbook()
File "/home/ge/kelo/anaconda3/lib/python3.7/site-packages/xlsxwriter/workbook.py", line 627, in _store_workbook
raise e
File "/home/ge/kelo/anaconda3/lib/python3.7/site-packages/xlsxwriter/workbook.py", line 625, in _store_workbook
allowZip64=self.allow_zip64)
File "/home/ge/kelo/anaconda3/lib/python3.7/zipfile.py", line 1207, in __init__
self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/ge/kelo/eXP/Corpus/lexique_3e_res_LT/test_modelTraditionnel_lexicon_tfidf_ngramBigModel_SVC.xlsx'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "features.py", line 228, in <module>
classify_essai(data_id,data,ylabels)
File "features.py", line 216, in classify_essai
output.to_excel("/home/ge/kelo/eXP/Corpus/lexique_3e_res_LT/test_modelTraditionnel_lexicon_tfidf_ngramBig{}.xlsx".format(model_name))
File "/home/ge/kelo/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 2256, in to_excel
engine=engine,
File "/home/ge/kelo/anaconda3/lib/python3.7/site-packages/pandas/io/formats/excel.py", line 742, in write
writer.save()
File "/home/ge/kelo/anaconda3/lib/python3.7/site-packages/pandas/io/excel/_xlsxwriter.py", line 195, in save
return self.book.close()
File "/home/ge/kelo/anaconda3/lib/python3.7/site-packages/xlsxwriter/workbook.py", line 313, in close
raise FileCreateError(e)
xlsxwriter.exceptions.FileCreateError: [Errno 2] No such file or directory: '/home/ge/kelo/eXP/Corpus/lexique_3e_res_LT/test_modelTraditionnel_lexicon_tfidf_ngramBigModel_SVC.xlsx'
Ниже моего сценария:
for model_name, model in models.items():
y_pred = cross_val_predict(model, X_data, ylabels, cv=cv_splitter)
all_accuracies = cross_val_score(model, X_data, ylabels, cv=cv_splitter)
print("Model: {}".format(model_name))
print(all_accuracies)
print(all_accuracies.mean()) #moyenne print("Accuracy: {}".format(accuracy_score(ylabels, y_pred))) #
print(all_accuracies.std()) #déterminer la variance
print(classification_report(ylabels, y_pred, labels=labels))
print("Accuracy: {}".format(accuracy_score(ylabels, y_pred)))
cm = confusion_matrix(ylabels, y_pred)
print("matrice confusion: {}".format(cm))
# export des données
output = pd.DataFrame()
output['id'] = output_id
output['Verbatim'] = Verbatim
output['Expected Output'] = ylabels
output['Predicted Output'] = y_pred
# print(output.head())
#output.to_excel("test_modelTraditionnel_lexicon_tfidf_ngram{}.xlsx".format(model_name))
output.to_excel("/home/ge/kelo/eXP/Corpus/lexique_3e_res_LT/test_modelTraditionnel_lexicon_tfidf_ngramBig{}.xlsx".format(model_name))
Как я могу преодолеть это, если я использую os.chdir для изменения каталога перед экспортом в указанный файл? c каталог или есть лучшее решение?