chansonz / book-ml-sem Goto Github PK
View Code? Open in Web Editor NEW《机器学习:软件工程方法与实现》Method and implementation of machine learning software engineering
License: MIT License
《机器学习:软件工程方法与实现》Method and implementation of machine learning software engineering
License: MIT License
书本中第一章,页数27,增加先验的注释下,第7行代码self.train()开始到结束,均需要缩进四行。
def judge(score_dict):
'''二分类'''
keys = self.CAT #list(score_dict.keys())
应该是
def judge(score_dict):
'''二分类'''
keys = EmailClassifier.CAT
s = '../data/processed/spam_400/'
h = '../data/processed/ham_1120/'
clf = EmailClassifier(s, h)
clf.train()
请问这里的s和h的路径是哪里来的? 我翻了上下文和仓库里的数据包,都没有找到这个文件路径
书中第27页的代码
def score(self, email_file):
if self.total_count[self.CAT[0]] == 0 or self.total_count[self.CAT[1]] == 0:
self.train()
result = self.P.copy()
for ww in EmailClassifier.get_words_from_file(email_file):
for cc in self.CAT:
v = self.training[cc][ww]
p = (v + 1) / (self.total_count[cc] + 1)
result[cc] *= p
这段代码无法通过单元测试,存在两个问题,
建议修改如下:
def score(self, email_file):
if self.total_count[self.CAT[0]] == 0 or self.total_count[self.CAT[1]] == 0:
self.train()
result = self.P.copy()
for ww in EmailClassifier.get_words_from_file(email_file):
for cc in self.CAT:
v = self.training[cc][ww]
p = (v + 1) / (self.total_count[cc] + 1)
result[cc] *= p
result[cc] = round(result[cc], 7)
return result
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.