Running scipy's oneway anova in a script

三世轮回 提交于 2019-11-29 14:26:12

问题


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)

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().


回答1:


I suppose you should try:

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


来源:https://stackoverflow.com/questions/12683683/running-scipys-oneway-anova-in-a-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!