From b18ee1583ab3883fe5c61f5d77df661373e231a0 Mon Sep 17 00:00:00 2001 From: zjx <3099123314@qq.com> Date: Fri, 5 Jul 2024 23:32:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=B5=E5=AE=B6=E6=97=AD=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..02fbcf4 --- /dev/null +++ b/pythonProject/.idea/.name @@ -0,0 +1 @@ +datas.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..82d9b20 --- /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..c24009a --- /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..883c45c --- /dev/null +++ b/pythonProject/datas.py @@ -0,0 +1,64 @@ + + +datas=[ + { + "city":"阜阳", + "area":120, + "rooms":2, + "school":2, + "style":1, + "price":9000, + }, +{ + "city":"阜阳", + "area":150, + "rooms":2, + "school":3, + "style":1, + "price":9800, + }, +{ + "city":"阜阳", + "area":150, + "rooms":2, + "school":1, + "style":1, + "price":12000, + }, + + +{ + "city":"合肥", + "area":100, + "rooms":2, + "school":3, + "style":1, + "price":15000, + }, +{ + "city":"合肥", + "area":130, + "rooms":2, + "school":1, + "style":1, + "price":12000, + }, +{ + "city":"合肥", + "area":150, + "rooms":2, + "school":3, + "style":1, + "price":20000, + }, +] + +# 各 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..9f9483a --- /dev/null +++ b/pythonProject/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