机器学习算法具有超参数,可让这些算法针对特定的数据集进行量身定制。

尽管通常可以理解超参数的影响,但是可能不知道它们对数据集的特定影响以及它们在学习期间的交互作用。因此,作为机器学习项目的一部分,调整算法超参数的值很重要。

通常使用简单的优化算法来调整超参数,例如网格搜索和随机搜索。另一种方法是使用随机优化算法,例如随机爬山算法。

在本教程中,您将发现如何手动优化机器学习算法的超参数。完成本教程后,您将知道:

  • 可以使用随机优化算法代替网格和随机搜索来进行超参数优化。
  • 如何使用随机爬山算法调整 Perceptron 算法的超参数。
  • 如何手动优化 XGBoost 梯度提升算法的超参数。

教程概述

本教程分为三个部分:他们是:

  • 手动超参数优化
  • 感知器超参数优化
  • XGBoost 超参数优化

手动超参数优化

机器学习模型具有必须设置的超参数,以便针对数据集自定义模型。通常,超参数对模型的一般影响是已知的,但是如何为给定的数据集最佳地设置超参数以及相互作用的超参数的组合具有挑战性。更好的方法是客观地搜索模型超参数的不同值,然后选择一个子集,以使模型在给定的数据集上获得最佳性能。这称为超参数优化或超参数调整。尽管最简单和最常见的两种方法是随机搜索和网格搜索,但是可以使用一系列不同的优化算法。

随机搜索。将搜索空间定义为超参数值的有界域,并在该域中随机采样点。

网格搜索。将搜索空间定义为超参数值的网格,并评估网格中的每个位置。

网格搜索非常适用于抽签检查组合,这些组合通常表现良好。随机搜索非常适合发现和获取您可能不会直观地猜到的超参数组合,尽管它通常需要更多时间来执行。

有关网格和随机搜索以进行超参数调整的更多信息,请参见教程:

随机搜索和网格搜索的超参数优化

https://machinelearningmastery.com/hyperparameter-optimization-with-random-search-and-grid-search/

网格和随机搜索是原始的优化算法,可以使用我们喜欢的任何优化来调整机器学习算法的性能。例如,可以使用随机优化算法。当需要良好或出色的性能并且有足够的资源可用于调整模型时,这可能是理想的。接下来,让我们看看如何使用

感知器超参数优化

Perceptron 算法是最简单的人工神经网络类型。它是单个神经元的模型,可用于两类分类问题,并为以后开发更大的网络提供了基础。在本节中,我们将探索如何手动优化 Perceptron 模型的超参数。首先,让我们定义一个综合二进制分类问题,我们可以将其用作优化模型的重点。我们可以使用make_classification()函数来定义一个包含1,000行和五个输入变量的二进制分类问题。下面的示例创建数据集并总结数据的形状。

  1. # define a binary classification dataset
  2. from sklearn.datasets import make_classification
  3. # define dataset
  4. X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
  5. # summarize the shape of the dataset
  6. print(X.shape, y.shape)

运行示例将打印创建的数据集的形状,从而确认我们的期望。

  1. (1000, 5) (1000,)

scikit-learn 通过 Perceptron 类提供了 Perceptron 模型的实现。

在调整模型的超参数之前,我们可以使用默认的超参数建立性能基准。

我们将通过 RepeatedStratifiedKFold 类使用重复分层k折交叉验证的良好实践来评估模型。下面列出了在我们的合成二进制分类数据集中使用默认超参数评估 Perceptron 模型的完整示例。

  1. # perceptron default hyperparameters for binary classification
  2. from numpy import mean
  3. from numpy import std
  4. from sklearn.datasets import make_classification
  5. from sklearn.model_selection import cross_val_score
  6. from sklearn.model_selection import RepeatedStratifiedKFold
  7. from sklearn.linear_model import Perceptron
  8. # define dataset
  9. X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
  10. # define model
  11. model = Perceptron()
  12. # define evaluation procedure
  13. cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
  14. # evaluate model
  15. scores = cross_val_score(model, X, y, scoring='accuracy', cvcv=cv, n_jobs=-1)
  16. # report result
  17. print('Mean Accuracy: %.3f (%.3f)' % (mean(scores), std(scores)))

