【问题标题】:What could be the best way to make your SVM faster and reliable?使您的 SVM 更快、更可靠的最佳方法是什么?
【发布时间】:2018-10-30 14:46:40
【问题描述】:

我是数据挖掘的新手。我已经实现了我的线性 SVM,如下所示。

X_train, X_test, y_train, y_test, = train_test_split(X, y, test_size=0.1, random_state = 0)
#print X_train.shape, y_train.shape
#print X_test.shape, y_test.shape

clf = svm.SVC(kernel='linear', C=1).fit(X_train, y_train)
print clf.score(X_test, y_test)

clf = svm.SVC(kernel='linear', C=1)
scores = cross_val_score(clf, X, y, cv=10)
print scores

print("Accuracy: %0.2f (+/- %0.2f)" % (scores.mean(), scores.std()*2 ))

tuned_parameters = [{'kernel': ['rbf'], 'gamma': [1e-3, 1e-4],'C': [1, 10, 100, 1000]},{'kernel': ['linear'], 'C': [1, 10, 100, 1000]}]
scores = ['precision', 'recall']
svr = svm.SVC(C=1)
for score in scores:
    print("# Tuning hyper-parameters for %s"% score)
    clf =GridSearchCV(svr, tuned_parameters, cv=10,scoring='%s_macro'% score)
    clf.fit(X_train, y_train)
    print("best parameters %s" % clf.best_params_)

这里,我的数据太大了,我应该怎么做才能让我的线性支持向量机运行得非常快?

【问题讨论】:

  • 你的数据标准化了吗?

标签: machine-learning scikit-learn classification svm


【解决方案1】:

仅对样本进行参数调整。

一旦你找到好的参数,然后使用整个数据集。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多