나는 SKLearn 모델을 훈련하고 다음 코드를 사용하여 모델을 저장하는 파이썬 3.6 스크립트가 : 나는에 피클을로드 할 때파이썬으로 파이썬 3 절인 SKlearn 모델을로드하는 방법이
with open('filepath', 'wb') as f:
pickle.dump(trained_model, f, protocol=2)
을 파이썬 3.6, 일이 잘 해결 :
>>with open('filepath', 'rb') as f:
>> model = pickle.load(f)
>>
>>model
RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=80, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False)
내가 파이썬 2.7에서이 같은 pickle.load 명령을 실행할 때, 나는 다음과 같은 오류 얻을 :
>>with open('filepath', 'rb') as f:
>> model = pickle.load(f)
ValueError: non-string names in Numpy dtype unpickling
을
설명서 및 유사 사례를 보면 프로토콜을 2 으로 설정하면은 피클 파일을 호환 가능해야합니다. 이 문제의 원인은 무엇이며 어떻게 해결할 수 있습니까?
전체 추적입니까? –
불행히도, 그렇습니다. – bigmacboy78
나는 진단을 위해 [mcve]를 제공하지 않았다. –