Machine-Learning-in-Action-Python3
Machine-Learning-in-Action-Python3 copied to clipboard
《机器学习实战》的python3源码
530行里 调用classify方法,给定的第二项输入应该是完整的数据labels,且顺序和数据集顺序应该一致 同时优化了classify方法的写法 更加直观 ```python def classify(inputTree, featLabels, testVec): # 获取决策树结点 # 当前树节点的key首项 表明选择的特征类型 keyLabel = list(inputTree.keys())[0] # 对应类型的特征树 currDict = inputTree[keyLabel] # 获取特征类型在特征中的index featIndex = featLabels.index(keyLabel) # 获取当前的特征叶子 或者是...
def replaceNaNWithMean(): 里面应该是这个⑧ meanVal = np.mean(datMat[np.nonzero(~np.isnan(datMat[:, i].A))[0], i])
🐛 正则匹配并不能匹配到正确的词 ♐ 这样可以,不知再有没有更好的解决方式 ```python def textParse(bigString): # 用特殊符号作为切分标志进行字符串切分,即非字母、非数字 # \W* 0个或多个非字母数字或下划线字符(等价于[^a-zA-Z0-9_]) bigString=bigString.split() listOfTockens=[] for i in range(len(bigString)): listOfTockens.append(str("".join(list(filter(str.isalpha, bigString[i]))))) # 除了单个字母,例如大写I,其他单词变成小写,去掉少于两个字符的字符串 return [tok.lower() for tok in listOfTockens if len(tok)...
## Bayes_Project1/Bayes.py中 第106行 numWords应该是模型中总词条数目或者说用户词典中的总词条数目吧?
中文版电子属于
请问有中文版电子书的下载链接吗?
https://github.com/wzy6642/Machine-Learning-in-Action-Python3/blob/3710796b7497255fbc1bba91b0558b4b3eb828b4/PCA_Project1/PCA.py#L52
def rssError() 函数说明部分的returns不应该是ws,应该是((yArr - yHatArr)**2).sum()。
Machine-Learning-in-Action-Python3/CART_Project3/CART.py 第285行 errorNoMerge = np.sum(np.power(lSet[:, -1] - tree['left'], 2)) + np.sum(np.power(rSet[:, 1] - tree['right'], 2)) 中的后半部分rSet的索引似乎应该是[:, -1]。应修改为: errorNoMerge = np.sum(np.power(lSet[:, -1] - tree['left'], 2)) + np.sum(np.power(rSet[:, -1] - tree['right'], 2))
需要替换属性`FontProperties=`为`fontproperties=`,注意替换时不能把`FontProperties`函数替换了,建议添加`=`