diff --git a/7.5/.idea/.gitignore b/7.5/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /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 0000000000000000000000000000000000000000..2c80e1269497d12e018fd6afa29982e56b0fb70d --- /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 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /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 0000000000000000000000000000000000000000..f25cb9ce14b007a4752e08370ac8375647eef5a0 --- /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 0000000000000000000000000000000000000000..6b331e2a1a59345e7f6d7b125256d45cb20c2af1 --- /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 Binary files /dev/null and b/7.5/__pycache__/datas.cpython-312.pyc differ diff --git a/7.5/datas.py b/7.5/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..e95e1301164d25458e81f39835c17a6c37682008 --- /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 0000000000000000000000000000000000000000..46192ab0e3d5705dbd6dcc7f70e3607c9f417e9e --- /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