diff --git a/pythonProject1/.idea/.gitignore b/pythonProject1/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..35410cacdc5e87f985c93a96520f5e11a5c822e4 --- /dev/null +++ b/pythonProject1/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/pythonProject1/.idea/inspectionProfiles/profiles_settings.xml b/pythonProject1/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/pythonProject1/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/pythonProject1/.idea/misc.xml b/pythonProject1/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..4cfae71e48e7de9dec98befb9355e2b1b5ff7b53 --- /dev/null +++ b/pythonProject1/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/pythonProject1/.idea/modules.xml b/pythonProject1/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..fdd8fdfd13437ad5929c98cfa256df55ff0f5e08 --- /dev/null +++ b/pythonProject1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject1/.idea/pythonProject1.iml b/pythonProject1/.idea/pythonProject1.iml new file mode 100644 index 0000000000000000000000000000000000000000..d0876a78d06ac03b5d78c8dcdb95570281c6f1d6 --- /dev/null +++ b/pythonProject1/.idea/pythonProject1.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject1/__pycache__/dates.cpython-312.pyc b/pythonProject1/__pycache__/dates.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1f24dfa151e466ba16886c585544ee03bb48c6b6 Binary files /dev/null and b/pythonProject1/__pycache__/dates.cpython-312.pyc differ diff --git a/pythonProject1/dates.py b/pythonProject1/dates.py new file mode 100644 index 0000000000000000000000000000000000000000..7de0ba88bfb29351b3acef4ef597a7c391f725c6 --- /dev/null +++ b/pythonProject1/dates.py @@ -0,0 +1,154 @@ +dates=[ + # 模拟吕梁的第一类房子 + { + "city":"吕梁", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":7000 + }, + { + "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 + }, +] +# 模拟太原房价数据 +dates=[ + # 模拟太原的第一类房子 + { + "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 + },] \ No newline at end of file diff --git a/pythonProject1/predict.py b/pythonProject1/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..a249d57366449a46baf88847991bc9e6e50bb9a9 --- /dev/null +++ b/pythonProject1/predict.py @@ -0,0 +1,28 @@ + +import numpy as np +from dates import dates +X=[] +Y=[] +cityMark={"吕梁":1,"太原":2} +for item in dates: + + 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]))) \ No newline at end of file diff --git a/pythonProject1/predict1.py b/pythonProject1/predict1.py new file mode 100644 index 0000000000000000000000000000000000000000..3886e75914d106fc682061e9e1c413020ccfab6c --- /dev/null +++ b/pythonProject1/predict1.py @@ -0,0 +1,11 @@ +#先安装一个 科学计算的框架 +import numpy as np + +a=np.array([[3,2,3],[3,2,3,],[3,2,3]]) +b=np.array([1,2,3]) +print(a.dot(b)) +#奇异矩阵 +#求 点乘 转置 逆 +print(a.T) +print(a.dot(b)) +print(np.linalg.pinv(a)) \ No newline at end of file