python机器学习-乳腺癌细胞挖掘(博主亲自录制视频)https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campaign=commission&utm_source=cp-400000000398149&utm_medium=share

项目联系QQ:231469242

https://github.com/thomas-haslwanter/statsintro_python/tree/master/ISP/Code_Quantlets/08_TestsMeanValues/kruskalWallis

# -*- coding: utf-8 -*-
import numpy as np
# additional packages
from scipy.stats.mstats import kruskalwallis
'''
.. currentmodule:: scipy.stats.mstats
This module contains a large number of statistical functions that can
be used with masked arrays.
Most of these functions are similar to those in scipy.stats but might
have small differences in the API or in the algorithm used. Since this
is a relatively new package, some API changes are still possible.
'''
# Get the data
'''
#These data could be a comparison of the smog levels in four different cities.
city1 = np.array([68, 93, 123, 83, 108, 122])
city2 = np.array([119, 116, 101, 103, 113, 84])
city3 = np.array([70, 68, 54, 73, 81, 68])
city4 = np.array([61, 54, 59, 67, 59, 70])
''' group1=[27,2,4,18,7,9]
group2=[20,8,14,36,21,22]
group3=[34,31,3,23,30,6]
list_groups=[group1,group2,group3] def Kruskawallis_test(list_groups):
# Perform the Kruskal-Wallis test,返回True表示有显著差异,返回False表示无显著差异
print"Use kruskawallis test:"
h, p = kruskalwallis(list_groups)
print"H value:",h
print"p",p # Print the results
if p<0.05:
print('There is a significant difference between the cities.')
return True
else:
print('No significant difference between the cities.')
return False Kruskawallis_test(list_groups)

当样本数据非正态分布,两组数对比时用mann-whitney检验,三组或更多时用kruskal-wallis检验

kruskal-wallis 是一个独立单因素方差检验的版本

kruskal-wallis能用于排序计算

样本数据

流程

H0和H1假设

自由度:组数-1,这里有三组,自由度为3-=2

自由度为2,a=0.05,对应得关键值5.99,如果计算的值大于5.99,拒绝原假设

对数据排序,然后把对应得排序填入表内

计算公式:

T为一组的排序之和

n为一组的个数

计算的H值2.854小于5.99,不拒绝原假设

python信用评分卡建模(附代码,博主录制)

最新文章

  1. java语法基本知识
  2. AngularJS---自定义指令
  3. VS2012变化的快捷键:
  4. jquery点击改变class并toggle;jquery点击改变图片src源码并toggle;jquery显示隐藏toggle
  5. js dom 操作
  6. JavaScript Modules
  7. Java再学习——synchronized与volatile
  8. SpringBoot入门系列:第一篇 Hello World
  9. PV FV PMT
  10. linux内核——1.概述
  11. python 循环使用 while 或 for 语句实现用户名密码输错三次退出
  12. 【Netty】ChannelHandler和codec
  13. [LeetCode] Reorganize String 重构字符串
  14. MYSQL—— 基础入门,select 查询涉及到的关键字组合详解(进阶篇)
  15. cf1153D 树形dp+思维
  16. 触发full gc的条件
  17. jquery抓娃娃机代码
  18. Oracle分析函数大全
  19. Qt应用程序单实例化
  20. jQuery - 同时添加click和dblclick事件

热门文章

  1. 算法笔记(c++)-使用递归函数逆序一个栈
  2. 获取文件夹下某个类型的文件名---基于python
  3. Thunder——互评beta版本
  4. 基础系列(6)—— C#类和对象
  5. Chrome浏览器超强调试工具
  6. TeamCity编译执行selenium上传窗口脚本缺陷
  7. Cmder命令行工具在Windows系统中的配置
  8. gridview 第一行编辑
  9. PHP中类中成员及常量
  10. [计算机网络-数据链路层] CSMA、CSMA/CA、CSMA/CD详解