From 8e9575a7cc5ee44b93fde13afb513af24cf9d41e Mon Sep 17 00:00:00 2001 From: Ain <1943664026@qq.com> Date: Fri, 5 Jul 2024 20:07:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E5=B7=A51=E7=8F=AD=E5=90=B4=E4=BF=8A?= =?UTF-8?q?=E6=9D=B0=207.5=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 7.5/.idea/.gitignore | 8 ++ 7.5/.idea/7.5.iml | 10 ++ .../inspectionProfiles/profiles_settings.xml | 6 ++ 7.5/.idea/misc.xml | 7 ++ 7.5/.idea/modules.xml | 8 ++ 7.5/__pycache__/datas.cpython-312.pyc | Bin 0 -> 705 bytes 7.5/datas.py | 87 ++++++++++++++++++ 7.5/predict.py | 32 +++++++ 8 files changed, 158 insertions(+) create mode 100644 7.5/.idea/.gitignore create mode 100644 7.5/.idea/7.5.iml create mode 100644 7.5/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 7.5/.idea/misc.xml create mode 100644 7.5/.idea/modules.xml create mode 100644 7.5/__pycache__/datas.cpython-312.pyc create mode 100644 7.5/datas.py create mode 100644 7.5/predict.py diff --git a/7.5/.idea/.gitignore b/7.5/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/7.5/.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/7.5/.idea/7.5.iml b/7.5/.idea/7.5.iml new file mode 100644 index 0000000..2c80e12 --- /dev/null +++ b/7.5/.idea/7.5.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/7.5/.idea/inspectionProfiles/profiles_settings.xml b/7.5/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/7.5/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/7.5/.idea/misc.xml b/7.5/.idea/misc.xml new file mode 100644 index 0000000..f25cb9c --- /dev/null +++ b/7.5/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/7.5/.idea/modules.xml b/7.5/.idea/modules.xml new file mode 100644 index 0000000..6b331e2 --- /dev/null +++ b/7.5/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/7.5/__pycache__/datas.cpython-312.pyc b/7.5/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..97a4d63c15181d751863e365705aa93f67911efc GIT binary patch literal 705 zcmX@j%ge<81Q%Dgr=_tmFgylvU_b!M_`Cwhn9h*GkiwY4l)?;zEGevW*noVt6m~G5 z1Ip)w^0}aVZXllt2zj7~@6Nq305}6M23=EoVw^))hODb=%Bo?J6-eN7v&(AHs z#a5i0k)NM)i?z6Hiu4L9e{tC4=BJeAq}mk;1J#2(P|N`&KQJ>gGJfD=5RkaR tFLXmd@P;6m6cG8y%g)O7L1;iEL~&V8x&$GA1TzIOaxyit76}4F1ON}1xr+b* literal 0 HcmV?d00001 diff --git a/7.5/datas.py b/7.5/datas.py new file mode 100644 index 0000000..e95e130 --- /dev/null +++ b/7.5/datas.py @@ -0,0 +1,87 @@ +# 经验就是来源于数据 +# 大数据 爬虫 后天 +# 模拟太原和吕梁的房价的数据 +#怎么模拟 城市 面积 户型 是不是学区房 装修的风格 +datas = [ + { + "city":"吕梁", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000 + }, + { + "city":"吕梁", + "area":130, + "rooms":3, + "school":1, + "style":1, + "price":8500 + }, + { + "city":"吕梁", + "area":135, + "rooms":3, + "school":1, + "style":1, + "price":8300 + }, + { + "city":"吕梁", + "area":140, + "rooms":3, + "school":2, + "style":2, + "price":5600 + }, + { + "city":"吕梁", + "area":100, + "rooms":2, + "school":2, + "style":2, + "price":4000 + }, + { + "city":"太原", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":10000 + }, + { + "city":"太原", + "area":130, + "rooms":3, + "school":1, + "style":1, + "price":10500 + }, + { + "city":"太原", + "area":135, + "rooms":3, + "school":1, + "style":1, + "price":10300 + }, + { + "city":"太原", + "area":140, + "rooms":3, + "school":2, + "style":2, + "price":8600 + }, + { + "city":"太原", + "area":100, + "rooms":2, + "school":2, + "style":2, + "price":6500 + } + +] \ No newline at end of file diff --git a/7.5/predict.py b/7.5/predict.py new file mode 100644 index 0000000..46192ab --- /dev/null +++ b/7.5/predict.py @@ -0,0 +1,32 @@ +# #1.先安装一个科学计算的框架 +# import numpy as np +# a=np.array([[3,2,3],[3,2,3],[3,2,3]]) +# b=np.array([1,2,3]) +# #奇异矩阵 点乘 转置 逆 +# print(a.T) +# print(a.dot(b)) +# print(np.linalg.pinv(a)) +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