正确的回归模型

时间:2018-10-08 02:25:45

标签: python machine-learning linear-regression

我正在尝试从功能很少的数据集中预测预留次数。功能既是分类的又是连续的。

因变量保留如下所示:我的数据集大小约为917 obs。

const injectedJavaScript: = `
    let currentStep = "login";
    if(currentStep === 'login') {
      document.getElementById('userID').value =  '${
        this.props.username
      }'; document.getElementById('userPassword').value = '${
        this.props.password
      }'; document.getElementById('login').click();
      currentStep = 'agreeToTerms';
    } else if(currentStep === 'agreeToTerms' && window.location.href === "https://www.example.com") {
      currentStep = 'download';
      document.getElementsByClassName('button')[0].click();
    }
    `;


  <WebView
        ignoreSslError={true}
        source={{ uri: "https://www.example.com" }}
        style={{ marginTop: 20, height: 400, width: 400 }}
        injectedJavaScript={injectedJavaScript}
        javaScriptEnabledAndroid={true}
        onError={() => this.webviewError(e)}
        startInLoadingState={true}
        scalesPageToFit={true}
      />

当我绘制因变量的直方图时,我得到了

enter image description here

因此,我使用了对数变换来消除某些偏斜。

array([ 1, 7, 17, 2, 2, 13, 8, 11, 9, 4, 4, 3, 5, 2, 5, 7, 3, 12, 9, 13, 5, 2, 11, 13, 14, 19, 9, 11, 3, 6, 7, 10, 1, 6, 5, 10, 8, 5, 4, 3, 2, 10, 10, 10, 8, 13, 16, 6, 4, 6, 3, 11, 10, 1, 18, 7, 2, 12, 17, 4, 2, 19, 3, 4, 17, 13, 10, 2, 10, 1, 3, 4, 20, 3, 2, 1, 3, 5, 8, 8, 4, 3, 13, 3, 3, 5, 4, 17, 7, 6, 10, 5, 3, 9, 9, 8, 1, 5, 17, 5, 10, 9, 2, 7, 13, 2, 9, 1, 15, 13, 10, 4, 2, 4, 5, 4, 3, 3, 10, 4, 7, 5, 13, 12, 7, 5, 6, 9, 5, 11, 7, 1, 4, 12, 4, 3, 11, 1, 4, 4, 3, 7, 4, 11, 4, 1, 9, 2, 10, 10, 3, 4, 4, 3, 2, 7, 10, 7, 6, 1, 3, 19, 9, 3, 8, 20, 1, 12, 9, 13, 13, 2, 9, 4, 9, 2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3, 6, 6, 18, 3, 10, 11, 10, 5, 6, 11, 4, 6, 7, 9, 13, 1, 14, 14, 13, 4, 3, 8, 5, 7, 14, 13, 13, 12, 8, 11, 12, 9, 8, 9, 4, 5, 4, 7, 5, 2, 3, 1, 7, 2, 1, 13, 5, 19, 9, 6, 9, 7])

现在分布图如下:

enter image description here

某些功能。

y=np.log(df["reservartions"].values)

由于actual_price和Recommended_price具有巨大的相关性,因此我创建了两者的差价,并删除了actual_price和建议价格。

但是运行线性回归或随机森林回归后,我得到的结果都很差,R2均为0.12。

这表明模型显然不能很好地预测和拟合。

我的因变量显然是一个正变量。线性回归还正确吗?我应该使用泊松回归吗?日志转换有意义吗?

0 个答案:

没有答案
相关问题