资源简介
AdaBoost算法有AdaBoost.M1和AdaBoost.M2两种算法,AdaBoost.M1是我们通常所说的Discrete AdaBoost,而AdaBoost.M2是M1的泛化形式。关于AdaBoost算法的一个结论是:当弱分类器算法使用简单的分类方法时,boosting的效果明显地统一地比bagging要好.当弱分类器算法使用C4.5时,boosting比bagging较好,但是没有前者明显。后来又有学者提出了解决多标签问题的AdaBoost.MH和AdaBoost.MR算法,其中AdaBoost.MH算法的一种形式又被称为Real Boost算法---弱分类器输出一个可能度,该值的范围是整个R, 和与之相应的权值调整,强分类器生成的AdaBoost算法。Python实现该算法。
adabbost原理见博客
http://blog.csdn.net/suipingsp/article/details/41722435

代码片段和文件信息
‘‘‘
Created on Feb27 2014
DS is short for Decision Stump
@author: Aidan
‘‘‘
from numpy import *
from object_json import *
from decisionstump import *
from copy import *
import pdb
class adaBoost(object):
def __init__(selfclassifierDict = None **args):
obj_list = inspect.stack()[1][-2]
self.__name__ = obj_list[0].split(‘=‘)[0].strip()
if classifierDict == None:
self.classifierDict = {}
else:
self.classifierDict = classifierDict
def jsonDumpsTransfer(self):
‘‘‘essential transformation to Python basic type in order to
store as json. dumps as objectname.json if filename missed ‘‘‘
#pdb.set_trace()
if ‘DS‘ in self.classifierDict:
del(self.DSobject)
def jsonDumps(self filename=None):
‘‘‘dumps to json file‘‘‘
self.jsonDumpsTransfer()
if not filename:
jsonfile = self.__name__+‘.json‘
else: jsonfile = filename
objectDumps2File(self jsonfile)
def jsonloadTransfer(self):#TBD
‘‘‘essential transformation to object required type such as numpy matrix
call this function after newobject = objectLoadFromFile(jsonfile)‘‘‘
#pdb.set_trace()
if ‘DS‘ in self.classifierDict:
self.DSobject = decisionStump()
def getClassifierList(selfclassifierType):
‘‘‘get the specific classifierList of classifierType‘‘‘
try:
return self.classifierDict[classifierType]
except:
raise NameError(‘no classifierList of type %s!‘%classifierType)
print ‘no classifierList of type %s‘%classifierType
return None
def setClassifierList(selfclassifierType classifierList):
self.classifierDict[classifierType] = deepcopy(classifierList)
def getClassifierDict(self):
return self.classifierDict
def setClassifierDict(self classifierDict):
self.classifierDict = deepcopy(classifierDict)
def __classifyDS(self dataToClass):
classifierList = self.getClassifierList(‘DS‘)
dataMatrix = mat(dataToClass)#do stuff similar to last aggClassEst in adaBoostTrainDS
m = shape(dataMatrix)[0]
aggClassEst = mat(zeros((m1)))
for i in range(len(classifierList)):
classEst = self.DSobject.stumpClassify(dataMatrixclassifierList[i][‘dim‘]\
classifierList[i][‘thresh‘]\
classifierList[i][‘ineqtype‘])#call stump classify
aggClassEst += classifierList[i][‘alpha‘]*classEst
#print ‘dataToClass aggClassEst:‘aggClassEst
return sign(aggClassEst)
def classify(selfdataToClass classifierType = ‘DS‘ ):
classifierList = self.getClassifierList(classifierType)
if classifierType == ‘DS‘:
result = self.__classifyDS(dat
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5973 2014-12-01 11:50 adaboost\adaboost.py
文件 6024 2014-12-01 11:50 adaboost\adaboost.pyc
文件 910 2014-12-01 11:31 adaboost\adaboostClassifier10.json
文件 8323 2014-12-01 11:31 adaboost\adaboostClassifier100.json
文件 1722 2014-12-01 11:30 adaboost\adaboostClassifier20.json
文件 16619 2014-12-01 11:35 adaboost\adaboostClassifier200.json
文件 2538 2014-12-01 11:30 adaboost\adaboostClassifier30.json
文件 3339 2014-12-01 11:33 adaboost\adaboostClassifier40.json
文件 33334 2014-12-01 11:35 adaboost\adaboostClassifier400.json
文件 520 2014-12-01 11:31 adaboost\adaboostClassifier5.json
文件 4185 2014-12-01 11:29 adaboost\adaboostClassifier50.json
文件 5006 2014-12-01 11:33 adaboost\adaboostClassifier60.json
文件 67584 2014-11-27 12:18 adaboost\adaboost_classifier structure.vsd
文件 5539 2014-11-28 16:10 adaboost\decisionstump.py
文件 5625 2014-11-28 16:10 adaboost\decisionstump.pyc
文件 13614 2010-12-06 08:29 adaboost\horseColicTest2.txt
文件 60778 2010-12-06 08:26 adaboost\horseColicTraining2.txt
文件 2789 2014-12-01 12:11 adaboost\ob
文件 3992 2014-12-03 16:23 adaboost\ob
文件 2104 2014-12-03 16:59 adaboost\test.py
目录 0 2014-12-03 16:23 adaboost
----------- --------- ---------- ----- ----
250518 21
- 上一篇:python3_爬取网上资源存入数据库中
- 下一篇:python3抓百度贴吧帖子源码
相关资源
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
评论
共有 条评论