diff --git a/7.5/__pycache__/datas.cpython-312.pyc b/7.5/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b92e4d0caaf2dbdbd14a52a1c1aaf3f5589b3a48 Binary files /dev/null and b/7.5/__pycache__/datas.cpython-312.pyc differ diff --git a/7.5/abc.py b/7.5/abc.py new file mode 100644 index 0000000000000000000000000000000000000000..16697108855471f3e08a5938ac7207e40c4bebf8 --- /dev/null +++ b/7.5/abc.py @@ -0,0 +1,25 @@ + +import numpy as np +#a=np.array([[1,2,3],[1,2,3],[1,2,3]]) +#b=np.array([1,2,3]) +#print(a.dot(b))#点乘 +#print(a.T)#转置 +#print(np.linalg.pinv(a))#逆 +from datas import datas +X=[] +Y=[] +cityMark={"吕梁":1,"太原":2} +for item in datas: + single=[] + single.append(cityMark[item["city"]]) + single.append(item["area"]) + single.append(item["rooms"]) + single.append(item["school"]) + 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.dot(np.array([2,100,2,1,2]))) diff --git a/7.5/datas.py b/7.5/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..bd9f5fc961b3583d8b8808d1d1a153d4e4715324 --- /dev/null +++ b/7.5/datas.py @@ -0,0 +1,155 @@ +#模拟太原和吕梁的房价的数据 预测系统 +#怎么模拟 城市 面积 户型 是不是学区房 装修的风格 +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":8500 + }, + { + "city": "吕梁", + "area": 135, + "rooms": 3, + "school": 1, + "style": 1, + "price": 8300 + }, + { + "city": "吕梁", + "area": 140, + "rooms": 3, + "school": 1, + "style": 1, + "price": 8600 + }, + #模拟的吕梁第三类房子 + { + "city":"吕梁", + "area":130, + "rooms":3, + "school":2, + "style":2, + "price":6500 + }, + { + "city": "吕梁", + "area": 135, + "rooms": 3, + "school": 2, + "style": 2, + "price": 6300 + }, + { + "city": "吕梁", + "area": 140, + "rooms": 3, + "school": 2, + "style": 2, + "price": 5600 + }, + #模拟的太原第一类房子 + { + "city":"太原", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":10000 + }, + { + "city": "太原", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 9800 + }, + { + "city": "太原", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 9200 + }, + #模拟的太原第二类房子 + { + "city":"太原", + "area":130, + "rooms":3, + "school":1, + "style":1, + "price":10500 + }, + { + "city": "太原", + "area": 135, + "rooms": 3, + "school": 1, + "style": 1, + "price": 10300 + }, + { + "city": "太原", + "area": 140, + "rooms": 3, + "school": 1, + "style": 1, + "price": 10600 + }, + #模拟的太原第三类房子 + { + "city":"太原", + "area":130, + "rooms":3, + "school":2, + "style":2, + "price":8500 + }, + { + "city": "太原", + "area": 135, + "rooms": 3, + "school": 2, + "style": 2, + "price": 8300 + }, + { + "city": "太原", + "area": 140, + "rooms": 3, + "school": 2, + "style": 2, + "price": 8600 + }, + +] \ No newline at end of file