我使用了LGBMRegressor()模型进行拟合并预测了一些值。我决定保存它(在拟合之后),以便以后使用,但是当我尝试加载模型时,我收到了以下异常:
Estimator not fitted, call fit before exploiting the model.
我尝试了三种不同的保存方式:
dump(model, 'model.txt')
dump(model, 'model.pkl')
dump(model, 'model.joblib')
model = joblib.load('model.allExtensionsMentionedBefore')
print(model)
时,我可以看到整个模型以及它的超参数。LGBMRegressor(colsample_bytree=0.9596645565436184,
learning_rate=0.025825537313443326, min_child_samples=72,
num_leaves=32, random_state=0, silent=True,
subsample=0.9311181768429686, subsample_freq=1)
然而,当我尝试使用model.predict(X)
时,出现了异常,提示它没有适配。
我做错了什么吗?
PS:我能够使用sklearn MLPRegressor()
完成这个过程(保存和加载),并且它完美地工作。