Python Multiple Linear Regression using OLS code with specific data?

前端 未结 3 1972
情歌与酒
情歌与酒 2020-12-15 12:40

I am using the ols.py code downloaded at scipy Cookbook (the download is in the first paragraph with the bold OLS) but I need to understand rather than using ra

3条回答
  •  再見小時候
    2020-12-15 13:23

    the ols function takes the entire independent data set as the second argument. Try

    m = ols(y, [x1, x2, x3], ...)
    

    though I suspect you may need to wrap it in numpy arrays:

    x = numpy.ndarray([3, len(x1)])
    x[0] = numpy.array(x1)
    x[1] = numpy.array(x2)
    x[2] = numpy.array(x3)
    m = ols(y, x, ...)
    

提交回复
热议问题