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

熱線電話:13121318867

登錄
首頁大數(shù)據(jù)時代學(xué)習(xí)曲線--幫你清晰判斷過擬合和欠擬合
學(xué)習(xí)曲線--幫你清晰判斷過擬合和欠擬合
2020-07-09
收藏

前面小編給大家簡單介紹過擬合欠擬合時,提到了一個概念:學(xué)習(xí)曲線,我們通過學(xué)習(xí)曲線能夠很清晰的判別出模型現(xiàn)在說出的狀態(tài)是欠擬合還是過擬合,下面小編具體整理了學(xué)習(xí)曲線的相關(guān)內(nèi)容,希望對大家有所幫助。

學(xué)習(xí)曲線(learning curve)是不同訓(xùn)練集大小,模型在訓(xùn)練集和驗證集上的得分變化曲線。橫坐標為·樣本數(shù),縱坐標為訓(xùn)練和交叉驗證集上的得分(如準確率)。

模型在新數(shù)據(jù)上的表現(xiàn)如何,都能清晰地在展現(xiàn)在學(xué)習(xí)去線上,我們也能通過這些表現(xiàn),進而判斷模型是否方差偏高或者偏差過高,以及增大訓(xùn)練集是否可以減小過擬合。

如圖所示:

(1)當訓(xùn)練集和測試集的誤差收斂但卻很高時,為高偏差。

左上圖中訓(xùn)練集和驗證集上的曲線能夠收斂,但偏差很高,訓(xùn)練集和驗證集上準確率相差很大,卻都很差。這種情況下模型對已知數(shù)據(jù)和未知數(shù)據(jù)都不能進行準確的預(yù)測,很可能是欠擬合。

方法:

增加模型參數(shù),采用更復(fù)雜的模型,減小正則項。

注意:此時通過增加數(shù)據(jù)量是不起作用的。

(2)當訓(xùn)練集和測試集上誤差之間有大的差距時,為高方差。

當訓(xùn)練集的準確率比其他獨立數(shù)據(jù)集上的測試結(jié)果的準確率要高時,一般都是過擬合。

右上圖中,訓(xùn)練集和驗證集的準確率差距很大,這種情況下,模型能夠很好的擬合已知數(shù)據(jù),但是泛化能力不足,屬于高方差,很可能是過擬合

方法:

增大訓(xùn)練集,降低模型復(fù)雜度,增大正則項,或者通過特征選擇減少特征數(shù)。

(3)右下方圖,也是最理想情況:找到偏差和方差都很小的狀態(tài),就是收斂而且誤差較小。

學(xué)習(xí)曲線的具體操作:

len(X_train) 個訓(xùn)練樣本,訓(xùn)練出 len(X_train) 個模型,第一次使用一個樣本訓(xùn)練出第一個模型,第二次使用兩個樣本訓(xùn)練出第二個模型,… ,第 len(X_train) 次使用 len(X_train) 個樣本訓(xùn)練出最后一個模型;

每個模型對于訓(xùn)練這個模型所使用的部分訓(xùn)練數(shù)據(jù)集的預(yù)測值:y_train_predict = 模型.predict(X_train[ : i ]);

每個模型對于訓(xùn)練這個模型所使用的部分訓(xùn)練數(shù)據(jù)集的均方誤差:mean_squared_error(y_train[ : i ], y_train_predict);

每個模型對于整個測試數(shù)據(jù)集的預(yù)測值:y_test_predict = 模型.predict(X_test)

每個模型對于整個測試數(shù)據(jù)集的預(yù)測的均方誤差:mean_squared_error(y_test, y_test_predict);

繪制每次訓(xùn)練模型所用的樣本數(shù)量與該模型對應(yīng)的部分訓(xùn)練數(shù)據(jù)集的均方誤差的平方根的關(guān)系曲線:plt.plot([i for i in range(1. len(X_train)+1)],np.sqrt(train_score), label=“train”)

繪制每次訓(xùn)練模型所用的樣本數(shù)量與該模型對應(yīng)的測試數(shù)據(jù)集的預(yù)測的均方誤差的關(guān)系曲線:plt.plot([i for i in range(1. len(X_train)+1)],np.sqrt(test_score), label=“test”)

數(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(), // 加隨機數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個參數(shù)驗證碼對象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺檢測極驗服務(wù)器是否宕機 new_captcha: data.new_captcha, // 用于宕機時表示是新驗證碼的宕機 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){ //倒計時完成 $(".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); }