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

查看:35
本文介绍了在脚本中运行 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).

单向方差分析的 scipy 实现仅接受逗号分隔数组作为输入,如下所示:

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天全站免登陆