1
我正在實施一個使用python和scikit學習的svm模型。我已經達到的地方,我選擇了,而我的特點,並將它們合併到看起來像這樣一個列表中的點:將列表轉換爲svm輸入
[[17, 14, 14, 7, 14, 14, 14, 7, 14, 14, 1],
[14, 14, 7, 14, 14, 14, 7, 14, 14, 7, 1],
[14, 7, 14, 14, 14, 7, 14, 14, 7, 14, 1],
[7, 14, 14, 14, 7, 14, 14, 7, 14, 7, 1],
[14, 14, 14, 7, 14, 14, 7, 14, 7, 14, 1],
[14, 14, 7, 14, 14, 7, 14, 7, 14, 7, 1],
[14, 7, 14, 14, 7, 14, 7, 14, 7, 13, 1],
[7, 14, 14, 7, 14, 7, 14, 7, 13, 7, 1],
[14, 14, 7, 14, 7, 14, 7, 13, 7, 14, 1],
[14, 7, 14, 7, 14, 7, 13, 7, 14, 10, 1],
[7, 14, 7, 14, 7, 13, 7, 14, 10, 4, 1],
[14, 7, 14, 7, 13, 7, 14, 10, 4, 13, 1],
[7, 14, 7, 13, 7, 14, 10, 4, 13, 13, 1],
[14, 7, 13, 7, 14, 10, 4, 13, 13, 7, 1],
[7, 13, 7, 14, 10, 4, 13, 13, 7, 13, 1],
[13, 7, 14, 10, 4, 13, 13, 7, 13, 3, 1],
[7, 14, 10, 4, 13, 13, 7, 13, 3, 13, 1],
[14, 10, 4, 13, 13, 7, 13, 3, 13, 13, 1],
[10, 4, 13, 13, 7, 13, 3, 13, 13, 3, 1],
[4, 13, 13, 7, 13, 3, 13, 13, 3, 13, 0],
[13, 13, 7, 13, 3, 13, 13, 3, 13, 13, 0],
[13, 7, 13, 3, 13, 13, 3, 13, 13, 14, 0]]
在每個元組的最後一個數字是標籤。我試圖找到一種方法來創建一個數據集,可以分離數據和目標以建立一個模型。我在文檔中找不到類似的東西。將它轉回到Dataframe會更容易嗎?
謝謝!
'''import numpy as np''' +'''data = np.array(my_list)'''+'''X = data [:,:-1]'''+'''Y = data [:, -1]如果你對當前表單的描述/假設是真的,就足夠了。這是基本的numpy東西。考慮關於如何處理數組的numpy-docs教程。 – sascha