在脚本中运行Scipy的单向方差分析 [英] Running scipy's oneway anova in a script

查看:149
本文介绍了在脚本中运行Scipy的单向方差分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题.我想在一个脚本中运行scipy.stats f_oneway()方差分析,该脚本加载包含numpy数组的数据档案,如下所示:

I have a problem. I want to run the scipy.stats f_oneway() ANOVA in a script that loads a data-archive containing groups with numpy arrays like so:

archive{'group1': array([ 1, 2, 3, ..., ]),
        'group2': array([ 9, 8, 7, ..., ]),
        ...}

现在我的问题是,对于不同的数据归档,组的数量不是固定的.换句话说,我事先不知道档案中有多少个群组(也不一定是他们的名字).

Now my problem is that the number of groups is not fixed for different data-archives. In other words, I don't know beforehand, how many groups there are in an archive (and also not necessarily what their names are).

单向方差分析的科学实现仅接受以逗号分隔的像这样输入数组:

The scipy implementation of a oneway ANOVA only accepts comma delimited arrays as input like so:

a = array([ 1, 2, 3, ..., ])
b = array([ 9, 8, 7, ..., ])
c = array([ 5, 6, 4, ..., ])

scipy.stats.f_oneway(a, b, c)

我试图给它列表,元组,多维数组都没有成功.因此,目前,我可以使用ANOVA实现的唯一方法是每次都手动输入组变量,这实际上使得无法在脚本中运行它.我想知道你们中的一个人是否对如何解决这个问题或如何避免f_oneway()的这些非常特定的数据格式要求有想法.

I tried to give it lists, tuples, multidimensional arrays all without success. So presently, the only way I can use this ANOVA implementation is by manually entering the group variables each time which effectively makes it impossible to run this in a script. I am wondering if one of you has an idea how to solve this or how to avoid these very specific data format requirements of f_oneway().

推荐答案

我想您应该尝试:

scipy.stats.f_oneway(*archive.values())

这篇关于在脚本中运行Scipy的单向方差分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