中级
绘制LDA决策边界
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
import matplotlib
matplotlib.use(____)
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
iris = load_iris()
X = iris.data[:, :____]
y = (____).astype(____)
scaler = StandardScaler()
X_s = scaler.fit_transform(____)
x_min, x_max = X_s[:, ____].min() - ____, X_s[:, ____].max() + ____
y_min, y_max = X_s[:, ____].min() - ____, X_s[:, ____].max() + ____
xx, yy = np.meshgrid(np.arange(____), np.arange(____))
model = LogisticRegression(____).fit(____)
Z = model.predict(np.c_[xx.ravel(), yy.ravel()]).reshape(____)
plt.contourf(____)
plt.scatter(____)
plt.title(____)
plt.tight_layout()
plt.show()
print(len(np.unique(____)))
示例
输入
solve()
期望输出
2
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199