← 返回题库
中级

多元OLS回归工资方程

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    import pandas as pd
    import matplotlib.pyplot as plt
    from sklearn.linear_model import LinearRegression
    import numpy as np
    url = '____'
    df = pd.read_csv(____)
    X = df[['____','____','____']]
    mod = LinearRegression().fit(____)
    for c,b in zip(____): print(____)
    print(____)
    print(____)
    y_pred = mod.predict(____)
    plt.figure(figsize=(____,____))
    plt.subplot(____,____,____)
    plt.scatter(____)
    plt.plot([df['____'].min(), df['____'].max()], [df['____'].min(), df['____'].max()], '____', label='____')
    plt.xlabel(____); plt.ylabel(____); plt.title(____); plt.legend()
    df['____'] = np.log(____)
    mod = LinearRegression().fit(____)
    print(____)
    print(____)
    plt.subplot(____,____,____)
    plt.scatter(____)
    x_line = np.linspace(df['____'].min(), df['____'].max(), ____)
    plt.plot(x_line, mod.predict(x_line.reshape(____)), '____', lw=____, label='____')
    plt.xlabel(____); plt.ylabel(____); plt.title(____); plt.legend()
    plt.tight_layout(); plt.show()

示例

输入
solve()
期望输出
educ=0.0631,exper=0.0451,tenure=0.0308
截距=2.8789,R²=0.3384
控制其他变量,教育年限每+1年工资+0.0631美元
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码