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 0000000000000000000000000000000000000000..3a2bde827852af05fbdb9fa9895c1f81d053ca14 --- /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 0000000000000000000000000000000000000000..85f09402e45ac62a6c8020304a44d4edeb53b955 --- /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