diff --git a/07.05/0705/__pycache__/datas.cpython-312.pyc b/07.05/0705/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1abbbc37bae56cbd7b711932b5989ca0f67ccec6 Binary files /dev/null and b/07.05/0705/__pycache__/datas.cpython-312.pyc differ diff --git a/07.05/0705/datas.py b/07.05/0705/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..57e5d3604f43e8611fb27f2a56afa5c6bb806bb1 --- /dev/null +++ b/07.05/0705/datas.py @@ -0,0 +1,172 @@ +# 经验来源于数据 +# 大数据 很多的数据 + +# 预测地方房价 +# 预测太原,吕梁房价 +# 1. 模拟太原和吕梁的房价数据 +# 模拟吕梁的房子数据 +datas=[ + # 模拟吕梁的第一类房子 + { + "city":"吕梁", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000 + }, + { + "city": "吕梁", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 7800 + }, + { + "city": "吕梁", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 8200 + }, + # 模拟吕梁的第二类房子 + { + "city":"吕梁", + "area":130, + "rooms":3, + "school":1, + "style":1, + "price":8300 + }, + { + "city": "吕梁", + "area": 135, + "rooms": 3, + "school": 1, + "style": 1, + "price": 8450 + }, + { + "city": "吕梁", + "area": 140, + "rooms": 3, + "school": 1, + "style": 1, + "price": 8600 + }, + # 模拟吕梁的第三类房子 + { + "city":"吕梁", + "area":130, + "rooms":3, + "school":2, + "style":2, + "price":7000 + }, + { + "city": "吕梁", + "area": 135, + "rooms": 3, + "school": 2, + "style": 2, + "price": 6500 + }, + { + "city": "吕梁", + "area": 140, + "rooms": 3, + "school": 2, + "style": 2, + "price": 6200 + }, +] +# 模拟太原房价数据 +datas=[ + # 模拟太原的第一类房子 + { + "city":"太原", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":10100 + }, + { + "city": "太原", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 10300 + }, + { + "city": "太原", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 10500 + }, + # 模拟太原的第二类房子 + { + "city":"太原", + "area":135, + "rooms":3, + "school":1, + "style":1, + "price":12120 + }, + { + "city": "太原", + "area": 135, + "rooms": 3, + "school": 1, + "style": 1, + "price": 12300 + }, + { + "city": "太原", + "area": 140, + "rooms": 3, + "school": 1, + "style": 1, + "price": 12600 + }, + # 模拟太原的第三类房子 + { + "city":"太原", + "area":130, + "rooms":3, + "school":2, + "style":2, + "price":8000 + }, + { + "city": "太原", + "area": 135, + "rooms": 3, + "school": 2, + "style": 2, + "price": 8300 + }, + { + "city": "太原", + "area": 140, + "rooms": 3, + "school": 2, + "style": 2, + "price": 8600 + }, + # 模拟房价数据的权重计算 + # 3000 10 1000 1300 1500 + # 太原2 100 3 1 1 + # 3000+1400+3000+2600+3000 + # 城市 x1 面积 x2 房间数 x3 学校 x4 样式 x5 + # x1=1 x2=100 x3=3 x4=1 x5=1 + # a1*1+a2*2+a3*3+a4*4+a5*5=y + # [a1,a2,......] 数学模型 机器学习 机器学习软件开发 + + ] + diff --git a/07.05/0705/predict.py b/07.05/0705/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..b21590e1d9eef9bfc7d6ca50cfbd44c49d9ebb44 --- /dev/null +++ b/07.05/0705/predict.py @@ -0,0 +1,26 @@ +# 1. 安装一个科学与计算的框架 +import numpy as np +from datas import datas +X=[] +Y=[] +cityMark={"吕梁":1,"太原":2} +for item in datas: + single=[] + #城市 + single.append(cityMark[item["city"]]) + #面积 + single.append(item["area"]) + #rooms + single.append(item["rooms"]) + #school + single.append(item["school"]) + #style + single.append(item["style"]) + X.append(single) + Y.append(item["price"]) + +X = np.array(X) +Y = np.array(Y) +theta = np.linalg.pinv(X.T.dot(X)).dot(X.T).dot(Y) +print(theta) +