from numpy import genfromtxt from sklearn import linear_model datapath=r"Delivery_Dummy.csv" data = genfromtxt(datapath,delimiter=",") x = data[1:,:-1] y = data[1:,-1] print x print y mlr = linear_model.LinearRegression() mlr.fit(x, y) print mlr print "coef:" print mlr.coef_ print "intercept" print mlr.intercept_ xPredict = [90,2,0,0,1] yPredict = mlr.predict(xPredict) print "predict:" print yPredict
X [[ 100. 4. 0. 1. 0.] [ 50. 3. 1. 0. 0.] [ 100. 4. 0. 1. 0.] [ 100. 2. 0. 0. 1.] [ 50. 2. 0. 0. 1.] [ 80. 2. 0. 1. 0.] [ 75. 3. 0. 1. 0.] [ 65. 4. 1. 0. 0.] [ 90. 3. 1. 0. 0.] [ 90. 2. 0. 0. 1.]] Y [ 9.3 4.8 8.9 6.5 4.2 6.2 7.4 6. 7.6 6.1]