网格搜索热图python代码
时间: 2023-03-12 07:12:00 浏览: 174
网格搜索算法(基于Python编程语言实现)
网格搜索热图可以使用Python的 matplotlib 库来实现。下面是一段示例代码:import matplotlib.pyplot as pltimport numpy as npfrom sklearn.datasets import load_digitsdigits = load_digits()from sklearn.model_selection import GridSearchCVparam_grid = {'C': [0.1,1, 10, 100], 'gamma': [1,0.1,0.01,0.001]}grid = GridSearchCV(SVC(),param_grid,refit=True,verbose=2)grid.fit(digits.data,digits.target)grid_predictions = grid.predict(digits.data)plt.scatter(digits.data[:, 0], digits.data[:, 1], c=grid_predictions, s=40, cmap='viridis')plt.show()
阅读全文