diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..1c2fda565b94d0f2b94cb65ba7cca866e7a25478 --- /dev/null +++ b/.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/.idea/.name b/.idea/.name new file mode 100644 index 0000000000000000000000000000000000000000..35c0710206399406045638d41b50e7148bc8f53f --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +reddict.py \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..09af6940195ff191e1663dabfc5c19a9bd053a18 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..e1ceb69dd7559259952ac2b81af35d9d1e570a9d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/pythonProject.iml b/.idea/pythonProject.iml new file mode 100644 index 0000000000000000000000000000000000000000..f246f2cd2c66df9f5c2233531499bd2f5b5b472f --- /dev/null +++ b/.idea/pythonProject.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..d7d9566429f270a3609ee598c8d30e4b0bad3abd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/7.5-homework b/7.5-homework new file mode 160000 index 0000000000000000000000000000000000000000..dd39b0754176fd0f813eb20aa00421566e1f23fe --- /dev/null +++ b/7.5-homework @@ -0,0 +1 @@ +Subproject commit dd39b0754176fd0f813eb20aa00421566e1f23fe diff --git a/__pycache__/datas.cpython-312.pyc b/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bf3e684343b76adf9cc0b44d12d0ba8cb2aced65 Binary files /dev/null and b/__pycache__/datas.cpython-312.pyc differ diff --git a/datas.py b/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..cb957f712183768b255d7cdddc7fcee819fdc6b5 --- /dev/null +++ b/datas.py @@ -0,0 +1,64 @@ + + +data=[ + { + "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/reddict.py b/reddict.py new file mode 100644 index 0000000000000000000000000000000000000000..5c36ee0c8e7fa9c687c2afbf80bdd5fdee1c2424 --- /dev/null +++ b/reddict.py @@ -0,0 +1,47 @@ + +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)) #矩阵求逆 + + +