99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
首頁大數(shù)據(jù)時(shí)代SVC,NuSVC,LinearSVC有什么區(qū)別
SVC,NuSVC,LinearSVC有什么區(qū)別
2020-07-03
收藏

相信大家在機(jī)器學(xué)習(xí)中,一定常見到;SVC,NvSVC,LinearSVC,今天我們就來看看這三者的區(qū)別。

SVC(C-Support Vector Classification):

支持向量分類,基于libsvm實(shí)現(xiàn)的,數(shù)據(jù)擬合的時(shí)間復(fù)雜度是數(shù)據(jù)樣本的二次方,這使得他很難擴(kuò)展到10000個(gè)數(shù)據(jù)集,當(dāng)輸入是多類別時(shí)(SVM最初是處理二分類問題的),通過一對一的方案解決,例如:

SVC參數(shù)解釋
(1)C: 目標(biāo)函數(shù)的懲罰系數(shù)C,用來平衡分類間隔margin和錯(cuò)分樣本的,default C = 1.0;
(2)kernel:參數(shù)選擇有RBF, Linear, Poly, Sigmoid, 默認(rèn)的是"RBF";
(3)degree:if you choose 'Poly' in param 2, this is effective, degree決定了多項(xiàng)式的最高次冪;
(4)gamma:核函數(shù)的系數(shù)('Poly', 'RBF' and 'Sigmoid'), 默認(rèn)是gamma = 1 / n_features;
(5)coef0:核函數(shù)中的獨(dú)立項(xiàng),'RBF' and 'Poly'有效;
(6)probablity: 可能性估計(jì)是否使用(true or false);
(7)shrinking:是否進(jìn)行啟發(fā)式;
(8)tol(default = 1e - 3): svm結(jié)束標(biāo)準(zhǔn)的精度;
(9)cache_size: 制定訓(xùn)練所需要的內(nèi)存(以MB為單位);
(10)class_weight: 每個(gè)類所占據(jù)的權(quán)重,不同的類設(shè)置不同的懲罰參數(shù)C, 缺省的話自適應(yīng);
(11)verbose: 跟多線程有關(guān),不大明白啥意思具體;
(12)max_iter: 最大迭代次數(shù),default = 1, if max_iter = -1, no limited;
(13)decision_function_shape : ‘ovo’ 一對一, ‘ovr’ 多對多  or None 無, default=None
(14)random_state :用于概率估計(jì)的數(shù)據(jù)重排時(shí)的偽隨機(jī)數(shù)生成器的種子。
 ps:7,8,9一般不考慮。
 
from sklearn.svm import SVC
import numpy as np
X= np.array([[-1,-1],[-2,-1],[1,1],[2,1]])
y = np.array([1,1,2,2])
 
clf = SVC()
clf.fit(X,y)
print clf.fit(X,y)
print clf.predict([[-0.8,-1]])

NuSVC(Nu-Support Vector Classification.):

核支持向量分類,和SVC類似,也是基于libsvm實(shí)現(xiàn)的,但不同的是通過一個(gè)參數(shù)空值支持向量的個(gè)數(shù)