运行示例报告将评估模型,并报告分类准确性的平均值和标准偏差。

注意:由于算法或评估程序的随机性,或者数值精度的差异,您的结果可能会有所不同。考虑运行该示例几次并比较平均结果。

在这种情况下,我们可以看到具有默认超参数的模型实现了约78.5%的分类精度。

我们希望通过优化的超参数可以实现比此更好的性能。

  1. Mean Accuracy: 0.786 (0.069)

接下来,我们可以使用随机爬山算法优化 Perceptron 模型的超参数。我们可以优化许多超参数,尽管我们将重点放在可能对模型的学习行为影响最大的两个参数上。他们是:

  • 学习率(eta0)
  • 正则化(alpha)

学习率控制基于预测误差的模型更新量,并控制学习速度。eta的默认值为1.0。合理的值应大于零(例如,大于1e-8或1e-10),并且可能小于1.0默认情况下,Perceptron 不使用任何正则化但是我们将启用“弹性网”正则化,在学习过程中同时应用L1和L2正则化。这将鼓励模型寻求较小的模型权重,从而往往获得更好的性能。我们将调整用于控制正则化权重的“ alpha”超参数,例如它影响学习的数量。如果设置为0.0,则好像没有使用正则化。合理的值在0.0到1.0之间。首先,我们需要为优化算法定义目标函数。我们将使用平均分类精度和重复的分层k折交叉验证来评估配置。我们将努力使配置的准确性最大化。下面的 Objective() 函数实现了这一点,采用了数据集和配置值列表。将配置值(学习率和正则化权重)解压缩,用于配置模型,然后对模型进行评估,并返回平均准确度。

  1. # objective function
  2. def objective(X, y, cfg):
  3. # unpack config
  4. eta, alpha = cfg
  5. # define model
  6. model = Perceptron(penalty='elasticnet', alphaalpha=alpha, etaeta0=eta)
  7. # define evaluation procedure
  8. cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
  9. # evaluate model
  10. scores = cross_val_score(model, X, y, scoring='accuracy', cvcv=cv, n_jobs=-1)
  11. # calculate mean accuracy
  12. result = mean(scores)
  13. return result

接下来,我们需要一个函数来在搜索空间中迈出一步。搜索空间由两个变量(eta和alpha)定义。搜索空间中的某个步骤必须与先前的值有一定关系,并且必须绑定到合理的值(例如0到1之间)。我们将使用“步长”超参数来控制允许算法从现有配置移动多远。使用高斯分布以当前值作为分布的平均值,以步长作为分布的标准偏差来概率地选择新的配置。我们可以使用randn(),NumPy函数生成具有高斯分布的随机数。下面的step()函数实现了这一点,并将在搜索空间中迈出一步,并使用现有配置生成新配置。

  1. # take a step in the search space
  2. def step(cfg, step_size):
  3. # unpack the configuration
  4. eta, alpha = cfg
  5. # step eta
  6. new_eta = eta + randn() * step_size
  7. # check the bounds of eta
  8. if new_eta <= 0.0:
  9. new_eta = 1e-8
  10. # step alpha
  11. new_alpha = alpha + randn() * step_size
  12. # check the bounds of alpha
  13. if new_alpha < 0.0:
  14. new_alpha = 0.0
  15. # return the new configuration
  16. return [new_eta, new_alpha]

接下来,我们需要实现随机爬山算法,该算法将调用我们的Objective()函数来评估候选解,而我们的step()函数将在搜索空间中迈出一步。搜索首先生成一个随机初始解,在这种情况下,eta和alpha值在0到1范围内。然后评估初始解并将其视为当前最佳工作解。

  1. # starting point for the search
  2. solution = [rand(), rand()]
  3. # evaluate the initial point
  4. solution_eval = objective(X, y, solution)

