python - mglearn.plots.plot_2d_separator (eps=0.5) ,那是什么,“eps”?
问题描述
我从《Python 机器学习简介》一书中学习 Python
在书中,使用了下面的函数。
但我不明白参数“X”是如何工作的以及参数“eps”的必要性。
你能帮我吗?
def plot_2d_classification(classifier, X, fill=False, ax=None, eps=None,
alpha=1, cm=cm3):
# multiclass
if eps is None:
eps = X.std() / 2.
if ax is None:
ax = plt.gca()
x_min, x_max = X[:, 0].min() - eps, X[:, 0].max() + eps
y_min, y_max = X[:, 1].min() - eps, X[:, 1].max() + eps
xx = np.linspace(x_min, x_max, 1000)
yy = np.linspace(y_min, y_max, 1000)
X1, X2 = np.meshgrid(xx, yy)
X_grid = np.c_[X1.ravel(), X2.ravel()]
decision_values = classifier.predict(X_grid)
ax.imshow(decision_values.reshape(X1.shape), extent=(x_min, x_max,
y_min, y_max),
aspect='auto', origin='lower', alpha=alpha, cmap=cm)
ax.set_xlim(x_min, x_max)
ax.set_ylim(y_min, y_max)
ax.set_xticks(())
ax.set_yticks(())
解决方案
推荐阅读
- php - 测试返回比预期更多的断言
- ibm-cloud - 如何在 IBM Cloud 上获取 Node-Red IP 地址?
- sqlite - Xamarin Forms Sqlite Android 7+ 支持
- ssh - 我是否必须从 localhost 为 get shell 提供服务?
- php - 使用 laravel 文件系统上传时更改图像大小
- azure - 使用 microsoft flow 将文件从 SharePoint 文件夹复制到 AzureBlob 文件夹
- jenkins - 将变量传递给另一个管道 Jenkins
- reactjs - babel-preset-react-app NODE_ENV 生产 v 测试
- java - 是否可以在运行时从 Java 运行 Xbase 脚本?
- sql - 如何在 Oracle SQL Developer 中执行超过 100 万条插入查询?