diff --git a/soft1/.idea/.gitignore b/soft1/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /dev/null +++ b/soft1/.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/soft1/.idea/inspectionProfiles/Project_Default.xml b/soft1/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000000000000000000000000000000000000..d4a00d666e9ebe45bfd5a3169093edbb53551d1f --- /dev/null +++ b/soft1/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/soft1/.idea/inspectionProfiles/profiles_settings.xml b/soft1/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/soft1/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/soft1/.idea/misc.xml b/soft1/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..d871a124ebd746ab92e516fabc748763c68cd1c0 --- /dev/null +++ b/soft1/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/soft1/.idea/modules.xml b/soft1/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..197647d9aceb84edac08b1c390da440ff152e855 --- /dev/null +++ b/soft1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/soft1/.idea/soft1.iml b/soft1/.idea/soft1.iml new file mode 100644 index 0000000000000000000000000000000000000000..74d515a027de98657e9d3d5f0f1831882fd81374 --- /dev/null +++ b/soft1/.idea/soft1.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/soft1/7.5/__pycache__/datas.cpython-311.pyc b/soft1/7.5/__pycache__/datas.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c96ae9e09e6e81171b0b1f279297d78e18cbe4cb Binary files /dev/null and b/soft1/7.5/__pycache__/datas.cpython-311.pyc differ diff --git a/soft1/7.5/datas.py b/soft1/7.5/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..03dca15f01bb5d1df0443377e1f5877258dd385d --- /dev/null +++ b/soft1/7.5/datas.py @@ -0,0 +1,153 @@ +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 diff --git a/soft1/7.5/predict.py b/soft1/7.5/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..c2c56aab2c75fc1c0cafc031b9dd5386728cd25f --- /dev/null +++ b/soft1/7.5/predict.py @@ -0,0 +1,25 @@ +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["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([1,100,2,1]))) \ No newline at end of file