接下来,该算法将迭代进行固定次数的迭代,作为提供给搜索的超参数。每次迭代都需要采取步骤并评估新的候选解决方案。

  1. # take a step
  2. candidate = step(solution, step_size)
  3. # evaluate candidate point
  4. candidte_eval = objective(X, y, candidate)

如果新解决方案比当前工作解决方案好,则将其视为新的当前工作解决方案。

  1. # check if we should keep the new point
  2. if candidte_eval >= solution_eval:
  3. # store the new point
  4. solution, solution_eval = candidate, candidte_eval
  5. # report progress
  6. print('>%d, cfg=%s %.5f' % (i, solution, solution_eval))

搜索结束时,将返回最佳解决方案及其性能。结合在一起,下面的hillclimbing()函数以数据集,目标函数,迭代次数和步长为参数,实现了用于调整 Perceptron 算法的随机爬山算法。

  1. # hill climbing local search algorithm
  2. def hillclimbing(X, y, objective, n_iter, step_size):
  3. # starting point for the search
  4. solution = [rand(), rand()]
  5. # evaluate the initial point
  6. solution_eval = objective(X, y, solution)
  7. # run the hill climb
  8. for i in range(n_iter):
  9. # take a step
  10. candidate = step(solution, step_size)
  11. # evaluate candidate point
  12. candidte_eval = objective(X, y, candidate)
  13. # check if we should keep the new point
  14. if candidte_eval >= solution_eval:
  15. # store the new point
  16. solution, solution_eval = candidate, candidte_eval
  17. # report progress
  18. print('>%d, cfg=%s %.5f' % (i, solution, solution_eval))
  19. return [solution, solution_eval]

然后,我们可以调用算法并报告搜索结果。在这种情况下,我们将运行该算法100次迭代,并使用0.1步长,这是在经过反复试验后选择的。

  1. # define the total iterations
  2. n_iter = 100
  3. # step size in the search space
  4. step_size = 0.1
  5. # perform the hill climbing search
  6. cfg, score = hillclimbing(X, y, objective, n_iter, step_size)
  7. print('Done!')
  8. print('cfg=%s: Mean Accuracy: %f' % (cfg, score))

结合在一起,下面列出了手动调整 Perceptron 算法的完整示例。

  1. # manually search perceptron hyperparameters for binary classification
  2. from numpy import mean
  3. from numpy.random import randn
  4. from numpy.random import rand
  5. from sklearn.datasets import make_classification
  6. from sklearn.model_selection import cross_val_score
  7. from sklearn.model_selection import RepeatedStratifiedKFold
  8. from sklearn.linear_model import Perceptron
  9. # objective function
  10. def objective(X, y, cfg):
  11. # unpack config
  12. eta, alpha = cfg
  13. # define model
  14. model = Perceptron(penalty='elasticnet', alphaalpha=alpha, etaeta0=eta)
  15. # define evaluation procedure
  16. cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
  17. # evaluate model
  18. scores = cross_val_score(model, X, y, scoring='accuracy', cvcv=cv, n_jobs=-1)
  19. # calculate mean accuracy
  20. result = mean(scores)
  21. return result
  22. # take a step in the search space
  23. def step(cfg, step_size):
  24. # unpack the configuration
  25. eta, alpha = cfg
  26. # step eta
  27. new_eta = eta + randn() * step_size
  28. # check the bounds of eta
  29. if new_eta <= 0.0:
  30. new_eta = 1e-8
  31. # step alpha
  32. new_alpha = alpha + randn() * step_size
  33. # check the bounds of alpha
  34. if new_alpha < 0.0:
  35. new_alpha = 0.0
  36. # return the new configuration
  37. return [new_eta, new_alpha]
  38. # hill climbing local search algorithm
  39. def hillclimbing(X, y, objective, n_iter, step_size):
  40. # starting point for the search
  41. solution = [rand(), rand()]
  42. # evaluate the initial point
  43. solution_eval = objective(X, y, solution)
  44. # run the hill climb
  45. for i in range(n_iter):
  46. # take a step
  47. candidate = step(solution, step_size)
  48. # evaluate candidate point
  49. candidte_eval = objective(X, y, candidate)
  50. # check if we should keep the new point
  51. if candidte_eval >= solution_eval:
  52. # store the new point
  53. solution, solution_eval = candidate, candidte_eval
  54. # report progress
  55. print('>%d, cfg=%s %.5f' % (i, solution, solution_eval))
  56. return [solution, solution_eval]
  57. # define dataset
  58. X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
  59. # define the total iterations
  60. n_iter = 100
  61. # step size in the search space
  62. step_size = 0.1
  63. # perform the hill climbing search
  64. cfg, score = hillclimbing(X, y, objective, n_iter, step_size)
  65. print('Done!')
  66. print('cfg=%s: Mean Accuracy: %f' % (cfg, score))

