的默认度量
hypopt
包裹是
score()
无论您使用什么模型,都可以使用函数,所以在您的情况下,它是
LogisticRegression().score()
默认为准确性。
如果您通过以下方式将hypopt包升级到1.0.8版
pip install hypopt --upgrade
,您可以在
scoring
参数
GridSearch.fit()
例如,
fit(scoring='f1')
. 下面是一个基于使用F1度量的代码的简单工作示例:
from hypopt import GridSearch
param_grid = {"penalty": ['l1'], 'C': [0.001, 0.01]}
opt = GridSearch(model=LogisticRegression(), param_grid = param_grid)
# This will use f1 score as the scoring metric that you optimize.
opt.fit(X_train, y_train, X_val, y_val, scoring='f1')
羟脯氨酸
支持大多数评分功能
sklearn
支持。
-
对于分类,
羟脯氨酸
支持以下指标(字符串):“准确性”、“Brier_Score_Loss”、“平均_Precision”、“F1”、“F1_Micro”、“F1_Macro”、“F1_Weighted”、“Neg_Log_Loss”、“Precision”、“Recall”或“Roc_Auc”。
-
为了回归,
羟脯氨酸
支持:“解释的方差”、“负-均值-绝对误差”、“负-均值-平方误差”、“负-均值-对数误差”、“负-中位数-绝对误差”、“r2”。
您还可以创建自己的度量标准
your_custom_score_func(y_true, y_pred)
通过将其包装成这样的对象:
from sklearn.metrics import make_scorer
scorer = make_scorer(your_custom_score_func)
opt.fit(X_train, y_train, X_val, y_val, scoring=scorer)
你可以在
hypopt.GridSearch.fit()
文档字符串:
您可以在此处了解有关创建自己的自定义评分标准的更多信息: