diff --git a/7.5/__pycache__/datas.cpython-312.pyc b/7.5/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2c8d4887ca29edf5f01e03087f36f581f752d4f0 Binary files /dev/null and b/7.5/__pycache__/datas.cpython-312.pyc differ diff --git a/7.5/datas.py b/7.5/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..74ec37d25780324857a277f1c122da2270ebbe90 --- /dev/null +++ b/7.5/datas.py @@ -0,0 +1,154 @@ +#模拟太原和吕梁的房价的数据 预测系统 +#怎么模拟 城市 面积 户型 是不是学区房 装修的风格 +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 diff --git a/7.5/predict.py b/7.5/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..0b82091cd8053403e0296f24b569c65ba1cab7ea --- /dev/null +++ b/7.5/predict.py @@ -0,0 +1,23 @@ +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"]) + 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,1]))) + + + +