运行示例将在每次搜索过程中看到改进时报告配置和结果。运行结束时,将报告最佳配置和结果。

注意:由于算法或评估程序的随机性,或者数值精度的差异,您的结果可能会有所不同。考虑运行该示例几次并比较平均结果。

在这种情况下,我们可以看到,最好的结果涉及在1.004处使用略高于1的学习率和约0.002的正则化权重,从而获得约79.1%的平均准确度,比默认配置好于约78.5%的准确度 。

  1. >0, cfg=[0.5827274503894747, 0.260872709578015] 0.70533
  2. >4, cfg=[0.5449820307807399, 0.3017271170801444] 0.70567
  3. >6, cfg=[0.6286475606495414, 0.17499090243915086] 0.71933
  4. >7, cfg=[0.5956196828965779, 0.0] 0.78633
  5. >8, cfg=[0.5878361167354715, 0.0] 0.78633
  6. >10, cfg=[0.6353507984485595, 0.0] 0.78633
  7. >13, cfg=[0.5690530537610675, 0.0] 0.78633
  8. >17, cfg=[0.6650936023999641, 0.0] 0.78633
  9. >22, cfg=[0.9070451625704087, 0.0] 0.78633
  10. >23, cfg=[0.9253366187387938, 0.0] 0.78633
  11. >26, cfg=[0.9966143540220266, 0.0] 0.78633
  12. >31, cfg=[1.0048613895650054, 0.002162219228449132] 0.79133
  13. Done!
  14. cfg=[1.0048613895650054, 0.002162219228449132]: Mean Accuracy: 0.791333

既然我们已经熟悉了如何使用随机爬山算法来调整简单的机器学习算法的超参数,那么让我们来看看如何调整更高级的算法,例如 XGBoost 。

XGBoost超参数优化

XGBoost 是 Extreme Gradient Boosting 的缩写,是随机梯度提升机器学习算法的有效实现。随机梯度增强算法(也称为梯度增强机或树增强)是一种功能强大的机器学习技术,可在各种具有挑战性的机器学习问题上表现出色,甚至表现最佳。首先,必须安装XGBoost库。您可以使用pip安装它,如下所示:

  1. sudo pip install xgboost

一旦安装,您可以通过运行以下代码来确认它已成功安装,并且您正在使用现代版本:

  1. # xgboost
  2. import xgboost
  3. print("xgboost", xgboost.__version__)

运行代码,您应该看到以下版本号或更高版本

  1. xgboost 1.0.1

尽管XGBoost库具有自己的 Python API,但我们可以通过 XGBClassifier 包装器类将 XGBoost 模型与 scikit-learn API 结合使用。可以实例化模型的实例,就像将其用于模型评估的任何其他 scikit-learn 类一样使用。例如:

  1. # define model
  2. model = XGBClassifier()

