From c93b5f51087c539cd77524c5c4249ac449e1fe56 Mon Sep 17 00:00:00 2001 From: pyq <14372110+tender0444@user.noreply.gitee.com> Date: Fri, 5 Jul 2024 13:24:09 +0000 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E5=B7=A5=E7=A8=8B2=E7=8F=AD?= =?UTF-8?q?=E8=A3=B4=E7=83=8A=E4=BB=9F=20=E8=BD=AF=E4=BB=B6=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B2=E7=8F=AD=E8=A3=B4=E7=83=8A=E4=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: pyq <14372110+tender0444@user.noreply.gitee.com> --- .../datas.py" | 156 ++++++++++++++++++ .../predict.py" | 21 +++ 2 files changed, 177 insertions(+) create mode 100644 "\350\275\257\344\273\266\345\267\245\347\250\2132\347\217\255\350\243\264\347\203\212\344\273\237/datas.py" create mode 100644 "\350\275\257\344\273\266\345\267\245\347\250\2132\347\217\255\350\243\264\347\203\212\344\273\237/predict.py" diff --git "a/\350\275\257\344\273\266\345\267\245\347\250\2132\347\217\255\350\243\264\347\203\212\344\273\237/datas.py" "b/\350\275\257\344\273\266\345\267\245\347\250\2132\347\217\255\350\243\264\347\203\212\344\273\237/datas.py" new file mode 100644 index 0000000..3a2bde8 --- /dev/null +++ "b/\350\275\257\344\273\266\345\267\245\347\250\2132\347\217\255\350\243\264\347\203\212\344\273\237/datas.py" @@ -0,0 +1,156 @@ +#房价预测 地区 面积 交通情况 1 2 是否为学区房 1 2 是否为新装修 1 2 价格 + +datas=[ + { + "position":"吕梁", + "area":100, + "transport":1, + "school":1, + "style":1, + "price":7000 + }, + { + "position":"吕梁", + "area":100, + "transport":1, + "school":1, + "style":1, + "price":6600 + }, + { + "position":"吕梁", + "area":100, + "transport":1, + "school":1, + "style":1, + "price":7400 + }, + { + "position":"吕梁", + "area":130, + "transport":2, + "school":1, + "style":1, + "price":6600 + }, + { + "position":"吕梁", + "area":130, + "transport":1, + "school":1, + "style":2, + "price":6000 + }, + { + "position": "吕梁", + "area": 130, + "transport": 1, + "school": 1, + "style": 2, + "price": 6000 + }, + { + "position": "吕梁", + "area": 150, + "transport": 1, + "school": 2, + "style": 2, + "price": 8000 + }, + { + "position": "吕梁", + "area": 150, + "school": 2, + "transport": 2, + "style": 2, + "price": 7800 + }, + { + "position": "吕梁", + "area": 130, + "transport": 2, + "school": 1, + "style": 2, + "price": 7400 + }, + { + "position": "吕梁", + "area": 130, + "transport": 1, + "school": 2, + "style": 2, + "price": 6900 + }, + { + "position": "吕梁", + "area": 130, + "transport": 1, + "school": 2, + "style": 1, + "price": 7500 + }, + { + "position": "吕梁", + "area": 130, + "transport": 2, + "school": 1, + "style": 1, + "price": 6600 + }, + { + "position": "吕梁", + "area": 130, + "transport": 1, + "school": 1, + "style": 2, + "price": 6000 + }, + { + "position": "太原", + "area": 130, + "transport": 1, + "school": 1, + "style": 2, + "price": 13000 + }, + { + "position": "太原", + "area": 150, + "transport": 1, + "school": 2, + "style": 2, + "price": 12000 + }, + { + "position": "太原", + "area": 150, + "transport": 2, + "school": 2, + "style": 2, + "price": 10800 + }, + { + "position": "太原", + "area": 130, + "transport": 2, + "school": 1, + "style": 2, + "price": 14000 + }, + { + "position": "太原", + "area": 130, + "transport": 1, + "school": 2, + "style": 2, + "price": 10900 + }, + { + "position": "太原", + "area": 130, + "transport": 1, + "school": 2, + "style": 1, + "price": 10000 + }, +] \ No newline at end of file diff --git "a/\350\275\257\344\273\266\345\267\245\347\250\2132\347\217\255\350\243\264\347\203\212\344\273\237/predict.py" "b/\350\275\257\344\273\266\345\267\245\347\250\2132\347\217\255\350\243\264\347\203\212\344\273\237/predict.py" new file mode 100644 index 0000000..85f0940 --- /dev/null +++ "b/\350\275\257\344\273\266\345\267\245\347\250\2132\347\217\255\350\243\264\347\203\212\344\273\237/predict.py" @@ -0,0 +1,21 @@ +import numpy as np +from datas import datas +X=[] +Y=[] +cityMark={"吕梁":1,"太原":2} +for item in datas: + single=[] + single.append(cityMark[item["position"]]) + single.append(item["area"]) + single.append(item["transport"]) + single.append(item["school"]) + single.append(item["style"]) + X.append(single) + Y.append(item["price"]) + +#print(X) +#print(Y) +X=np.array(X) +Y=np.array(Y) +theta=np.linalg.pinv(X.T.dot(X).dot(X.T)).dot(X.T).dot(Y) +print(theta) \ No newline at end of file -- Gitee