Python代码编写辅导:CSC411 Digit Classification
2023-06-13 09:14:05 时间
全文链接:tecdat.cn/?p=29674
Requirement
In this assignment, you will compare the characteristics and performance of different classifiers, namely logistic regression, k-nearest neighbours and naive Bayes. You will experiment with these extensions and extend the provided code. Note that you should understand the code first instead of using it as a black box. Python versions of the code have been provided. You are free to work with whichever you wish.
Analysis
作为Machine Learning的三大基础算法
- Logistic regression,也就是logistic回归,常用于数据挖掘,疾病自动诊断,经济预测等领域
- K-nearest neighbours,也就是K邻近算法,常用于数据挖掘,以及分类,对未知事物的识别等领域
- Naive Bayes,也就是朴素贝叶斯,常用于分类器,文本分类识别
本题给出了以上三大算法的基本实现,但是需要根据测试框架的调度逻辑,实现未完成的测试函数。 本题偏重工程性质,在不断的调试中,会加深对算法的理解。
Tips
下面是check_grad函数的实现
def check_grad(func, X, epsilon, *args):
if len(X.shape) != 2 or X.shape[1] != 1:
raise ValueError("X must be a vector")
y, dy, = func(X, *args)[:2] # get the partial derivatives dy
dh = np.zeros((len(X), 1))
for j in xrange(len(X)):
dx = np.zeros((len(X), 1))
dx[j] += epsilon
y2 = func(X+dx, *args)[0]
dx = -dx
y1 = func(X+dx, *args)[0]
dh[j] = (y2 - y1)/(2*epsilon)
print np.hstack((dy, dh)) # print the two vectors
d = LA.norm(dh-dy)/LA.norm(dh+dy) # return norm of diff divided by norm of sum
return d
相关文章
- Python常用代码_python画图代码大全
- Python表白代码:太秀了,用过的人都找到了对象…【满屏玫瑰盛开】
- python常用面试题_Python+Selenium 常见面试题整理[通俗易懂]
- python监控网页内容变化_使用Python监控文件内容变化代码实例
- 【说站】python异常的传递
- 【说站】python自定义模块的调用
- python标识符命名规则和要求_python必背入门代码
- python代码自检工具 flake8简单介绍
- Python 生成、识别社会统一信用代码
- 有趣的python代码_python五角星代码
- 【Python画蜘蛛侠】谁的DNA动了?
- 1行Python代码,把PPT转成图片,python-office功能更新~
- Python入门的20行代码
- Python 进阶指南(编程轻松进阶):六、编写 Python 风格的代码
- Python面向对象编程-公有、私有和保护成员
- python-Python与MongoDB数据库-使用Python执行MongoDB查询(二)
- 40行python代码编写的计算器详解编程语言
- python编写的用于测试网站访问速率的代码片段详解编程语言
- python在windows命令行下输出彩色文字代码详解编程语言
- 如何使用 Sphinx 给 Python 代码写文档
- CherryTree 是一个支持无限层级分类的笔记软件,Python 编写,支持富文本编辑和代码高亮,支持 Mac、Linux、Windows平台。
- Python网络编程起步(Socket发送消息)
- python获取豆瓣电影简介代码分享
- Python开发实例分享bt种子爬虫程序和种子解析