摘要: 单变量线性回归 2.1 单变量线性函数 假设函数 hθ(x) = θ0 + θ1x代价函数:平方误差函数或者平方误差代价函数 h(x(i))是预测值,也写做y帽,y(i)是实际值,两者取差分母的2是为了后续求偏导更好计算。 目标: 最小化代价函数,即minimize J(θ0, θ1) 得到的代价函 阅读全文
posted @ 2024-08-01 14:33 鹤比纷恆红 阅读(71) 评论(0) 推荐(0)
摘要: 1 机器学习定义 计算机程序从经验E中学习,解决某一任务T,进行某一性能P,通过P测定在T上的表现因经验E而提高 eg:跳棋程序E: 程序自身下的上万盘棋局T: 下跳棋P: 与新对手下跳棋时赢的概率 2 监督学习 supervised learning 2.1 监督学习定义 给算法一个数据集,其中包 阅读全文
posted @ 2024-08-01 09:22 鹤比纷恆红 阅读(60) 评论(0) 推荐(0)
摘要: 7.1 创建和使用类 class Dog(): # 一次模拟小狗的简单尝试””" def_init_(self,name,age): # "“初始化属性name,age""" self.name = name self.age = age def sit(self): # ""模拟小狗收到命令时蹲下 阅读全文
posted @ 2024-07-28 07:14 鹤比纷恆红 阅读(37) 评论(0) 推荐(0)
摘要: 6.1 定义函数 def greet_user(): """显示简单的问候语""" print('Hello!') greet_user() # 调用函数 6.1.1 向函数传递信息 def greet_user(username): "“显示简单的问候语"” print(f"Hello,{user 阅读全文
posted @ 2024-07-27 17:53 鹤比纷恆红 阅读(29) 评论(0) 推荐(0)
摘要: 5.1 函数input()工作原理 # 变量=input(参数:说明/提示) message input("Tell me something,and I will repeat it back to you:" print(message) prompt ="If you tell us who 阅读全文
posted @ 2024-07-27 16:17 鹤比纷恆红 阅读(38) 评论(0) 推荐(0)
摘要: 4.1 一个简单的字典(键值对) # 外星人颜色(绿色)+分数(5) alien_0 = {'color':'green','points':5} print(alien_0['color']) #想要获取值(green),指定字典名(alie_0)+键(color) print(alien_0[' 阅读全文
posted @ 2024-07-27 15:06 鹤比纷恆红 阅读(45) 评论(0) 推荐(0)
摘要: 3.1 一个简单实例 cars = ['audi','bmw','subaru','toyota'] for car in cars: if car == 'bmw': pirnt(car.upper()) else: pirnt(car.title()) Audi BMW Subaru Toyot 阅读全文
posted @ 2024-07-03 16:24 鹤比纷恆红 阅读(65) 评论(0) 推荐(0)
摘要: 2.1 列表是什么 bicycles = ['trek','cannondale','redline','specialized'] print(bicycles) 结果:['trek','cannondale','redline','specialized'] ① 访问列表元素 bicycles 阅读全文
posted @ 2024-07-03 14:38 鹤比纷恆红 阅读(38) 评论(0) 推荐(0)
摘要: 1.1 变量的命名和适用 ① 必须是字母,数字,下划线。不能数字开头 message = "xxxx" 1_message = "xxxx"(不行) _message = "xxx" 0 = "xxx"(不行) ② 常变量名之间不能有空格 greeting message = "xxx"(不行) g 阅读全文
posted @ 2024-07-01 15:53 鹤比纷恆红 阅读(44) 评论(0) 推荐(0)