diff --git a/pythonProject/.idea/.gitignore b/pythonProject/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /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 0000000000000000000000000000000000000000..02fbcf495a6b8c8e68a311a21f083f7be4475bf9 --- /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 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /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 0000000000000000000000000000000000000000..82d9b20db28f31680e414a7b38f2e49811207d26 --- /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 0000000000000000000000000000000000000000..e15ec35fe054f3b2c7c21e3dcca866d6a79ca0ba --- /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 0000000000000000000000000000000000000000..c24009a9f2e5426c2f2556feb6ae618d6ee4b4c5 --- /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 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc --- /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 Binary files /dev/null and b/pythonProject/__pycache__/datas.cpython-312.pyc differ diff --git a/pythonProject/datas.py b/pythonProject/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..883c45c7fb3cd923453589e8eebdae6436fab0b4 --- /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 0000000000000000000000000000000000000000..9f9483a3ef1432cbbf72cbf985b62370f871ed0e --- /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)) #矩阵求逆 + + +