# -*- coding:utf-8 -*-
from numpy import genfromtxt
from sklearn import linear_model
# genfromtxt函數
# genfromtxt函數建立數組表格資料
# genfromtxt主要執行兩個循環運算。第一個循環将檔案的每一行轉換成字元串序列。第二個循環将每個字元串序列轉換為相應的資料類型。
# genfromtxt能夠考慮缺失的資料,但其他更快和更簡單的函數像loadtxt不能考慮缺失值。
# 詳細用法參考:https://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html
# 附加numpy.savetxt該函數能夠将資料存儲為 CSV 格式:https://docs.scipy.org/doc/numpy/reference/generated/numpy.savetxt.html
datapath=r"Delivery_Dummy.csv"
data = genfromtxt(datapath,delimiter=",")
#delimiter: the str used to separate data. 橫縱坐标以 ',' 分割,是以給 delimiter 傳入 ','。delimiter是區分橫縱坐标的
# skip_header: the number of lines to skip at the beginning of the file. 這個參數是跳過表頭資訊的
x = data[:,:-]
y = data[:,-]
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 = [,,,,]
yPredict = mlr.predict(xPredict)
print "predict:"
print yPredict