摘要:本文主要向大家介绍了机器学习入门之机器学习二,通过具体的内容向大家展现,希望对大家学习机器学习入门有所帮助。
本文主要向大家介绍了机器学习入门之机器学习二,通过具体的内容向大家展现,希望对大家学习机器学习入门有所帮助。
一、机器学习类库资料(Scipy Lecture Notes)
参考链接: https://wizardforcel.gitbooks.io/scipy-lecture-notes/content/0.html
二、练习题
练习:斐波那契数列
写一个函数来展示斐波那契数列的前n个项目,定义如下:
- u_0 = 1; u_1 = 1
- u_(n+2) = u_(n+1) + u_n
答案:
def fb(n):
u_0 = 1
u_1 = 1
if n == 0:
return [1]
elif n == 1:
return [1,1]
else:
temp = [u_0,u_1]
for i in range(n):
if i >= 2:
res = temp[i-1] + temp[i-2]
temp.append(res)
return temp
练习:快速排序
def quick_sort(list_,start,end):
if start >= end:
return
cmp_index = start
for i in range(start+1,end):
if list_[i] < list_[cmp_index]:
tmp = list_[i]
del list_[i]
list_.insert(cmp_index,tmp)
cmp_index += 1
quick_sort(list_,start=start,end=cmp_index-1)
quick_sort(list_,start=cmp_index+1,end=len(list_))
num = [4,7,1,-2,6,3,2,3]
quick_sort(num,0,len(num))
print(num)
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标人工智能机器学习频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号