簡體   English   中英

使用 SVM 對 5 維數據集進行分類的示例?

[英]An example of classifying a 5 dimensional dataset using SVM?

我試圖在網上找到一個但失敗了。 5D 數據集是一個像這樣的列表列表

[[0,0,0,1,0],
 [0,0.5,0.5,0,0],
 [0,0.33333,0.33333,0.33333,0],
 [1,0,0,0,0],
 ......]

謝謝。

你能提供你的完整數據和標簽嗎? 有了所需的數據,您的答案將在不到一分鍾的時間內准備好。

# importing numpy and SVC from svm
import numpy as np
from sklearn.svm import SVC

# Example data and labels (you can replace with your data and lables).
X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])
y = np.array([1, 1, 2, 2])

# Building SVM model
clf = SVC(gamma='auto')

# Training Model
clf.fit(X, y)

# predicting with above mode(you can replace with your test data that have 5 dimesion).
print(clf.predict([[-0.8, -1]]))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM