• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cbook.boxplot_stats函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.cbook.boxplot_stats函数的典型用法代码示例。如果您正苦于以下问题:Python boxplot_stats函数的具体用法?Python boxplot_stats怎么用?Python boxplot_stats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了boxplot_stats函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_results_withlabels

    def test_results_withlabels(self):
        labels = ["Test1", 2, "ardvark", 4]
        results = cbook.boxplot_stats(self.data, labels=labels)
        res = results[0]
        for lab, res in zip(labels, results):
            assert res["label"] == lab

        results = cbook.boxplot_stats(self.data)
        for res in results:
            assert "label" not in res
开发者ID:QuLogic,项目名称:matplotlib,代码行数:10,代码来源:test_cbook.py


示例2: test_boxplot_stats_autorange_false

    def test_boxplot_stats_autorange_false(self):
        x = np.zeros(shape=140)
        x = np.hstack([-25, x, 25])
        bstats_false = cbook.boxplot_stats(x, autorange=False)
        bstats_true = cbook.boxplot_stats(x, autorange=True)

        assert bstats_false[0]['whislo'] == 0
        assert bstats_false[0]['whishi'] == 0
        assert_array_almost_equal(bstats_false[0]['fliers'], [-25, 25])

        assert bstats_true[0]['whislo'] == -25
        assert bstats_true[0]['whishi'] == 25
        assert_array_almost_equal(bstats_true[0]['fliers'], [])
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:13,代码来源:test_cbook.py


示例3: setup

    def setup(self):
        np.random.seed(937)
        self.nrows = 37
        self.ncols = 4
        self.data = np.random.lognormal(size=(self.nrows, self.ncols), mean=1.5, sigma=1.75)
        self.known_keys = sorted(
            ["mean", "med", "q1", "q3", "iqr", "cilo", "cihi", "whislo", "whishi", "fliers", "label"]
        )
        self.std_results = cbook.boxplot_stats(self.data)

        self.known_nonbootstrapped_res = {
            "cihi": 6.8161283264444847,
            "cilo": -0.1489815330368689,
            "iqr": 13.492709959447094,
            "mean": 13.00447442387868,
            "med": 3.3335733967038079,
            "fliers": np.array([92.55467075, 87.03819018, 42.23204914, 39.29390996]),
            "q1": 1.3597529879465153,
            "q3": 14.85246294739361,
            "whishi": 27.899688243699629,
            "whislo": 0.042143774965502923,
        }

        self.known_bootstrapped_ci = {"cihi": 8.939577523357828, "cilo": 1.8692703958676578}

        self.known_whis3_res = {
            "whishi": 42.232049135969874,
            "whislo": 0.042143774965502923,
            "fliers": np.array([92.55467075, 87.03819018]),
        }

        self.known_res_percentiles = {"whislo": 0.1933685896907924, "whishi": 42.232049135969874}

        self.known_res_range = {"whislo": 0.042143774965502923, "whishi": 92.554670752188699}
开发者ID:QuLogic,项目名称:matplotlib,代码行数:34,代码来源:test_cbook.py


示例4: test_results_bootstrapped

 def test_results_bootstrapped(self):
     results = cbook.boxplot_stats(self.data, bootstrap=10000)
     res = results[0]
     for key in list(self.known_bootstrapped_ci.keys()):
         assert_approx_equal(
             res[key],
             self.known_bootstrapped_ci[key]
         )
开发者ID:data-exp-lab,项目名称:matplotlib,代码行数:8,代码来源:test_cbook.py


示例5: test_results_whiskers_percentiles

    def test_results_whiskers_percentiles(self):
        results = cbook.boxplot_stats(self.data, whis=[5, 95])
        res = results[0]
        for key in list(self.known_res_percentiles.keys()):
            if key != "fliers":
                assert_statement = assert_approx_equal
            else:
                assert_statement = assert_array_almost_equal

            assert_statement(res[key], self.known_res_percentiles[key])
开发者ID:Reagankm,项目名称:KnockKnock,代码行数:10,代码来源:test_cbook.py


示例6: setup

    def setup(self):
        np.random.seed(937)
        self.nrows = 37
        self.ncols = 4
        self.data = np.random.lognormal(size=(self.nrows, self.ncols),
                                        mean=1.5, sigma=1.75)
        self.known_keys = sorted([
            'mean', 'med', 'q1', 'q3', 'iqr',
            'cilo', 'cihi', 'whislo', 'whishi',
            'fliers', 'label'
        ])
        self.std_results = cbook.boxplot_stats(self.data)

        self.known_nonbootstrapped_res = {
            'cihi': 6.8161283264444847,
            'cilo': -0.1489815330368689,
            'iqr': 13.492709959447094,
            'mean': 13.00447442387868,
            'med': 3.3335733967038079,
            'fliers': np.array([
                92.55467075,  87.03819018,  42.23204914,  39.29390996
            ]),
            'q1': 1.3597529879465153,
            'q3': 14.85246294739361,
            'whishi': 27.899688243699629,
            'whislo': 0.042143774965502923,
            'label': 1
        }

        self.known_bootstrapped_ci = {
            'cihi': 8.939577523357828,
            'cilo': 1.8692703958676578,
        }

        self.known_whis3_res = {
            'whishi': 42.232049135969874,
            'whislo': 0.042143774965502923,
            'fliers': np.array([92.55467075, 87.03819018]),
        }

        self.known_res_with_labels = {
            'label': 'Test1'
        }

        self.known_res_percentiles = {
            'whislo':   0.1933685896907924,
            'whishi':  42.232049135969874
        }

        self.known_res_range = {
            'whislo': 0.042143774965502923,
            'whishi': 92.554670752188699

        }
开发者ID:AudiencePropensities,项目名称:matplotlib,代码行数:54,代码来源:test_cbook.py


示例7: compute_boxplot

 def compute_boxplot(self, series):
     """
     Compute boxplot for given pandas Series.
     """
     from matplotlib.cbook import boxplot_stats
     series = series[series.notnull()]
     if len(series.values) == 0:
         return {}
     stats = boxplot_stats(list(series.values))[0]
     stats['count'] = len(series.values)
     stats['fliers'] = "|".join(map(str, stats['fliers']))
     return stats
开发者ID:AhmedHamedTN,项目名称:django-rest-pandas,代码行数:12,代码来源:serializers.py


示例8: median_confidence_intervals

def median_confidence_intervals(data):
    if not data:  # empty
        return [0], [0], [0]
    bxpstats = cbook.boxplot_stats(data)
    confidence_intervals = [[], []]
    medians = []
    for stat in bxpstats:
        confidence_intervals[0].append(stat['cilo'])
        confidence_intervals[1].append(stat['cihi'])
        medians.append(stat['med'])
    confidence_intervals[0] = np.array(confidence_intervals[0])
    confidence_intervals[1] = np.array(confidence_intervals[1])
    return medians, medians - confidence_intervals[0], confidence_intervals[1] - medians
开发者ID:UNH-Robotics,项目名称:metronome,代码行数:13,代码来源:plotutils.py


示例9: test_results_whiskers_range

    def test_results_whiskers_range(self):
        results = cbook.boxplot_stats(self.data, whis='range')
        res = results[0]
        for key in list(self.known_res_range.keys()):
            if key != 'fliers':
                assert_statement = assert_approx_equal
            else:
                assert_statement = assert_array_almost_equal

            assert_statement(
                res[key],
                self.known_res_range[key]
            )
开发者ID:data-exp-lab,项目名称:matplotlib,代码行数:13,代码来源:test_cbook.py


示例10: plt1

def plt1(rpt, key='REL', log=True):
    """ plot supervised learning report. """
    # load report form file if necessary.
    sim = ['fam', 'frq', 'mdl', 'nxp']
    nnt = ['gtp', 'xtp', 'nwk']
    mtd = ['mtd', 'par']
    if isinstance(rpt, str) and rpt.endswith('pgz'):
        rpt = lpz(rpt)

    # the benchmark records
    bmk = rpt.bmk

    # title
    ttl = bmk.iloc[0][sim]
    ttl = ', '.join('{}={}'.format(k, v) for k, v in ttl.items())

    # method grouping
    grp = nnt + mtd

    # plot of relative error
    err = bmk[bmk.key == key].loc[:, nnt + mtd + ['val']]
    err = err[err.mtd != 'nul']

    # sample some data points to craft boxplot states
    X, L = [], []
    for l, g in err.groupby(grp):
        if 'nnt' in l:
            l = "{nwk:>10}.{mtd}".format(**g.iloc[0])
        else:
            l = "{par:>10}.{mtd}".format(**g.iloc[0])
        x = np.array(g.val)
        X.append(x)
        L.append(l)
    X = np.array(X).T
    S = cbook.boxplot_stats(X, labels=L)

    # plot
    plt.close('all')
    plt.title(ttl)
    ax = plt.axes()
    if log:
        ax.set_yscale('log')
    ax.bxp(S)

    # draw a line at y=1
    x0, x1 = ax.get_xbound()
    zx, zy = np.linspace(x0, x1, 10), np.ones(10)
    ax.plot(zx, zy, linestyle='--', color='red', linewidth=.5)
    for tick in ax.get_xticklabels():
        tick.set_rotation(90)
    return rpt, plt
开发者ID:xiaoran831213,项目名称:DeepG,代码行数:51,代码来源:kgm.py


示例11: median_confidence_intervals

def median_confidence_intervals(data: list):
    """ Compute the median and the median 95% confidence intervals for the data.
    :param data: the data whose statistics are to be calculated
    :return: the medians, the low confidence intervals, and the high confidence intervals
    """
    if not data:  # empty
        return [0], [0], [0]
    bxpstats = cbook.boxplot_stats(data)
    confidence_intervals = [[], []]
    medians = []
    for stat in bxpstats:
        confidence_intervals[0].append(stat['cilo'])
        confidence_intervals[1].append(stat['cihi'])
        medians.append(stat['med'])
    confidence_intervals[0] = np.array(confidence_intervals[0])
    confidence_intervals[1] = np.array(confidence_intervals[1])
    return medians, medians - confidence_intervals[0], confidence_intervals[1] - medians
开发者ID:csbence,项目名称:real-time-search,代码行数:17,代码来源:plotutils.py


示例12: main

def main():
  parser = argparse.ArgumentParser()
  parser.add_argument('sequence_name', help='dataset sequence name')
  parser.add_argument('--diff_list', help='string - name of diff_list file (needed for Graph 1, output of depth_map.py)')
  parser.add_argument('--graph_depths', help='directory - graph files (needed for Graphs 2-5, output of depth_map.py)')
  parser.add_argument('--x_axis_spacing', help='integer - separation among ticks in the x axis (for readability))')
  args = parser.parse_args()

  make_fig_1(args)

  # depth vs errors (amount, mean)
  # load all graph_depth*.npy files

  graph_depth_dir = "./depth_info/"
  if args.graph_depths:
    graph_depth_dir = args.graph_depths

  x_axis_spacing = 5
  if args.x_axis_spacing and args.x_axis_spacing >= 1:
    x_axis_spacing = int(float(args.x_axis_spacing))


  print "Using graph depth dir: ", graph_depth_dir
  npys = glob.glob(graph_depth_dir+'graph_depth*.npy')

  if len(npys)<=0 :
    print "No data to collect.."
    return

  bins = np.load(graph_depth_dir+'bins.npy')
  print bins
  graph_depth = [[] for i in range(len(bins))]

  fig, ax = plt.subplots(1,1)
  bxpstats = list()
  graphs = []
  for npy in npys:
    g = np.load(npy)[1]
    if len(g) > 0:
      graphs.append(g)

  means = np.zeros(len(bins))
  medians = np.zeros(len(bins))
  maxs = np.zeros(len(bins))
  for i in range(len(bins)):
    graph_depth = []

    for j in range(len(npys)):
      if i < len(graphs[j]):
        if len(graphs[j][i]) > 0:
          graph_depth.extend(graphs[j][i])

    if len(graph_depth) > 0:
      means[i] = np.mean(graph_depth)
      medians[i] = np.median(graph_depth)
      maxs[i] = np.max(graph_depth)
      bxpstats.extend(cbook.boxplot_stats(np.ravel(graph_depth)))
    else:
      bxpstats.extend(cbook.boxplot_stats(np.ravel([0])))

    print "ITEM : " , i, len(graph_depth)

  ax.bxp(bxpstats, showfliers=False)
  bins_str = map(lambda x: str(int(bins[x])) if x % x_axis_spacing == 0 else '', range(len(bins)))

  # bins-bins[0]+1 since it can start at any number
  plt.xticks(bins-bins[0]+1, bins_str)
  plt.xlabel(utf8("Distance to the camera (depth, m)"))
  plt.ylabel("Error (m)")
  plt.savefig(args.sequence_name+"2.png")

  # mean
  plt.figure(3)
  plt.plot(bins, means)
  plt.xlabel(utf8("Distance to the camera (depth, m)"))
  plt.ylabel("Error - mean (m)")
  plt.savefig(args.sequence_name+"3.png")

  plt.figure(4)
  plt.plot(bins, medians)
  plt.xlabel(utf8("Distance to the camera (depth, m)"))
  plt.ylabel("Error - median (m)")
  plt.savefig(args.sequence_name+"4.png")

  np.save("depth_info/medians"+args.sequence_name+".npy", medians)

  plt.figure(5)
  plt.plot(bins, maxs)
  plt.xlabel(utf8("Distance to the camera (depth, m)"))
  plt.ylabel(utf8("Error - máximo (m)"))
  plt.savefig(args.sequence_name+"5.png")

  print ""
  print "Saved " + args.sequence_name + "{1-5}.png files"
开发者ID:labimage,项目名称:dense-sptam,代码行数:94,代码来源:plot_dmap_error.py


示例13:

wcls = sumbrief[sumbrief['Experiment'].str.contains('_WCL')]
wcl = wcls[~wcls['Experiment'].str.contains('_WCLP')]
wclp = wcls[wcls['Experiment'].str.contains('_WCLP')]
ubs = sumbrief[sumbrief['Experiment'].str.contains('_Ub')]
ub = ubs[~ubs['Experiment'].str.contains('_UbP')]
ubp = ubs[ubs['Experiment'].str.contains('_UbP')]

#print wcl
#print wclp
#print ub
#print ubp


# compute the boxplot stats
ubstats = cbook.boxplot_stats(ub[["MS/MS Identified"]].values, whis='range', bootstrap=None, labels=None)
ubpstats = cbook.boxplot_stats(ubp[["MS/MS Identified"]].values, whis='range', bootstrap=None, labels=None)
wclstats = cbook.boxplot_stats(wcl[["MS/MS Identified"]].values, whis='range', bootstrap=None, labels=None)
wclpstats = cbook.boxplot_stats(wclp[["MS/MS Identified"]].values, whis='range', bootstrap=None, labels=None)

fs = 10 # fontsize

# demonstrate how to toggle the display of different elements:
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(4,4))
axes[0, 0].bxp(ubstats)
axes[0, 0].set_title('ub', fontsize=fs)

axes[0, 1].bxp(ubpstats)
axes[0, 1].set_title('ubp', fontsize=fs)

axes[1, 0].bxp(wclstats)
开发者ID:chelsell,项目名称:whangee_pubs,代码行数:30,代码来源:quality_control.py


示例14: test_bad_dims

 def test_bad_dims(self):
     data = np.random.normal(size=(34, 34, 34))
     with pytest.raises(ValueError):
         results = cbook.boxplot_stats(data)
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:4,代码来源:test_cbook.py


示例15: test_label_error

 def test_label_error(self):
     labels = [1, 2]
     with pytest.raises(ValueError):
         results = cbook.boxplot_stats(self.data, labels=labels)
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:4,代码来源:test_cbook.py


示例16: test_results_whiskers_percentiles

 def test_results_whiskers_percentiles(self):
     results = cbook.boxplot_stats(self.data, whis=[5, 95])
     res = results[0]
     for key, value in self.known_res_percentiles.items():
         assert_array_almost_equal(res[key], value)
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:5,代码来源:test_cbook.py


示例17: test_results_whiskers_range

 def test_results_whiskers_range(self):
     results = cbook.boxplot_stats(self.data, whis='range')
     res = results[0]
     for key, value in self.known_res_range.items():
         assert_array_almost_equal(res[key], value)
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:5,代码来源:test_cbook.py


示例18: test_results_whiskers_float

 def test_results_whiskers_float(self):
     results = cbook.boxplot_stats(self.data, whis=3)
     res = results[0]
     for key, value in self.known_whis3_res.items():
         assert_array_almost_equal(res[key], value)
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:5,代码来源:test_cbook.py


示例19: test_results_bootstrapped

 def test_results_bootstrapped(self):
     results = cbook.boxplot_stats(self.data, bootstrap=10000)
     res = results[0]
     for key, value in self.known_bootstrapped_ci.items():
         assert_approx_equal(res[key], value)
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:5,代码来源:test_cbook.py


示例20: list

A good general reference on boxplots and their history can be found
here: http://vita.had.co.nz/papers/boxplots.pdf
"""

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook

# fake data
np.random.seed(19680801)
data = np.random.lognormal(size=(37, 4), mean=1.5, sigma=1.75)
labels = list('ABCD')

# compute the boxplot stats
stats = cbook.boxplot_stats(data, labels=labels, bootstrap=10000)

###############################################################################
# After we've computed the stats, we can go through and change anything.
# Just to prove it, I'll set the median of each set to the median of all
# the data, and double the means

for n in range(len(stats)):
    stats[n]['med'] = np.median(data)
    stats[n]['mean'] *= 2

print(list(stats[0]))

fs = 10  # fontsize

###############################################################################
开发者ID:ianthomas23,项目名称:matplotlib,代码行数:30,代码来源:bxp.py



注:本文中的matplotlib.cbook.boxplot_stats函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cbook.dedent函数代码示例发布时间:2022-05-27
下一篇:
Python cbook._warn_external函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap