中级
残差诊断
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
from sklearn.datasets import load_diabetes
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
diabetes = load_diabetes()
X_train, X_test, y_train, y_test = train_test_split(____)
model = LinearRegression()
model.fit(____)
y_pred = model.predict(____)
residuals = y_test - y_pred
fig, axes = plt.subplots(____, ____, figsize=(____, ____))
axes[____, ____].scatter(____)
axes[____, ____].axhline(____, color='____', linestyle='____')
axes[____, ____].set_xlabel(____)
axes[____, ____].set_ylabel(____)
axes[____, ____].set_title(____)
axes[____, ____].grid(____)
axes[____, ____].hist(____)
x = np.linspace(residuals.min(), residuals.max(), ____)
axes[____, ____].plot(x, stats.norm.pdf(x, np.mean(____), np.std(____)), '____', linewidth=____)
axes[____, ____].set_xlabel(____)
axes[____, ____].set_title(____)
axes[____, ____].grid(____)
stats.probplot(____)
axes[____, ____].set_title(____)
axes[____, ____].scatter(y_pred, np.abs(____), alpha=____, edgecolor='____')
axes[____, ____].set_xlabel(____)
axes[____, ____].set_ylabel(____)
axes[____, ____].set_title(____)
axes[____, ____].grid(____)
plt.tight_layout()
plt.show()
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199