在调整 XGBoost 的超参数之前,我们可以使用默认的超参数建立性能基准。我们将使用与上一节相同的合成二进制分类数据集,并使用重复分层k折交叉验证的相同测试工具。下面列出了使用默认超参数评估 XGBoost 性能的完整示例。

  1. # xgboost with default hyperparameters for binary classification
  2. from numpy import mean
  3. from numpy import std
  4. from sklearn.datasets import make_classification
  5. from sklearn.model_selection import cross_val_score
  6. from sklearn.model_selection import RepeatedStratifiedKFold
  7. from xgboost import XGBClassifier
  8. # define dataset
  9. X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
  10. # define model
  11. model = XGBClassifier()
  12. # define evaluation procedure
  13. cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
  14. # evaluate model
  15. scores = cross_val_score(model, X, y, scoring='accuracy', cvcv=cv, n_jobs=-1)
  16. # report result
  17. print('Mean Accuracy: %.3f (%.3f)' % (mean(scores), std(scores)))

通过运行示例,可以评估模型并报告分类精度的平均值和标准偏差。

注意:由于算法或评估程序的随机性,或者数值精度的差异,您的结果可能会有所不同。考虑运行该示例几次并比较平均结果。在这种情况下,我们可以看到具有默认超参数的模型实现了约84.9%的分类精度。我们希望通过优化的超参数可以实现比此更好的性能。

  1. Mean Accuracy: 0.849 (0.040)

接下来,我们可以采用随机爬山优化算法来调整 XGBoost 模型的超参数。我们可能要针对 XGBoost 模型优化许多超参数。

有关如何调优 XGBoost 模型的概述,请参见教程:

如何配置梯度提升算法

https://machinelearningmastery.com/configure-gradient-boosting-algorithm/

我们将关注四个关键的超参数。他们是:

  • 学习率(learning_rate)
  • 树数(n_estimators)
  • 子样本百分比(子样本)
  • 树深(最大深度)

学习速度控制着每棵树对整体的贡献。明智的值应小于1.0,而应稍高于0.0(例如1e-8)。树木的数量控制着合奏的大小,通常,越多的树木越好,以至于收益递减。合理的值在1棵树与数百或数千棵树之间。子样本百分比定义用于训练每棵树的随机样本大小,定义为原始数据集大小的百分比。值介于略高于0.0(例如1e-8)和1.0的值之间树的深度是每棵树中的级别数。较深的树更特定于训练数据集,并且可能过度拟合。较短的树通常可以更好地概括。明智的值是1到10或20之间。首先,我们必须更新Objective()函数以解包XGBoost模型的超参数,对其进行配置,然后评估平均分类精度。

  1. # objective function
  2. def objective(X, y, cfg):
  3. # unpack config
  4. lrate, n_tree, subsam, depth = cfg
  5. # define model
  6. model = XGBClassifier(learning_rate=lrate, n_estimators=n_tree, subsamsubsample=subsam, max_depth=depth)
  7. # define evaluation procedure
  8. cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
  9. # evaluate model
  10. scores = cross_val_score(model, X, y, scoring='accuracy', cvcv=cv, n_jobs=-1)
  11. # calculate mean accuracy
  12. result = mean(scores)
  13. return result

接下来,我们需要定义用于在搜索空间中迈出一步的step()函数。

每个超参数的范围都非常不同,因此,我们将分别为每个超参数定义步长(分布的标准偏差)。为了使事情保持简单,我们还将在线定义步长,而不是将其定义为函数的参数。

