2016-12-14 44 views
0

我剛剛安裝了LIBSVM並觀看了此YouTube video以瞭解如何訓練和測試數據集。使用LIBSVM運行示例文件

不幸的是我收到以下錯誤:

Can't open input file a1a.train. 

缺少什麼我在這裏?
謝謝

+0

對我來說, 「下面的YouTube視頻」 是不是像一個鏈接兼容的 「http://www.bing.com/videos/search ......?」 – Setop

回答

0

如果你想在Python中訓練SVM,那麼我建議你使用scikit-learn。這是去Python機器學習包內的大量文檔和支持。它也可以通過pipanaconda進行安裝,因此很容易安裝和運行。

Sklearn有一個特定的SVM module,它使用LIBSVM來完成後端工作,而sklearn處理大部分數據。

這是sklearn中的一個不錯的example,用於在python和sklearn中運行您的第一個SVM。

import numpy as np 
from sklearn.svm import SVR 
import matplotlib.pyplot as plt 

# Generate sample data 
X = np.sort(5 * np.random.rand(40, 1), axis=0) 
y = np.sin(X).ravel() 
Add noise to targets 
y[::5] += 3 * (0.5 - np.random.rand(8)) 

# Fit regression model 
svr_rbf = SVR(kernel='rbf', C=1e3, gamma=0.1) 
svr_lin = SVR(kernel='linear', C=1e3) 
svr_poly = SVR(kernel='poly', C=1e3, degree=2) 
y_rbf = svr_rbf.fit(X, y).predict(X) 
y_lin = svr_lin.fit(X, y).predict(X) 
y_poly = svr_poly.fit(X, y).predict(X) 

# look at the results 
lw = 2 
plt.scatter(X, y, color='darkorange', label='data') 
plt.hold('on') 
plt.plot(X, y_rbf, color='navy', lw=lw, label='RBF model') 
plt.plot(X, y_lin, color='c', lw=lw, label='Linear model') 
plt.plot(X, y_poly, color='cornflowerblue', lw=lw, label='Polynomial model') 
plt.xlabel('data') 
plt.ylabel('target') 
plt.title('Support Vector Regression') 
plt.legend() 
plt.show() 

enter image description here