From cb9c901f8bcf8e3943b41792550e7e7b8ab1d7c0 Mon Sep 17 00:00:00 2001 From: majianrui <1930103283@qq.com> Date: Sat, 6 Jul 2024 10:35:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A9=AC=E5=81=A5=E7=9D=BF=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pythonProject/.idea/.gitignore | 8 +++ pythonProject/.idea/.name | 1 + .../inspectionProfiles/profiles_settings.xml | 6 ++ pythonProject/.idea/misc.xml | 7 ++ pythonProject/.idea/modules.xml | 8 +++ pythonProject/.idea/pythonProject.iml | 10 +++ pythonProject/.idea/vcs.xml | 6 ++ .../__pycache__/datas.cpython-312.pyc | Bin 0 -> 519 bytes pythonProject/datas.py | 64 ++++++++++++++++++ pythonProject/reddict.py | 48 +++++++++++++ 10 files changed, 158 insertions(+) create mode 100644 pythonProject/.idea/.gitignore create mode 100644 pythonProject/.idea/.name create mode 100644 pythonProject/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 pythonProject/.idea/misc.xml create mode 100644 pythonProject/.idea/modules.xml create mode 100644 pythonProject/.idea/pythonProject.iml create mode 100644 pythonProject/.idea/vcs.xml create mode 100644 pythonProject/__pycache__/datas.cpython-312.pyc create mode 100644 pythonProject/datas.py create mode 100644 pythonProject/reddict.py diff --git a/pythonProject/.idea/.gitignore b/pythonProject/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /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/.name b/pythonProject/.idea/.name new file mode 100644 index 0000000..35c0710 --- /dev/null +++ b/pythonProject/.idea/.name @@ -0,0 +1 @@ +reddict.py \ No newline at end of file diff --git a/pythonProject/.idea/inspectionProfiles/profiles_settings.xml b/pythonProject/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /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 0000000..2a01189 --- /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 0000000..e15ec35 --- /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 0000000..2c80e12 --- /dev/null +++ b/pythonProject/.idea/pythonProject.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pythonProject/.idea/vcs.xml b/pythonProject/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/pythonProject/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pythonProject/__pycache__/datas.cpython-312.pyc b/pythonProject/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bf3e684343b76adf9cc0b44d12d0ba8cb2aced65 GIT binary patch literal 519 zcmX@j%ge<81R5LK({xxF7#@Q-Fu((4e9izerZc24q%fv1r7!~_OA6~8HXxr3%4di2 zIiP$_FrN#qo*T-Cspo<6Vd{B7{B*V`hDtt7{!%uebx$WueYU9aWeSk_k_kjG0*Ooq zc?Jeewp%R8nI)CCSQ3j;6K}B=<>%)X-(o9H&dATtxy4#sQkj!_i?yIAGdcBT6G&5q z98mi-5Q{^BfdOLrl2uRp=4T410|hCIv)3^0KqCeGtMb!H7pf3`2(~&?tO5aM}^hXw1&k$Xdh?bSD6- C?~C04 literal 0 HcmV?d00001 diff --git a/pythonProject/datas.py b/pythonProject/datas.py new file mode 100644 index 0000000..485c95c --- /dev/null +++ b/pythonProject/datas.py @@ -0,0 +1,64 @@ + + +datas=[ + { + "city":"吕梁", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000, + }, +{ + "city":"吕梁", + "area":130, + "rooms":2, + "school":1, + "style":1, + "price":7800, + }, +{ + "city":"吕梁", + "area":150, + "rooms":2, + "school":1, + "style":1, + "price":8200, + }, + + +{ + "city":"太原", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":10000, + }, +{ + "city":"太原", + "area":130, + "rooms":2, + "school":1, + "style":1, + "price":9800, + }, +{ + "city":"太原", + "area":150, + "rooms":2, + "school":1, + "style":1, + "price":8500, + }, +] + +# 各 3000 10 1000 1300 1500 +# 城市 面积 房间数量 学区房 装修 各个元素的权重 a1 a2 a3 a4 a5 +# 总价即总分 : p +# 各个元素*各个元素的权重之和即为分数 +# 城市: x1 例: 县=1 市=2 +# 面积: x2 按平方米计量 +# 房间数量: x3 个数 +# 学区房 : bool 0/1 +# 装修: bool 0/1 是否精装修 \ No newline at end of file diff --git a/pythonProject/reddict.py b/pythonProject/reddict.py new file mode 100644 index 0000000..9e00cfd --- /dev/null +++ b/pythonProject/reddict.py @@ -0,0 +1,48 @@ + +import num 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.appnd(item["price"]) + +x=np.array(x) +y=np.array(y) +print(x) +print(y) + + +theta=np.linalg.pinv(x.T.do(x)).do(x.T).do(y) + +print(theta.dot(np.array([2,100,2,1,1]))) + + +#a=np.array([[1,2,3],[1,2,3]]) +#b=np.array([1,2,3) +#print(a.dot(b)) #点乘 + + +#print(a) +#print(a.T) #转置矩阵 + + +#print(np.linalg.pinv(a)) #矩阵求逆 + + + -- Gitee