sklearn系列之 sklearn.svm.SVC詳解

首先咱們應該對SVM的參數有一個詳細的認知:算法

  sklearn.svm.SVC 參數說明:緩存

  

自己這個函數也是基於libsvm實現的,因此在參數設置上有不少類似的地方。(PS: libsvm中的二次規劃問題的解決算法是SMO)。
sklearn.svm.SVC(C=1.0, kernel='rbf', degree=3, gamma='auto', coef0=0.0, shrinking=True, probability=False,

tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape=None,random_state=None)

參數:

l  C:C-SVC的懲罰參數C?默認值是1.0

C越大,至關於懲罰鬆弛變量,但願鬆弛變量接近0,即對誤分類的懲罰增大,趨向於對訓練集全分對的狀況,這樣對訓練集測試時準確率很高,但泛化能力弱。C值小,對誤分類的懲罰減少,容許容錯,將他們當成噪聲點,泛化能力較強。

l  kernel :核函數,默認是rbf,能夠是‘linear’, ‘poly’, ‘rbf’, ‘sigmoid’, ‘precomputed’ 

    0 – 線性:u'v

    1 – 多項式:(gamma*u'*v + coef0)^degree

    2 – RBF函數:exp(-gamma|u-v|^2)

    3 –sigmoid:tanh(gamma*u'*v + coef0)

l  degree :多項式poly函數的維度,默認是3,選擇其餘核函數時會被忽略。

l  gamma : ‘rbf’,‘poly’ 和‘sigmoid’的核函數參數。默認是’auto’,則會選擇1/n_features

l  coef0 :核函數的常數項。對於‘poly’和 ‘sigmoid’有用。

l  probability :是否採用機率估計?.默認爲False

l  shrinking :是否採用shrinking heuristic方法,默認爲true

l  tol :中止訓練的偏差值大小,默認爲1e-3

l  cache_size :核函數cache緩存大小,默認爲200

l  class_weight :類別的權重,字典形式傳遞。設置第幾類的參數C爲weight*C(C-SVC中的C)

l  verbose :容許冗餘輸出?

l  max_iter :最大迭代次數。-1爲無限制。

l  decision_function_shape :‘ovo’, ‘ovr’ or None, default=None3

l  random_state :數據洗牌時的種子值,int值

主要調節的參數有:C、kernel、degree、gamma、coef0。

 

自己這個函數也是基於libsvm實現的,因此在參數設置上有不少類似的地方。(PS: libsvm中的二次規劃問題的解決算法是SMO)。
sklearn.svm.SVC(C=1.0kernel='rbf'degree=3gamma='auto'coef0=0.0shrinking=Trueprobability=False,dom

tol=0.001cache_size=200class_weight=Noneverbose=Falsemax_iter=-1decision_function_shape=None,random_state=None)函數

參數:測試

 

l  C:C-SVC的懲罰參數C?默認值是1.0spa

C越大,至關於懲罰鬆弛變量,但願鬆弛變量接近0,即對誤分類的懲罰增大,趨向於對訓練集全分對的狀況,這樣對訓練集測試時準確率很高,但泛化能力弱。C值小,對誤分類的懲罰減少,容許容錯,將他們當成噪聲點,泛化能力較強。code

l  kernel :核函數,默認是rbf,能夠是‘linear’, ‘poly’, ‘rbf’, ‘sigmoid’, ‘precomputed’ blog

    0 – 線性:u'vci

    1 – 多項式:(gamma*u'*v + coef0)^degreeit

    2 – RBF函數:exp(-gamma|u-v|^2)

    3 –sigmoid:tanh(gamma*u'*v + coef0)

l  degree :多項式poly函數的維度,默認是3,選擇其餘核函數時會被忽略。

l  gamma : ‘rbf’,‘poly’ 和‘sigmoid’的核函數參數。默認是’auto’,則會選擇1/n_features

l  coef0 :核函數的常數項。對於‘poly’和 ‘sigmoid’有用。

l  probability 是否採用機率估計?.默認爲False

l  shrinking :是否採用shrinking heuristic方法,默認爲true

l  tol 中止訓練的偏差值大小,默認爲1e-3

l  cache_size :核函數cache緩存大小,默認爲200

l  class_weight :類別的權重,字典形式傳遞。設置第幾類的參數Cweight*C(C-SVC中的C)

l  verbose :容許冗餘輸出?

l  max_iter :最大迭代次數。-1爲無限制。

l  decision_function_shape ‘ovo’, ‘ovr’ or None, default=None3

l  random_state :數據洗牌時的種子值,int

主要調節的參數有:C、kernel、degree、gamma、coef0。

相關文章
相關標籤/搜索