树的数量和深度是整数,因此步进值是四舍五入的。选定的步长是任意的,是在经过反复试验后选择的。下面列出了更新的步进功能。

  1. # take a step in the search space
  2. def step(cfg):
  3. # unpack config
  4. lrate, n_tree, subsam, depth = cfg
  5. # learning rate
  6. lratelrate = lrate + randn() * 0.01
  7. if lrate <= 0.0:
  8. lrate = 1e-8
  9. if lrate > 1:
  10. lrate = 1.0
  11. # number of trees
  12. n_tree = round(n_tree + randn() * 50)
  13. if n_tree <= 0.0:
  14. n_tree = 1
  15. # subsample percentage
  16. subsamsubsam = subsam + randn() * 0.1
  17. if subsam <= 0.0:
  18. subsam = 1e-8
  19. if subsam > 1:
  20. subsam = 1.0
  21. # max tree depth
  22. depth = round(depth + randn() * 7)
  23. if depth <= 1:
  24. depth = 1
  25. # return new config
  26. return [lrate, n_tree, subsam, depth]

最后,必须更新hillclimbing()算法,以定义具有适当值的初始解。在这种情况下,我们将使用合理的默认值,匹配默认的超参数或接近它们来定义初始解决方案。

  1. # starting point for the search
  2. solution = step([0.1, 100, 1.0, 7])

结合在一起,下面列出了使用随机爬山算法手动调整 XGBoost 算法的超参数的完整示例。

  1. # xgboost manual hyperparameter optimization for binary classification
  2. from numpy import mean
  3. from numpy.random import randn
  4. from numpy.random import rand
  5. from numpy.random import randint
  6. from sklearn.datasets import make_classification
  7. from sklearn.model_selection import cross_val_score
  8. from sklearn.model_selection import RepeatedStratifiedKFold
  9. from xgboost import XGBClassifier
  10. # objective function
  11. def objective(X, y, cfg):
  12. # unpack config
  13. lrate, n_tree, subsam, depth = cfg
  14. # define model
  15. model = XGBClassifier(learning_rate=lrate, n_estimators=n_tree, subsamsubsample=subsam, max_depth=depth)
  16. # define evaluation procedure
  17. cv = RepeatedStratifiedKFold(n_splits=10, n_repeats=3, random_state=1)
  18. # evaluate model
  19. scores = cross_val_score(model, X, y, scoring='accuracy', cvcv=cv, n_jobs=-1)
  20. # calculate mean accuracy
  21. result = mean(scores)
  22. return result
  23. # take a step in the search space
  24. def step(cfg):
  25. # unpack config
  26. lrate, n_tree, subsam, depth = cfg
  27. # learning rate
  28. lratelrate = lrate + randn() * 0.01
  29. if lrate <= 0.0:
  30. lrate = 1e-8
  31. if lrate > 1:
  32. lrate = 1.0
  33. # number of trees
  34. n_tree = round(n_tree + randn() * 50)
  35. if n_tree <= 0.0:
  36. n_tree = 1
  37. # subsample percentage
  38. subsamsubsam = subsam + randn() * 0.1
  39. if subsam <= 0.0:
  40. subsam = 1e-8
  41. if subsam > 1:
  42. subsam = 1.0
  43. # max tree depth
  44. depth = round(depth + randn() * 7)
  45. if depth <= 1:
  46. depth = 1
  47. # return new config
  48. return [lrate, n_tree, subsam, depth]
  49. # hill climbing local search algorithm
  50. def hillclimbing(X, y, objective, n_iter):
  51. # starting point for the search
  52. solution = step([0.1, 100, 1.0, 7])
  53. # evaluate the initial point
  54. solution_eval = objective(X, y, solution)
  55. # run the hill climb
  56. for i in range(n_iter):
  57. # take a step
  58. candidate = step(solution)
  59. # evaluate candidate point
  60. candidte_eval = objective(X, y, candidate)
  61. # check if we should keep the new point
  62. if candidte_eval >= solution_eval:
  63. # store the new point
  64. solution, solution_eval = candidate, candidte_eval
  65. # report progress
  66. print('>%d, cfg=[%s] %.5f' % (i, solution, solution_eval))
  67. return [solution, solution_eval]
  68. # define dataset
  69. X, y = make_classification(n_samples=1000, n_features=5, n_informative=2, n_redundant=1, random_state=1)
  70. # define the total iterations
  71. n_iter = 200
  72. # perform the hill climbing search
  73. cfg, score = hillclimbing(X, y, objective, n_iter)
  74. print('Done!')
  75. print('cfg=[%s]: Mean Accuracy: %f' % (cfg, score))

