随机森林准确率和分类器关系
【摘要】 #!/usr/bin/python
# -*- coding:utf-8 -*-
import operator
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from functools import reduce
from scipy.special impo...
#!/usr/bin/python
# -*- coding:utf-8 -*-
import operator
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from functools import reduce
from scipy.special import comb
print('comb(10, 2) = ', comb(100, 30))
def c(n, k): return reduce(operator.mul, list(range(n-k+1, n+1))) / reduce(operator.mul, list(range(1, k+1)))
def bagging(n, p): s = 0 for i in range(n // 2 + 1, n + 1): s += comb(n, i) * p ** i * (1 - p) ** (n - i) return s
if __name__ == "__main__": n = 100 x = np.arange(1, n, 2) y = np.empty_like(x, dtype=np.float) for i, t in enumerate(x): y[i] = bagging(t, 0.6) if t % 10 == 9: print(t, '个分类器的正确率:', y[i]) mpl.rcParams['font.sans-serif'] = 'simHei' mpl.rcParams['axes.unicode_minus'] = False plt.figure(facecolor='w'
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
文章来源: maoli.blog.csdn.net,作者:刘润森!,版权归原作者所有,如需转载,请联系作者。
原文链接:maoli.blog.csdn.net/article/details/89457493
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)