From a8612eba1229d908ccd5ef3b01cf04c66d27ae4c Mon Sep 17 00:00:00 2001 From: bea <3208465014@qq.com> Date: Fri, 5 Jul 2024 18:42:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E6=99=A8=E9=9B=85=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 --- 7.5/__pycache__/datas.cpython-312.pyc | Bin 0 -> 1078 bytes 7.5/abc.py | 25 +++++ 7.5/datas.py | 155 ++++++++++++++++++++++++++ 3 files changed, 180 insertions(+) create mode 100644 7.5/__pycache__/datas.cpython-312.pyc create mode 100644 7.5/abc.py create mode 100644 7.5/datas.py diff --git a/7.5/__pycache__/datas.cpython-312.pyc b/7.5/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b92e4d0caaf2dbdbd14a52a1c1aaf3f5589b3a48 GIT binary patch literal 1078 zcmdUsze~eV5XUcRlGY#9ByF{I@CSn0rHhInA`T)>;wTc3&=+kaH6@8)MqP>^;vzZ- zg1G47AL8OzG6|xfQ^n26d+Do$N)g1W)mCmV^U_ciKQ35}=Rs9z;Co^n|KmbwmpE|b&h)`$)Q}}qnVExfJPP9x6j9yraX?D%VQ|@Q4}GMGB<%z zLTe?@1tQTs-MxViOa`Bmi?iCQV{bWnd3edR3|Fi8nrm-*`1eZo4*Ir@qNmLirnT^3 zq2hlg=E^qNwTyWug*j-q?gMH)#&KM|8{}-QSFOoPO$k*_zbE6OR98XC)#Mc2RYO%W ozc|wWB-L+ywC((7gKbmwwVM@l{7m)dv2O@#e4O7G9R*+Z3r9K~S^xk5 literal 0 HcmV?d00001 diff --git a/7.5/abc.py b/7.5/abc.py new file mode 100644 index 0000000..1669710 --- /dev/null +++ b/7.5/abc.py @@ -0,0 +1,25 @@ + +import numpy as np +#a=np.array([[1,2,3],[1,2,3],[1,2,3]]) +#b=np.array([1,2,3]) +#print(a.dot(b))#点乘 +#print(a.T)#转置 +#print(np.linalg.pinv(a))#逆 +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,2]))) diff --git a/7.5/datas.py b/7.5/datas.py new file mode 100644 index 0000000..bd9f5fc --- /dev/null +++ b/7.5/datas.py @@ -0,0 +1,155 @@ +#模拟太原和吕梁的房价的数据 预测系统 +#怎么模拟 城市 面积 户型 是不是学区房 装修的风格 +datas=[ + #模拟的吕梁第一类房子 + { + "city":"吕梁", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000 + }, + { + "city": "吕梁", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 7800 + }, + { + "city": "吕梁", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 8200 + }, + #模拟的吕梁第二类房子 + { + "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": 1, + "style": 1, + "price": 8600 + }, + #模拟的吕梁第三类房子 + { + "city":"吕梁", + "area":130, + "rooms":3, + "school":2, + "style":2, + "price":6500 + }, + { + "city": "吕梁", + "area": 135, + "rooms": 3, + "school": 2, + "style": 2, + "price": 6300 + }, + { + "city": "吕梁", + "area": 140, + "rooms": 3, + "school": 2, + "style": 2, + "price": 5600 + }, + #模拟的太原第一类房子 + { + "city":"太原", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":10000 + }, + { + "city": "太原", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 9800 + }, + { + "city": "太原", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 9200 + }, + #模拟的太原第二类房子 + { + "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": 1, + "style": 1, + "price": 10600 + }, + #模拟的太原第三类房子 + { + "city":"太原", + "area":130, + "rooms":3, + "school":2, + "style":2, + "price":8500 + }, + { + "city": "太原", + "area": 135, + "rooms": 3, + "school": 2, + "style": 2, + "price": 8300 + }, + { + "city": "太原", + "area": 140, + "rooms": 3, + "school": 2, + "style": 2, + "price": 8600 + }, + +] \ No newline at end of file -- Gitee