初级
Auto数据集多元线性回归
未完成
初级参考
完整示例代码供参考,建议自己理解后重新输入
import pandas as pd
import statsmodels.formula.api as smf
auto = pd.read_csv('https://liangdaima.com/static/data/statistics/Auto.csv')
auto['horsepower'] = pd.to_numeric(auto['horsepower'], errors='coerce')
auto = auto.dropna()
model = smf.ols('mpg ~ horsepower + weight + acceleration', data=auto).fit()
print('R-squared:', model.rsquared)
print('回归系数:')
print(model.params)
示例
输入
solve()
期望输出
R-squared: 0.7063754859981903 回归系数: Intercept 45.678293 horsepower -0.047496 weight -0.005789 acceleration -0.002066 dtype: float64
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199