- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
使用databricks,我基本上从这里复制并粘贴了相同的代码:https://www.dataiku.com/learn/guide/code/python/advanced-xgboost-tuning.html
我遇到了这个错误:
train = data.sample(frac=0.70, random_state=123)
valid = data.loc[~data.index.isin(train.index), :]
y_train = train['target']
X_train = train.drop(['target'], axis=1)
y_valid = test['target']
X_valid = test.drop(['target'], axis=1)
def objective(space):
clf = xgb.XGBClassifier(n_estimators = 10000,
max_depth = space['max_depth'],
min_child_weight = space['min_child_weight'],
subsample = space['subsample'])
eval_set = [( train, y_train), ( valid, y_valid)]
clf.fit(train[col_train], y_train,
eval_set=eval_set, eval_metric="auc",
early_stopping_rounds=30)
pred = clf.predict_proba(valid)[:,1]
auc = roc_auc_score(y_valid, pred)
print("SCORE:", auc)
return{'loss':1-auc, 'status': STATUS_OK }
space ={
'max_depth': hp.quniform("x_max_depth", 5, 30, 1),
'min_child_weight': hp.quniform ('x_min_child', 1, 10, 1),
'subsample': hp.uniform ('x_subsample', 0.8, 1)
}
trials = Trials()
best = fmin(fn=objective,
space =space,
algo=tpe.suggest,
max_evals=100,
trials=trials)
print(best)
我遇到的错误如下:
ValueError: invalid number of arguments
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<command-3897094> in <module>()
4 algo=tpe.suggest,
5 max_evals=100,
----> 6 trials=trials)
7
8
ValueError: invalid number of arguments
任何见解都会有所帮助。关于堆栈溢出的第一个问题!
最佳答案
博客Advanced XGBoost tuning in Python您引用的是2016年8月22日的帖子,如下图。
我认为它适用于旧版本,可能不适合使用最新版本的 hyperopt
包。
因此,请参阅 FMin
的最新 hyperopt
wiki 页面。 。下面是一个简单的示例代码。
from hyperopt import fmin, tpe, hp
best = fmin(fn=lambda x: x ** 2,
space=hp.uniform('x', -10, 10),
algo=tpe.suggest,
max_evals=100)
print best
可以看到space
类型应该是hyperopt.pyll.Apply
,而不是Python字典,请参见code来自 GitHub 存储库,如下图。
关于python - 我对使用 Xgboost 的 hyperopt 包的 fmin() 函数有很大的兴趣,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58530665/
我正在使用 python包裹hyperopt我有一个参数 a这需要大于参数 b . 例如,我希望我的参数空间是这样的 from hyperopt import hp space = {"b": hp.
如果有人可以提供帮助: 如何为每个单独的测试设置超时?整个实验超时? 如何设置渐进策略,在实验的不同阶段消除/修剪搜索空间中最差得分分支的百分比(同时使用当前的优化算法)? IE。在最大总实验的 30
这是我第一次调整 XGBoost 的超参数。我的计划是使用 hyperopt 找到最佳超参数。 def obj (params): xgb_model=xgb.XGBRegressor(
除了HyperOpt之外,还有其他可以支持超参数搜索多重处理的吗?我知道HyperOpt可以配置为使用MongoDB,但似乎很容易出错并且在杂草中度过一周,有什么更受欢迎的吗有效吗? 最佳答案 查看射
我正在尝试使用hyperopt首次。我复制并粘贴了教程示例: from hyperopt import fmin, tpe, hp best = fmin(fn=lambda x: x ** 2,
我正在使用 Python 的 hyperopt 库来执行 ML 超参数优化。特别是,我试图使用此函数来最小化找到 lightgbm 最佳超参数: def lgb_objective_map(param
我是 hyperopt 包的新手。现在,我想优化我在 gensim 中实现的 LDA 模型。 LDA 模型经过优化以最大化训练数据的轮廓分数。 现在,我的问题是“如何将训练数据 (numpy.ndar
我使用“hyperopt”Python 包调整算法,我找不到如何打印最佳配置的损失: from hyperopt import fmin, tpe, rand, space_eval, Trials
我完全承认我可能在这里设置了错误的条件空间,但出于某种原因,我根本无法让它发挥作用。我正在尝试使用 hyperopt 来调整逻辑回归模型,并且根据求解器的不同,还有一些其他参数需要探索。如果您选择 l
我正在尝试使用贝叶斯优化(Hyperopt)来获得 SVM 算法的最佳参数。但是,我发现每次运行时最佳参数都在变化。 下面提供的是一个简单的可重现案例。你能对此有所了解吗? import numpy
Hyperopt 提供什么样的设置来调整探索与利用之间的平衡?代码中有类似“bandit”和“bandit_algo”的东西,但没有解释。 有人可以提供任何代码示例吗? 非常感谢您的帮助! 最佳答案
在下面的代码中,我修改了 tensorflow 教程(官方)中的 Deep MNIST 示例。 修改——将权重衰减添加到损失函数中,同时也修改了权重。 (如果不正确,请告诉我)。 from __fut
我正在为我的主项目说明 hyperopt 的 TPE 算法,但似乎无法使算法收敛。据我对原文的了解 paper和 youtube lecture TPE算法的工作步骤如下: (在下文中,x=超参数和
我正在努力使用 hyperopt 来调整我的 ML 模型,但在使用 qloguniform 作为搜索空间时遇到了麻烦。我给出了 official wiki 的示例并更改了搜索空间。 import pi
有没有人有将 Hyperopt 集成到 Spark 的 MlLib 中的好例子?我一直在尝试在 Databricks 上这样做,并继续遇到同样的错误。我不确定这是否是我的目标函数的问题,或者它是否与
我正在尝试使用 Hyperopt在回归模型上,它的一个超参数是按变量定义的,需要作为列表传递。例如,如果我有一个包含 3 个自变量(不包括常量)的回归,我会通过 hyperparameter = [x
我是 mongodb 的新手,我想在 hyperopt 中使用它进行并行评估。到目前为止,我已执行以下步骤: 在C:/Mongodb安装MongoDB 3.7.3 创建一个空数据库文件夹 C:/Mon
我第一次尝试使用 Hyperopt 在 Python 中进行超参数调整。我已阅读文档并想在 XgBoost 分类器上尝试一下。 “X_train”和“y_train”是将其分为测试集和训练集后的数据框
我第一次尝试使用 hyperopt 调整 KNeighbors 参数,但出现了一个奇怪的错误。不知道问题出在哪里,但希望能解决。以下是有关此问题的更多详细信息: 代码: from sklearn.ne
我尝试使用 optuna 来调整超参数。但我的目标函数是有条件的,这会在获得最佳参数方面产生问题。 只有满足条件时我才想获得 cwc,否则继续尝试下一个超参数。但我猜由于条件不满足并且目标函数返回 c
我是一名优秀的程序员,十分优秀!