NuSVC參數(shù)
nu:訓(xùn)練誤差的一個(gè)上界和支持向量的分?jǐn)?shù)的下界。應(yīng)在間隔(0,1 ]。
其余同SVC
'''
import numpy as np
X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])
y = np.array([1, 1, 2, 2])
from sklearn.svm import NuSVC
clf = NuSVC()
clf.fit(X, y) 
print clf.fit(X,y)
print(clf.predict([[-0.8, -1]]))

LinearSVC(Linear Support Vector Classification):

線性支持向量分類,類似于SVC,但是其使用的核函數(shù)是”linear“上邊介紹的兩種是按照brf(徑向基函數(shù)計(jì)算的,其實(shí)現(xiàn)也不是基于LIBSVM,所以它具有更大的靈活性在選擇處罰和損失函數(shù)時(shí),而且可以適應(yīng)更大的數(shù)據(jù)集,它支持密集和稀疏的輸入是通過一對一的方式解決的

LinearSVC 參數(shù)解釋
C:目標(biāo)函數(shù)的懲罰系數(shù)C,用來平衡分類間隔margin和錯(cuò)分樣本的,default C = 1.0;
loss :指定損失函數(shù)
penalty :
dual :選擇算法來解決對偶或原始優(yōu)化問題。當(dāng)n_samples > n_features 時(shí)dual=false。
tol :(default = 1e - 3): svm結(jié)束標(biāo)準(zhǔn)的精度;
multi_class:如果y輸出類別包含多類,用來確定多類策略, ovr表示一對多,“crammer_singer”優(yōu)化所有類別的一個(gè)共同的目標(biāo)
如果選擇“crammer_singer”,損失、懲罰和優(yōu)化將會被被忽略。
fit_intercept :
intercept_scaling :
class_weight :對于每一個(gè)類別i設(shè)置懲罰系數(shù)C = class_weight[i]*C,如果不給出,權(quán)重自動調(diào)整為 n_samples / (n_classes * np.bincount(y))
verbose:跟多線程有關(guān),不大明白啥意思具體
 
from sklearn.svm import LinearSVC
 
X=[[0],[1],[2],[3]]
Y = [0,1,2,3]
 
clf = LinearSVC(decision_function_shape='ovo') #ovo為一對一
clf.fit(X,Y)
print clf.fit(X,Y)
 
dec = clf.decision_function([[1]])    #返回的是樣本距離超平面的距離
print dec
 
clf.decision_function_shape = "ovr"
dec =clf.decision_function([1]) #返回的是樣本距離超平面的距離
print dec
 
#預(yù)測
print clf.predict([1])</span>


數(shù)據(jù)分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數(shù)據(jù)分析師資訊
更多

OK
客服在線
立即咨詢
客服在線
立即咨詢
') } function initGt() { var handler = function (captchaObj) { captchaObj.appendTo('#captcha'); captchaObj.onReady(function () { $("#wait").hide(); }).onSuccess(function(){ $('.getcheckcode').removeClass('dis'); $('.getcheckcode').trigger('click'); }); window.captchaObj = captchaObj; }; $('#captcha').show(); $.ajax({ url: "/login/gtstart?t=" + (new Date()).getTime(), // 加隨機(jī)數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進(jìn)行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個(gè)參數(shù)驗(yàn)證碼對象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個(gè)配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺檢測極驗(yàn)服務(wù)器是否宕機(jī) new_captcha: data.new_captcha, // 用于宕機(jī)時(shí)表示是新驗(yàn)證碼的宕機(jī) product: "float", // 產(chǎn)品形式,包括:float,popup width: "280px", https: true // 更多配置參數(shù)說明請參見:http://docs.geetest.com/install/client/web-front/ }, handler); } }); } function codeCutdown() { if(_wait == 0){ //倒計(jì)時(shí)完成 $(".getcheckcode").removeClass('dis').html("重新獲取"); }else{ $(".getcheckcode").addClass('dis').html("重新獲取("+_wait+"s)"); _wait--; setTimeout(function () { codeCutdown(); },1000); } } function inputValidate(ele,telInput) { var oInput = ele; var inputVal = oInput.val(); var oType = ele.attr('data-type'); var oEtag = $('#etag').val(); var oErr = oInput.closest('.form_box').next('.err_txt'); var empTxt = '請輸入'+oInput.attr('placeholder')+'!'; var errTxt = '請輸入正確的'+oInput.attr('placeholder')+'!'; var pattern; if(inputVal==""){ if(!telInput){ errFun(oErr,empTxt); } return false; }else { switch (oType){ case 'login_mobile': pattern = /^1[3456789]\d{9}$/; if(inputVal.length==11) { $.ajax({ url: '/login/checkmobile', type: "post", dataType: "json", data: { mobile: inputVal, etag: oEtag, page_ur: window.location.href, page_referer: document.referrer }, success: function (data) { } }); } break; case 'login_yzm': pattern = /^\d{6}$/; break; } if(oType=='login_mobile'){ } if(!!validateFun(pattern,inputVal)){ errFun(oErr,'') if(telInput){ $('.getcheckcode').removeClass('dis'); } }else { if(!telInput) { errFun(oErr, errTxt); }else { $('.getcheckcode').addClass('dis'); } return false; } } return true; } function errFun(obj,msg) { obj.html(msg); if(msg==''){ $('.login_submit').removeClass('dis'); }else { $('.login_submit').addClass('dis'); } } function validateFun(pat,val) { return pat.test(val); }