我有問題了解X和y如何參考培訓。我有5數字列,即時通訊加載到numpy的陣列如下一個簡單的CSV文件:簡單的numpy數組參考
url = "http://www.xyz/shortDataFinal.data"
# download the file
raw_data = urllib.urlopen(url)
# load the CSV file as a numpy matrix
dataset = np.loadtxt(raw_data, delimiter=",")
print(dataset.shape)
# separate the data from the target attributes
X = dataset[:,0:3] #Does this mean columns 1-4?
y = dataset[:,4] #Is this the 5th column?
我覺得我錯誤地引用我的X值。這是我需要的:
X值參考列1-4和我的y值是最後一列,這是第5。如果我理解正確,我應該像上面所做的那樣,引用數組索引0:3作爲X值,數字4作爲y,但這些值不正確。換句話說,數組返回的值不匹配數據中的值 - 它們被一列(索引)關閉。
你想'0:4'(得到4列)。 – hpaulj