From d334dff15c7b49cc6dac47420d66f157a65f8538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B3=E9=B9=8F=E5=8B=83?= <2316120172@qq.com> Date: Sat, 6 Jul 2024 09:18:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B3=E9=B9=8F=E5=8B=83=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 --- zuoye/.idea/.gitignore | 8 +++ zuoye/.idea/.name | 1 + .../inspectionProfiles/profiles_settings.xml | 6 ++ zuoye/.idea/misc.xml | 7 ++ zuoye/.idea/modules.xml | 8 +++ zuoye/.idea/pythonProject.iml | 10 +++ zuoye/.idea/vcs.xml | 6 ++ zuoye/__pycache__/datas.cpython-312.pyc | Bin 0 -> 519 bytes zuoye/datas.py | 64 ++++++++++++++++++ zuoye/reddict.py | 48 +++++++++++++ 10 files changed, 158 insertions(+) create mode 100644 zuoye/.idea/.gitignore create mode 100644 zuoye/.idea/.name create mode 100644 zuoye/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 zuoye/.idea/misc.xml create mode 100644 zuoye/.idea/modules.xml create mode 100644 zuoye/.idea/pythonProject.iml create mode 100644 zuoye/.idea/vcs.xml create mode 100644 zuoye/__pycache__/datas.cpython-312.pyc create mode 100644 zuoye/datas.py create mode 100644 zuoye/reddict.py diff --git a/zuoye/.idea/.gitignore b/zuoye/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/zuoye/.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/zuoye/.idea/.name b/zuoye/.idea/.name new file mode 100644 index 0000000..35c0710 --- /dev/null +++ b/zuoye/.idea/.name @@ -0,0 +1 @@ +reddict.py \ No newline at end of file diff --git a/zuoye/.idea/inspectionProfiles/profiles_settings.xml b/zuoye/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/zuoye/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/zuoye/.idea/misc.xml b/zuoye/.idea/misc.xml new file mode 100644 index 0000000..2a01189 --- /dev/null +++ b/zuoye/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/zuoye/.idea/modules.xml b/zuoye/.idea/modules.xml new file mode 100644 index 0000000..e15ec35 --- /dev/null +++ b/zuoye/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/zuoye/.idea/pythonProject.iml b/zuoye/.idea/pythonProject.iml new file mode 100644 index 0000000..2c80e12 --- /dev/null +++ b/zuoye/.idea/pythonProject.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/zuoye/.idea/vcs.xml b/zuoye/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/zuoye/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/zuoye/__pycache__/datas.cpython-312.pyc b/zuoye/__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/zuoye/datas.py b/zuoye/datas.py new file mode 100644 index 0000000..485c95c --- /dev/null +++ b/zuoye/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/zuoye/reddict.py b/zuoye/reddict.py new file mode 100644 index 0000000..630fecc --- /dev/null +++ b/zuoye/reddict.py @@ -0,0 +1,48 @@ + +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) +print(x) +print(y) + + +theta=np.linalg.pinv(x.T.dot(x)).dot(x.T).dot(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