diff --git a/pythonProject/.idea/.gitignore b/pythonProject/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /dev/null +++ b/pythonProject/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/pythonProject/.idea/inspectionProfiles/profiles_settings.xml b/pythonProject/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/pythonProject/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/pythonProject/.idea/misc.xml b/pythonProject/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..2a01189048dd51552f6ba99bf21b7c67f3613c98 --- /dev/null +++ b/pythonProject/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/pythonProject/.idea/modules.xml b/pythonProject/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..e15ec35fe054f3b2c7c21e3dcca866d6a79ca0ba --- /dev/null +++ b/pythonProject/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject/.idea/pythonProject.iml b/pythonProject/.idea/pythonProject.iml new file mode 100644 index 0000000000000000000000000000000000000000..2c80e1269497d12e018fd6afa29982e56b0fb70d --- /dev/null +++ b/pythonProject/.idea/pythonProject.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pythonProject/7.5/__pycache__/datas.cpython-312.pyc b/pythonProject/7.5/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1c7e899513a9c8b84e1fc1922746770664060155 Binary files /dev/null and b/pythonProject/7.5/__pycache__/datas.cpython-312.pyc differ diff --git a/pythonProject/7.5/datas.py b/pythonProject/7.5/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..ed9304d510b6992ab848892d0b20f90e5e557ed3 --- /dev/null +++ b/pythonProject/7.5/datas.py @@ -0,0 +1,152 @@ +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/pythonProject/7.5/predict.py b/pythonProject/7.5/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..2600a3e93e758c935870555b4b40b7b03e4e8d94 --- /dev/null +++ b/pythonProject/7.5/predict.py @@ -0,0 +1,27 @@ +import numpy as np + +from datas import datas +X=[] +Y=[] +cityMark={"吕梁":1, "太原":2} +for itme in datas: + single=[] + #城市 + single.append(cityMark[itme["city"]]) + #面积 + single.append(itme["area"]) + #房间数 + single.append(itme["rooms"]) + #学区房 + single.append(itme["school"]) + #装修 + single.append(itme["style"]) + X.append(single) + Y.append(itme["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])))