简体   繁体   English

light gbm - python API 与 Scikit-learn API

[英]light gbm - python API vs Scikit-learn API

I am trying to apply LightGBM and have gone through the Python API documentation .我正在尝试应用 LightGBM 并浏览了 Python API文档

Is there any difference between Training API and Scikit-learn API? Training API 和 Scikit-learn API 之间有什么区别吗? Can we use both the APIs to achieve same result for the same problem?我们可以使用这两种 API 来针对同一问题实现相同的结果吗?

The short answer: yes, they will provide identical results if you will configure them in identical ways.简短的回答:是的,如果您以相同的方式配置它们,它们将提供相同的结果。

The reason is that sklearn API is just a wrapper around the "native training" API, which in turn is a wrapper around the backend C++ library.原因是 sklearn API 只是“本机训练”API 的包装器,而后者又是后端 C++ 库的包装器。 At the end, this is your choice to make.最后,这是您的选择。 I personally would advice in favour of the sklearn API.我个人会建议使用 sklearn API。 The 2 major advantages are: 2个主要优点是:

  • you can make use of full sklearn toolkit (pipelines with data preprocessing, hyperparameter optimisation, model evalueation, etc)您可以使用完整的 sklearn 工具包(具有数据预处理、超参数优化、模型评估等的管道)
  • you can switch between different model in a painless way, ie your input data has the same format ( pd.DataFrame or np.ndarray ), trainign interface is the same and you can switch between sklearn models, lightgbm, xgboost, catboost or vowpal wabbit by simply instantiating different objects and passing them through the same procedure.您可以轻松地在不同模型之间切换,即您的输入数据具有相同的格式( pd.DataFramenp.ndarray ),trainign 接口是相同的,您可以在 sklearn 模型、lightgbm、xgboost、catboost 或 vawpal wabbit 之间切换通过简单地实例化不同的对象并将它们传递给相同的过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM