scikit-learn中LibSVM与LibSVM的区别

时间:2016-05-17 13:28:05

标签: machine-learning scikit-learn svm libsvm

我在scikit-learn中使用LibSVM(grid.py)和LibSVM运行网格搜索,但在示例文件上收到了不同的结果" heart_scale"

我的scikit-learn代码

from sklearn.datasets import load_svmlight_file
from sklearn.svm import SVC
from sklearn.grid_search import GridSearchCV

data = load_svmlight_file("heart_scale")
(X, y) = (data[0].toarray(), data[1])

# Using the same ranges for C and gamma as default in LibSVM grid.py
gamma_range = np.logspace(3, -15, 10, base=2)
C_range = np.logspace(-5, 15, 11, base=2)

tuned_parameters = [{'kernel': ['rbf'], 'gamma': gamma_range ,
                         'C': C_range}]
grid = GridSearchCV(SVC(), tuned_parameters, cv=5)
grid.fit(X, y)

print("Best parameters set found on development set:")
print(grid.best_params_)
print("The best parameters are %s with a score of %0.2f"
          % (grid.best_params_, grid.best_score_))

输出

Best parameters set found on development set:
{'kernel': 'rbf', 'C': 2.0, 'gamma': 0.0078125}
The best parameters are {'kernel': 'rbf', 'C': 2.0, 'gamma': 0.0078125} with a score of 0.84

LIBSVM

python grid.py heart_scale

输出

2048.0 0.0001220703125 84.4444

有人能告诉我如何在scikit-learn中使用LibSVM实现与LibSVM相同的结果吗?

0 个答案:

没有答案