diff --git a/pythonProject7/.idea/.gitignore b/pythonProject7/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..26d33521af10bcc7fd8cea344038eaaeb78d0ef5 --- /dev/null +++ b/pythonProject7/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/pythonProject7/.idea/inspectionProfiles/profiles_settings.xml b/pythonProject7/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/pythonProject7/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/pythonProject7/.idea/misc.xml b/pythonProject7/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..e975d3020ffae87bbd1745dd095bb5ca236eb228 --- /dev/null +++ b/pythonProject7/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/pythonProject7/.idea/modules.xml b/pythonProject7/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..f88b3359a3e0524b5c77b216f04fd9131733b911 --- /dev/null +++ b/pythonProject7/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject7/.idea/pythonProject7.iml b/pythonProject7/.idea/pythonProject7.iml new file mode 100644 index 0000000000000000000000000000000000000000..74d515a027de98657e9d3d5f0f1831882fd81374 --- /dev/null +++ b/pythonProject7/.idea/pythonProject7.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pythonProject7/datas.py b/pythonProject7/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..4725f971969f38c96c23ba57e416f0d08f3a514c --- /dev/null +++ b/pythonProject7/datas.py @@ -0,0 +1,182 @@ +datas=[ + { + "city": "吕梁", + "area": "100", + "room": "3", + "school": 2, + "style": 1, + "price": 8600 + }, + { + "city": "吕梁", + "area": "120", + "room": "2", + "school": 1, + "style": 1, + "price": 8300 + }, + { + "city": "吕梁", + "area": "110", + "room": "2", + "school": 1, + "style": 1, + "price": 8200 + }, + #二类 + { + "city": "吕梁", + "area": "130", + "room": "4", + "school": 2, + "style": 1, + "price": 9000 + }, + { + "city": "吕梁", + "area": "140", + "room": "4", + "school": 2, + "style": 1, + "price": 8500 + }, + { + "city": "吕梁", + "area": "122", + "room": "3", + "school": 2, + "style": 1, + "price": 8100 + }, + #三类 + { + "city": "吕梁", + "area": "84", + "room": "2", + "school": 1, + "style": 1, + "price": 7600 + }, + { + "city": "吕梁", + "area": "60", + "room": "2", + "school": 2, + "style": 1, + "price": 5000 + }, + { + "city": "吕梁", + "area": "90", + "room": "2", + "school": 2, + "style": 1, + "price": 6600 + }, + + #太原1类 + { + "city": "太原", + "area": "110", + "room": "3", + "school": 1, + "style": 1, + "price": 8400 + }, + { + "city": "太原", + "area": "101", + "room": "2", + "school": 2, + "style": 1, + "price": 7000 + }, + { + "city": "太原", + "area": "100", + "room": "2", + "school": 2, + "style": 1, + "price": 6600 + }, + #太原二类 + { + "city": "太原", + "area": "80", + "room": "5", + "school": 2, + "style": 1, + "price": 5000 + }, + { + "city": "太原", + "area": "99", + "room": "2", + "school": 2, + "style": 1, + "price": 5200 + }, + { + "city": "太原", + "area": "130", + "room": "1", + "school": 2, + "style": 1, + "price": 6600 + }, + #太原三类 + { + "city": "太原", + "area": "140", + "room": "5", + "school": 2, + "style": 1, + "price": 9600 + }, + { + "city": "太原", + "area": "130", + "room": "4", + "school": 2, + "style": 1, + "price": 8880 + }, + { + "city": "太原", + "area": "100", + "room": "2", + "school": 2, + "style": 1, + "price": 6500 + }, + #3000 10 1000 1300 1500 + #太原2 100 3 1 1 + #城市*1 面积*2 房间数量*3 学区房*4 装修*5 + # *1=1 *2=2 + #3000+14000+30000+26000+30000 +] +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["rooms"]) +single.append(item["school"]) +single.append(item["style"]) +single.append(item["area"]) +X.append(single) +Y.append(item["price"]) + +X=np.array(X) +Y=np.array(Y) + +theta=np.linalg.pinv(X.T.dot(X)).dot(Y) + + +print(theta) + +print(theta.dot(np.array([2,100,2,1,1]))) \ No newline at end of file diff --git a/pythonProject7/main.py b/pythonProject7/main.py new file mode 100644 index 0000000000000000000000000000000000000000..5596b44786f04e4810aefe9f8d712f08ed310f71 --- /dev/null +++ b/pythonProject7/main.py @@ -0,0 +1,16 @@ +# This is a sample Python script. + +# Press Shift+F10 to execute it or replace it with your code. +# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. + + +def print_hi(name): + # Use a breakpoint in the code line below to debug your script. + print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. + + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + print_hi('PyCharm') + +# See PyCharm help at https://www.jetbrains.com/help/pycharm/ diff --git a/pythonProject7/predict.py b/pythonProject7/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..3cae8563b6bf8a2117187960fb69b600f4485a0e --- /dev/null +++ b/pythonProject7/predict.py @@ -0,0 +1,8 @@ +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))