资源简介
机器学习实战数据集
代码片段和文件信息
#-*- coding:utf-8 _*-
“““
@author:KING
@file: adaboost.py
@time: 2018/08/15
“““
import numpy as np
def loadSimpData():
datMat = np.matrix([[1.2.1]
[2.1.1]
[1.31.]
[1.1.]
[2.1.]])
classLabels = [1.01.0-1.0-1.01.0]
return datMatclassLabels
def stumpClassify(dataMatrixdimenthreshValthreshIneq):
retArray = np.ones((np.shape(dataMatrix)[0]1))
if threshIneq == ‘lt‘:
retArray[dataMatrix[:dimen] <= threshVal] = -1.0
else:
retArray[dataMatrix[: dimen] > threshVal] = -1.0
return retArray
def buildStump(dataArrclassLabelsD):
dataMatrix = np.mat(dataArr)
labelMat = np.mat(classLabels).T
mn = np.shape(dataMatrix)
numSteps = 10.0
bestStump = {}
bestClasEst = np.mat(np.zeros((m1)))
minError = np.inf
for i in range(n):#遍历特征
rangeMin = dataMatrix[:i].min()
rangeMax = dataMatrix[:i].max()
stepSize = (rangeMax-rangeMin)/numSteps#阈值增长步长
for j in range(-1int(numSteps)+1):
for inequal in [‘lt‘‘gt‘]:
threshVal = (rangeMin+float(j)*stepSize)
predictedVals = stumpClassify(dataMatrixithreshValinequal)
errArr = np.mat(np.ones((m1)))
errArr[predictedVals==labelMat]=0
weightedError = D.T*errArr
print(“split:dim %dthresh %.2fthresh inequal:%sthe weightedError is :%.3f“ %(
ithreshValinequalweightedError))
if weightedError minError = weightedError
bestClasEst = predictedVals.copy()
bestStump[‘dim‘] = i
bestStump[‘thresh‘]=threshVal
bestStump[‘ineq‘] = inequal
return bestStumpminErrorbestClasEst
def adaBoostTrainDS(dataArrclassLabelsnumIt = 40):
weakClassArr = []
m = np.shape(dataArr)[0]
D = np.mat(np.ones((m1))/m)
aggClassEst = np.mat(np.zeros((m1)))
for i in range(numIt):
bestStumperrorclassEst = buildStump(dataArrclassLabelsD)#第i个弱分类器
print(“D:“D.T)
alpha = float(0.5*np.log((1.0-error)/np.fmax(error1e-16)))
bestStump[‘alpha‘] = alpha
weakClassArr.append(bestStump)
print(“classEst: “classEst.T)#该分类器的分类结果
expon = np.multiply(-1*alpha*np.mat(classLabels).TclassEst)
D = np.multiply(Dnp.exp(expon))
D = D/D.sum()
aggClassEst+=alpha*classEst#与此前的分类器同时工作给出分类结果
print(“aggClassEst: “aggClassEst.T)
aggErrors = np.multiply(np.sign(aggClassEst)!= np.mat(classLabels).Tnp.ones((m1)))
errorRate = aggErrors.sum()/m
print(“total error:“errorRate“\n“)
if errorRate == 0.0:
break
return weakClassArr
def adaClassify(dataToClassclassifierArr):
dataMatrix = np.mat(dataToClass)
m = np.shape(dataMatrix)[0]
aggClassEst = np.mat(np.
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\.idea\
文件 455 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\.idea\AdaBoost.iml
文件 185 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\.idea\misc.xm
文件 268 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\.idea\modules.xm
文件 6905 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\.idea\workspace.xm
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\.ipynb_checkpoints\
文件 6963 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\.ipynb_checkpoints\AdaBoost-checkpoint.ipynb
文件 8412 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\AdaBoost.ipynb
文件 3456 2018-08-15 07:18 Machine-Learning-in-Action-master\AdaBoost\adaboost.py
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\.idea\
文件 398 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\.idea\Logistic回归.iml
文件 185 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\.idea\misc.xm
文件 280 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\.idea\modules.xm
文件 9563 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\.idea\workspace.xm
文件 3722 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\horseColicTest.txt
文件 60357 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\horseColicTraining.txt
文件 4007 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\logRegres.py
文件 4507 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\logRegres.pyc
文件 2087 2018-08-15 07:18 Machine-Learning-in-Action-master\Logistic回归\testSet.txt
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\MLiA_SourceCode\
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\MLiA_SourceCode\machinelearninginaction\
文件 31 2018-08-15 07:18 Machine-Learning-in-Action-master\README.txt
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\SVM\
目录 0 2018-08-15 07:18 Machine-Learning-in-Action-master\SVM\.idea\
文件 398 2018-08-15 07:18 Machine-Learning-in-Action-master\SVM\.idea\SVM.iml
文件 185 2018-08-15 07:18 Machine-Learning-in-Action-master\SVM\.idea\misc.xm
文件 258 2018-08-15 07:18 Machine-Learning-in-Action-master\SVM\.idea\modules.xm
文件 16956 2018-08-15 07:18 Machine-Learning-in-Action-master\SVM\.idea\workspace.xm
............此处省略3581个文件信息
相关资源
- 机器学习算法-名企历年校招面试笔试
- Tensorflow(一)训练自己的数据集——
- ETL工具Beeload快速入门
- 视觉跟踪avi监控视频数据集3
- 视觉跟踪avi监控视频数据集2
- mnist包含数据集利用Lenet实现.zip
- AIML语料库 Alice Bot语料库 英文,最新
- Andrew ng机器学习课程笔记带标签
- 2018新书 深入浅出数据科学 全彩中文
- 基于机器学习的Pm2.5图像分析及估计
- Introduction to Time Series and Forecasting.pd
- 手写数字训练样本集
- 机器学习知识学习总结.pdf
- 机器学习个人笔记完整版v5.29-A4打印版
- coursera机器学习每周测验完整版,包括
- UserBehavior.7z
- 斯坦福机器学习课后答案和个人笔记
- 机器学习中文版PDF
- Spark机器学习.pdf
- 机器学习-白板推导系列-前17讲笔记
- 机器学习实战 中文文字版.zip
- PRML模式识别与机器学习
- 机器学习PPT65306
- 已分类的数码管数据集
- PRML模式识别和机器学习带书签
- Statistic learning with sparsity
- 《机器学习》 Tom T.Mitchell 中文版 PD
- 数字图像处理数据集六-McMaster
- 数字图像处理数据集五-Kodak24
- 统计学习导论R语言
评论
共有 条评论