运行示例将在每次搜索过程中看到改进时报告配置和结果。运行结束时,将报告最佳配置和结果。

注意:由于算法或评估程序的随机性,或者数值精度的差异,您的结果可能会有所不同。考虑运行该示例几次并比较平均结果。

在这种情况下,我们可以看到最好的结果涉及使用大约0.02的学习率,52棵树,大约50%的子采样率以及53个级别的较大深度。此配置产生的平均准确度约为87.3%,优于默认配置的平均准确度约为84.9%。

  1. >0, cfg=[[0.1058242692126418, 67, 0.9228490731610172, 12]] 0.85933
  2. >1, cfg=[[0.11060813799692253, 51, 0.859353656735739, 13]] 0.86100
  3. >4, cfg=[[0.11890247679234153, 58, 0.7135275461723894, 12]] 0.86167
  4. >5, cfg=[[0.10226257987735601, 61, 0.6086462443373852, 17]] 0.86400
  5. >15, cfg=[[0.11176962034280596, 106, 0.5592742266405146, 13]] 0.86500
  6. >19, cfg=[[0.09493587069112454, 153, 0.5049124222437619, 34]] 0.86533
  7. >23, cfg=[[0.08516531024154426, 88, 0.5895201311518876, 31]] 0.86733
  8. >46, cfg=[[0.10092590898175327, 32, 0.5982811365027455, 30]] 0.86867
  9. >75, cfg=[[0.099469211050998, 20, 0.36372573610040404, 32]] 0.86900
  10. >96, cfg=[[0.09021536590375884, 38, 0.4725379807796971, 20]] 0.86900
  11. >100, cfg=[[0.08979482274655906, 65, 0.3697395430835758, 14]] 0.87000
  12. >110, cfg=[[0.06792737273465625, 89, 0.33827505722318224, 17]] 0.87000
  13. >118, cfg=[[0.05544969684589669, 72, 0.2989721608535262, 23]] 0.87200
  14. >122, cfg=[[0.050102976159097, 128, 0.2043203965148931, 24]] 0.87200
  15. >123, cfg=[[0.031493266763680444, 120, 0.2998819062922256, 30]] 0.87333
  16. >128, cfg=[[0.023324201169625292, 84, 0.4017169945431015, 42]] 0.87333
  17. >140, cfg=[[0.020224220443108752, 52, 0.5088096815056933, 53]] 0.87367
  18. Done!
  19. cfg=[[0.020224220443108752, 52, 0.5088096815056933, 53]]: Mean Accuracy: 0.873667

