
python
袁博特
这个作者很懒,什么都没留下…
-
原创 机器学习实战《Machine Learing in Action》——第三章python知识点
featList = [example[i] for example in dataSet]此句话应该拆成两块进行理解第一句话:for example in dataSet从dataset中逐行提取第二句话:featList = [example[i]]数组的第i个元素dataset = [[1, 1, 'yes'], [1, 1, 'yes'], [1, 0, 'no'], [0, 1, 'no'],2021-01-30 10:53:0210
0
-
原创 python3.x版本 机器学习实战《Machine Learing in Action》——第三章python中绘制决策树代码
python3.x版本下,在用example_dict.keys()或者example_dict.values()取出字典中对应的键值时,取出的值总是会带有前缀。python2.x版本的不存在这个问题,可以直接使用书中的代码以下是python3.x版本代码:def plotTree(myTree, parentPt, nodeTxt):#if the first key tells you what feat was split on numLeafs = getNumLeafs(myTree2021-01-24 22:46:3510
0
-
原创 python3.x版本 机器学习实战《Machine Learing in Action》——第三章python中叶子数和树的深度代码
python3.x版本下,在用example_dict.keys()或者example_dict.values()取出字典中对应的键值时,取出的值总是会带有前缀。python2.x版本的不存在这个问题,可以直接使用书中的代码以下是python3.x版本代码:def getNumLeafs(myTree): # python3 版本 返回叶子数 numLeafs = 0 secondDict = list(myTree.values()) for key in range(len2021-01-23 20:58:2221
5
-
原创 jupyter notebook 压缩/解压文件夹
转载请注明出处!!!压缩压缩成zip格式# 压缩当前路径所有文件,输出zip文件path='./'import zipfile,oszipName = 'student_id.zip' #压缩后文件的位置及名称f = zipfile.ZipFile( zipName, 'w', zipfile.ZIP_DEFLATED )for dirpath, dirnames, filenames in os.walk(path): for filename in filenames:2021-01-21 19:31:38162
0
-
转载 注意python中import和from import 的区别
注意python中import和from import 的区别 首先明确:尽量不要为了图省事使用from xxx import * python中有两种导入模块的方式,一种是import xxx,另一种是from xxx import yyy,两者的区别在于,第一种仅仅导入一个模...2021-01-04 21:56:0626
3