diff --git a/pythonProject3/.idea/.gitignore b/pythonProject3/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /dev/null +++ b/pythonProject3/.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/pythonProject3/.idea/inspectionProfiles/profiles_settings.xml b/pythonProject3/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/pythonProject3/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/pythonProject3/.idea/misc.xml b/pythonProject3/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..2a08db1706d0c3bcef43f907d58b10d624f3f7de --- /dev/null +++ b/pythonProject3/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/pythonProject3/.idea/modules.xml b/pythonProject3/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..1fb3c8be37acbe2ac220221f9983c305224ff79c --- /dev/null +++ b/pythonProject3/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject3/.idea/pythonProject3.iml b/pythonProject3/.idea/pythonProject3.iml new file mode 100644 index 0000000000000000000000000000000000000000..2c80e1269497d12e018fd6afa29982e56b0fb70d --- /dev/null +++ b/pythonProject3/.idea/pythonProject3.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pythonProject3/__pycache__/datas.cpython-312.pyc b/pythonProject3/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2442da092d9841da64a393fe5fdc46ffa4ea953c Binary files /dev/null and b/pythonProject3/__pycache__/datas.cpython-312.pyc differ diff --git a/pythonProject3/datas.py b/pythonProject3/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..fe5cc9f7db2e6e133fe1de1f194fdeae2fb31c98 --- /dev/null +++ b/pythonProject3/datas.py @@ -0,0 +1,111 @@ +datas= [ +#模拟吕梁第一类房屋 + { +"city":"吕梁", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 8000 + }, + + { + "city": "吕梁", + "area": 100, + "rooms": 2, + "school": 2, + "style": 1, + "price": 7900 + + }, + + { + "city":"吕梁", +"area": 100, +"rooms": 2, +"school": 1, +"style": 1, +"price": 8000 + +}, +#第二类 + { + "city":"吕梁", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000 + + }, + + { + "city":"吕梁", +"area": 100, +"rooms": 2, +"school": 1, +"style": 1, +"price": 8000 +}, + + { + "city": "吕梁", +"area": 100, +"rooms": 2, +"school": 1, +"style": 1, +"price": 8000 + + }, + +#太原第一类 +{ +"city": "太原", +"area": 130, +"rooms": 3, +"school": 2, +"style": 2, +"price": 10000 +}, +{ +"city": "太原", +"area": 135, +"rooms": 3, +"school": 2, +"style": 2, +"price": 8300 +}, + +{ +"city": "太原", +"area": 140, +"rooms": 3, +"school": 2, +"style": 2, +"price": 8600 +}, + +#太原第二类 + { +"city": "太原", +"area": 140, +"rooms": 2, +"school": 2, +"style": 2, +"price": 7500 +}, + {"city": "太原", +"area": 145, +"rooms": 2, +"school": 2, +"style": 2, +"price": 8600 +}, + {"city": "太原", +"area": 135, +"rooms": 3, +"school": 1, +"style": 2, +"price": 8000 +}, +] \ No newline at end of file diff --git a/pythonProject3/predict.py b/pythonProject3/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..a88b6a6431af6a9e9de0baa8cfa6e0985d7b8ccf --- /dev/null +++ b/pythonProject3/predict.py @@ -0,0 +1,27 @@ +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]))) \ No newline at end of file