From 2d567c13937dba0ed9b0fa74eac71b6b73e3e67d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=99=93=E6=A2=A620211106121?= <14647666+coconyc@user.noreply.gitee.com> Date: Fri, 5 Jul 2024 21:13:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E8=BD=AF=E5=B7=A52101=E5=88=98?= =?UTF-8?q?=E6=99=93=E6=A2=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pythonProject3/.idea/.gitignore | 8 ++ .../inspectionProfiles/profiles_settings.xml | 6 + pythonProject3/.idea/misc.xml | 7 ++ pythonProject3/.idea/modules.xml | 8 ++ pythonProject3/.idea/pythonProject3.iml | 10 ++ .../__pycache__/datas.cpython-312.pyc | Bin 0 -> 784 bytes pythonProject3/datas.py | 111 ++++++++++++++++++ pythonProject3/predict.py | 27 +++++ 8 files changed, 177 insertions(+) create mode 100644 pythonProject3/.idea/.gitignore create mode 100644 pythonProject3/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 pythonProject3/.idea/misc.xml create mode 100644 pythonProject3/.idea/modules.xml create mode 100644 pythonProject3/.idea/pythonProject3.iml create mode 100644 pythonProject3/__pycache__/datas.cpython-312.pyc create mode 100644 pythonProject3/datas.py create mode 100644 pythonProject3/predict.py diff --git a/pythonProject3/.idea/.gitignore b/pythonProject3/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /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 0000000..105ce2d --- /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 0000000..2a08db1 --- /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 0000000..1fb3c8b --- /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 0000000..2c80e12 --- /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 GIT binary patch literal 784 zcma))J4?e*7>2(jJxSV{Hi@<9;BAs36mOG=2s(;(mM)F((|7VHHG>H>^Qo46^F0{l2FAdZgMwTakzu=0F?j3SQg-rhE45ghG SG05}^)`cBT=J$xre)o4}c+CX> literal 0 HcmV?d00001 diff --git a/pythonProject3/datas.py b/pythonProject3/datas.py new file mode 100644 index 0000000..fe5cc9f --- /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 0000000..a88b6a6 --- /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 -- Gitee