5分钟掌握手动优化机器学习模型超参数相关推荐

  1. 使用TPOT自动选择scikit-learn机器学习模型和参数

    声明:原文地址:使用TPOT自动选择scikit-learn机器学习模型和参数,此文是本人学习原文的结果,略有改动.侵删. 在上一篇博客中我们在anacoda中安装了tpot: anacoda下安装T ...

  2. 机器学习之超参数优化 - 网格优化方法(随机网格搜索)

    机器学习之超参数优化 - 网格优化方法(随机网格搜索) 在讲解网格搜索时我们提到,伴随着数据和模型的复杂度提升,网格搜索所需要的时间急剧增加.以随机森林算法为例,如果使用过万的数据,搜索时间则会立刻上 ...

  3. AWS 开源 SageMaker,帮助开发人员优化机器学习模型

    开发四年只会写业务代码,分布式高并发都不会还做程序员? >>>   Amazon WebServices 已经发布了来自其 SageMaker Neo 机器学习的相关代码,Neo-A ...

  4. 第七十四篇:机器学习优化方法及超参数设置综述

    第七十四篇:机器学习优化方法及超参数设置综述 置顶 2019-08-25 23:03:44 廖佳才 阅读数 207更多 分类专栏: 深度学习 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-S ...

  5. 机器学习之超参数优化 - 网格优化方法(对半网格搜索HalvingSearchCV)

    机器学习之超参数优化 - 网格优化方法(对半网格搜索HalvingSearchCV) 在讲解随机网格搜索之前,我们梳理了决定枚举网格搜索运算速度的因子: 1 参数空间的大小:参数空间越大,需要建模的次 ...

  6. python手动将机器学习模型保存为json文件

    python手动将机器学习模型保存为json文件 # 导入需要的包和库: # Import Required packages #-------------------------# Import t ...

  7. 机器学习中模型参数和模型超参数分别是什么?有什么区别?

    机器学习中模型参数和模型超参数分别是什么?有什么区别? 目录 机器学习中模型参数和模型超参数分别是什么?有什么区别?

  8. 机器学习、超参数、最优超参数、网格搜索、随机搜索、贝叶斯优化、Google Vizier、Adviser

    机器学习.超参数.最优超参数.网格搜索.随机搜索.贝叶斯优化.Google Vizier.Adviser 最优超参数 选择超参数的问题在于,没有放之四海而皆准的超参数. 因此,对于每个新数据集,我们必 ...

  9. 基于Python的随机森林(RF)回归与多种模型超参数自动优化方法

      本文详细介绍基于Python的随机森林(Random Forest)回归算法代码与模型超参数(包括决策树个数与最大深度.最小分离样本数.最小叶子节点样本数.最大分离特征数等等)自动优化代码.    ...

最新文章

  1. 飞机的“黑色十分钟”能被人工智能消灭吗?
  2. java使用Jsch实现远程操作linux服务器进行文件上传、下载,删除和显示目录信息...
  3. 浅析支付系统的整体架构
  4. 2020最新,100道电商大厂必问面试题:附完整答案
  5. HDU-3537 Mock Turtles型翻硬币游戏
  6. 从RDS中获取binlog
  7. 软件设计师10-面向对象-设计模式
  8. 在有空字符串的有序字符串数组中查找(找给定字符串)
  9. ORACLE数据恢复方法(提交事务也可以)
  10. 浅谈ACM算法学习与有效训练
  11. Linux下Hadoop运行mongodb对应的 jar 报错java.lang.NoClassDefFoundError:ClassNotFoundException
  12. 【信息安全】-身份认证技术
  13. poi怎么设置某个单元格为下拉框_java excel 多选下拉列表设置
  14. 移动端跨平台开发的深度解析
  15. 高德地图android 缓存,高德地图定位不刷新,感觉有缓存
  16. linux 内核修改rss,什么是Linux内存管理中的RSS和VSZ
  17. 迅雷下载的资源,文件夹有大小,但是打开没有文件
  18. ClearCommError()函数
  19. 基于Java+SpringBoot+vue+element实现爱心捐赠平台系统
  20. 2021年低压电工考试资料及低压电工模拟试题

热门文章

  1. Windows server 2003 DNS 全攻略(一)
  2. 红包规则_“科普闯关100%夺红包”游戏规则升级了!速速来看!
  3. 分割字符串_[话俾你知]Python使用正则处理字符串技巧(分割、替换)
  4. 排序算法一:选择排序
  5. BIO  三位标注  (B-begin,I-inside,O-outside)
  6. transformer详解 大牛 wmathor
  7. 数据预处理为什么使用独热编码one-hot
  8. 陈键飞:基于随机量化的高效神经网络训练理论及算法
  9. 遥遥无期还是近在咫尺?长文展望「大模型」商业化前景
  10. 蒙特卡洛算法贡献者之一Arianna Rosenbluth逝世 | AI日报