用于HpBandSter超参数搜索的scikitlearn包装器

hpbandster-sklearn的Python项目详细描述


hpbandster学习

hpbandster-sklearn是一个Python库,为^{}提供一个^{}包装器-HpBandSterSearchCV-一个超参数调整库。在

动机

HpBandSter实现了几种前沿的超参数算法,包括hyband和BOHB。它们的性能往往优于标准随机搜索,在更短的时间内找到最佳参数组合。在

HpBandSter功能强大且可配置,但对于初学者来说,它的用法通常不直观,需要大量的样板代码。为了解决这个问题,HpBandSterSearchCV被创建为scikit-learn超参数搜索器的一个替代品,它遵循其众所周知和流行的API,使得可以用最小的设置来优化scikit-learnAPI估计器。在

HpBandSterSearchCVAPI基于scikit-learn^{},实现了它所做的几乎所有参数。在

安装

pip install hpbandster-sklearn

使用

像其他任何scikit-learn超参数搜索器一样使用它:

^{pr2}$

您也可以使用ConfigSpace.ConfigurationSpace对象来代替dict(事实上,这是推荐的)!在

importnumpyasnpfromsklearn.datasetsimportload_irisfromsklearn.ensembleimportRandomForestClassifierfromsklearn.utils.validationimportcheck_is_fittedfromhpbandster_sklearnimportHpBandSterSearchCVimportConfigSpaceasCSimportConfigSpace.hyperparametersasCSHX,y=load_iris(return_X_y=True)clf=RandomForestClassifier(random_state=0)np.random.seed(0)param_distributions=CS.ConfigurationSpace(seed=42)param_distributions.add_hyperparameter(CSH.UniformIntegerHyperparameter("min_samples_split",2,11))param_distributions.add_hyperparameter(CSH.UniformIntegerHyperparameter("max_depth",2,4))search=HpBandSterSearchCV(clf,param_distributions,random_state=0,n_jobs=1,n_iter=10,verbose=1).fit(X,y)search.best_params_

有关详细信息,请参阅documentation of this library,以及^{}和{a6}的文档。在

还支持管道和TransformedTargetRegressor。如果您使用其中一个(或两个都使用),请确保相应地为超参数和资源名称加前缀-例如,final_estimator__n_estimatorsn_samples不加前缀。在

提前停车

由于HpBandSter中的几乎每个搜索算法都利用了早期停止(主要是通过连续的减半),用户可以通过HpBandSterSearchCV对象的参数配置要使用的资源和预算。在

search=HpBandSterSearchCV(clf,param_distributions,resource_name='n_samples',# can be either 'n_samples' or a string corresponding to an estimator attribute, eg. 'n_estimators' for an ensembleresource_type=float,# if specified, the resource value will be cast to that type before being passed to the estimator, otherwise it will be derived automaticallymin_budget=0.2,max_budget=1,)search=HpBandSterSearchCV(clf,param_distributions,resource_name='n_estimators',# can be either 'n_samples' or a string corresponding to an estimator attribute, eg. 'n_estimators' for an ensembleresource_type=int,# if specified, the resource value will be cast to that type before being passed to the estimator, otherwise it will be derived automaticallymin_budget=20,max_budget=200,)

默认情况下,对象将尝试通过按顺序检查以下内容来自动确定最佳资源:

  • 'n_estimators',如果模型具有该属性和warm_start属性
  • 'max_iter',如果模型具有该属性和warm_start属性
  • 'n_samples'-如果模型不支持warm_start,数据集样本将被用作资源,测量模型将迭代地拟合到越来越大的数据集部分上。在

此外,还添加了对LightGBMXGBoost和{}scikit-learn估计量的特殊支持。在

文件

https://hpbandster-sklearn.readthedocs.io/en/latest/

参考文献

作者

安东尼鲍姆(Yard1)

许可证

MIT

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java是数据线。getMicrosecondPosition()线程安全?   java我可以设置多个。whereEqualTo在firestore查询中指向文档中的字段?   java Intellij 14 Glassfish服务器未连接。部署不可用   java JPA。如何返回null而不是LazyInitializationException   java TarsosDSP Clap检测   比较基于字符串的java枚举   java空指针异常日历。设定时间   java Hystrix在运行时忽略超时   将数据从Java RESTful服务器推送到Android手机上进行通知   java Jnotify delete vs shift delete问题   java安装失败\u没有匹配\u ABIS res113   TreeJava:传递未实例化的对象引用是如何工作的?   java如何使用Android ringtone manager从资产文件夹播放铃声?   java在Dropwizard的不同状态下使用不同的模拟