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

熱線電話:13121318867

登錄
首頁精彩閱讀數(shù)據(jù)分析之_離群值(Outliers) BoxPlot?_數(shù)據(jù)分析師
數(shù)據(jù)分析之_離群值(Outliers) BoxPlot?_數(shù)據(jù)分析師
2014-11-26
收藏

數(shù)據(jù)分析之_離群值(Outliers) BoxPlot_數(shù)據(jù)分析師


一:什么是Outliers

Outliers是統(tǒng)計學(xué)專業(yè)術(shù)語,是指相比一組數(shù)據(jù)中的其它數(shù)據(jù)的極限值

 

二:極限值意味什么

 1. 決定哪些值是Outliers是一個主觀行為,有一些基準(zhǔn)數(shù)據(jù)來決定是否一個值是一個Outliers,這些基準(zhǔn)是任意選擇的,比如P<=0.5就是一個任意選擇的基準(zhǔn)

2. 一個基準(zhǔn)是用BoxPlot來決定適度離群值(mild Outliers)和極限離群值(extreme Outliers),適度離群值是任何值1.5倍大于基于剩下所有的值的IQR,極限離群值是任何值3倍大于剩下所有的值的IQR,IQRInterquartile Range)代表四分位數(shù)間距,是這些值中的50%中間值,分別是Q1-25%, Median-50%,Q3-75%, IQR=Q3-Q1

 

三:使用Box Plot來發(fā)現(xiàn)Outliers

一個典型的Box Plot是基于以下五個值計算而來的

a. 一組樣本的最小值

b. 一組樣本的最大值

c. 一組樣本的中值

d. 下四分位數(shù)(Lower Quartile / Q1

e. 上四分位數(shù)(Upper Quartile / Q3

根據(jù)這五個值構(gòu)建出來基本的Box Plot,某些圖形軟件還會顯示平均值,IQR= Q3 – Q1

顯然超出上下四分位數(shù)的值可以看做為Outliers。我們通過眼睛就可以很好的觀察到這些Outliers值的點。

box plot 001

 

一個顯示適度和極限Outliers值的Box plot顯示如下:

box plot 002

四:示例說明及JfreeChart的實現(xiàn)

假設(shè)一組數(shù)據(jù)為:2,4,6,8,12,14,16,18,20,25,45

中值 Median = 14

Q1-下四分位數(shù)(11 * 0.25 = 3 = 7

Q3-上四分位數(shù)(11 * 0.75 = 9 =19

IQRQ3 – Q1 = 12

1.5 * IQR = 18

最小值(6 – 1.5 * IQR= 2

最大值(20 + 1.5 * IQR= 25

很顯然值45是一個適度Outliers

對比的一組數(shù)據(jù)為:2,4,6,8,12,14,16,18,20,25,26

 

boxplot 003

 

從圖上可以看出Series0的數(shù)據(jù)存在Outliers,一個紅色三角形已經(jīng)表明

同樣Series1的數(shù)據(jù)是一組非常好的數(shù)據(jù),沒有Outliers.

 

下面是Java源代碼:

package com.dataanalysis.plots; import java.awt.Font; import java.util.ArrayList; import java.util.List; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; public class BoxAndWhiskerDemo extends ApplicationFrame {     /** *   */ private static final long serialVersionUID = -3205574763811416266L;     /**      * Creates a new demo.      *      * @param title  the frame title.      */     public BoxAndWhiskerDemo(final String title) {         super(title);                  final BoxAndWhiskerCategoryDataset dataset = createSampleDataset();         final CategoryAxis xAxis = new CategoryAxis("Type");         final NumberAxis yAxis = new NumberAxis("Value");         yAxis.setAutoRangeIncludesZero(false);         final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();         renderer.setFillBox(false);         renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());         final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);         final JFreeChart chart = new JFreeChart(             "Box-and-Whisker Demo",             new Font("SansSerif", Font.BOLD, 14),             plot,             true         );         final ChartPanel chartPanel = new ChartPanel(chart);         chartPanel.setPreferredSize(new java.awt.Dimension(450, 270));         setContentPane(chartPanel);     }     /**      * Creates a sample dataset.      *       * @return A sample dataset.      */     private BoxAndWhiskerCategoryDataset createSampleDataset() {                  final int seriesCount = 2;         final int categoryCount = 4;         double[] data = null;         final DefaultBoxAndWhiskerCategoryDataset dataset              = new DefaultBoxAndWhiskerCategoryDataset();         for (int i = 0; i < seriesCount; i++) {         if(i == 0) {         data = new double[]{2,4,6,8,12,14,16,18,20,25,45};         } else {         data = new double[]{2,4,6,8,12,14,16,18,20,25,26};         }                     for (int j = 0; j < categoryCount; j++) {                 final List list = new ArrayList();                 for (int k = 0; k < data.length; k++) {                     list.add(new Double(data[k]));                 }                 dataset.add(list, "Series " + i, " Type " + j);             }                      }         return dataset;     }     /**      * For testing from the command line.      *      * @param args  ignored.      */     public static void main(final String[] args) {         final BoxAndWhiskerDemo demo = new BoxAndWhiskerDemo("Box-and-Whisker Chart Demo");         demo.pack();         RefineryUtilities.centerFrameOnScreen(demo);         demo.setVisible(true);     } } 

數(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)的第一個參數(shù)驗證碼對象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺檢測極驗服務(wù)器是否宕機(jī) new_captcha: data.new_captcha, // 用于宕機(jī)時表示是新驗證碼的宕機(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){ //倒計時完成 $(".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); }