不大懂怎么办

来源:1-1 课程背景

慕无忌401737

2018-04-08 15:19

我看了一点,但是不是很明白

写回答 关注

1回答

  • qq_不忘初心_206
    2018-04-08 16:56:00

    import numpy as np 

    from numpy.linalg import inv

    from numpy import dot

    from numpy import mat

    import pandas as pd 


    dataset = pd.read_csv('data.csv')

    print(dataset)


    temp = dataset.iloc[:,2:5] #iloc :对数组进行切片


    # X = mat([1,2,3]).reshape(3,1)

    # Y = 2*X

    # # theta = (X'X)^-1X'Y

    # #theta = dot(dot(inv(dot(X.T,X)), X.T),T)

    # #theta = theta - alpha*(theta*X-Y)*X


    # theta = 1.

    # alpha = 0.1

    # for i in range(100):

    # theta = theta + np.sum(alpha *(Y - dot(X,theta))*X.reshape(1,3))/3.#加权平均


    # print(theta


Python实现线性回归

掌握python进行线性回归分析的原理及编程实践

26151 学习 · 36 问题

查看课程

相似问题