_catboost.CatBoostError: C:/Program Files (x86)/Go Agent/pipelines/BuildMaster/catboost.git/catboost/libs/data/model_dataset_compatibility.cpp:81: At position 0 should be feature with name featureA (found featureB)

目录

_catboost.CatBoostError: C:/Program Files (x86)/Go Agent/pipelines/BuildMaster/catboost.git/catboost/libs/data/model_dataset_compatibility.cpp:81: At position 0 should be feature with name featureA (found featureB)

问题:

解决:

完整错误:


问题:

#模型保存

# Import pickle Package
import pickle

# Save the Modle to file in the current working directory

pkl_name = "break_model1.pkl"  

with open(pkl_name, 'wb') as file:  
    pickle.dump(cat_model, file)

#模型加载预测

# Load the Model back from file
with open(pkl_name, 'rb') as file:  
    Pickled_Model = pickle.load(file)
    
Pickled_Model

Pickled_Model.predict_proba(features_test)[:,1]

解决:

如下示例:犯了三个错误:

第一,特征的顺序变了;A特征跑到了B特征后面;

第二,多了一个模型训练没有见过的特征E;

第三,少了一个模型训练缺少的特征C

#模型训练的特征列表;
feature_list = [featureA、featureB、featureC、featureD]


#模型预测的特征列表;
feature_list = [featureB、featureA、featureE、featureD]




#正解
feature_list = [featureA、featureB、featureC、featureD]
input_data = data[feature_list]

完整错误:

_catboost.CatBoostError: C:/Program Files (x86)/Go Agent/pipelines/BuildMaster/catboost.git/catboost/libs/data/model_dataset_compatibility.cpp:81: At position 0 should be feature with name featureA (found featureB)

Logo

Agent 垂直技术社区,欢迎活跃、内容共建,欢迎商务合作。wx: diudiu5555

更多推荐