diff --git a/homework/.idea/.gitignore b/homework/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /dev/null +++ b/homework/.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/homework/.idea/7.5.iml b/homework/.idea/7.5.iml new file mode 100644 index 0000000000000000000000000000000000000000..d0876a78d06ac03b5d78c8dcdb95570281c6f1d6 --- /dev/null +++ b/homework/.idea/7.5.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/homework/.idea/inspectionProfiles/profiles_settings.xml b/homework/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/homework/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/homework/.idea/misc.xml b/homework/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..060d2c5e8c365bdf4dafbb4e5ef23b4ac65aafd6 --- /dev/null +++ b/homework/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/homework/.idea/modules.xml b/homework/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..6b331e2a1a59345e7f6d7b125256d45cb20c2af1 --- /dev/null +++ b/homework/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/homework/.keep b/homework/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/homework/__pycache__/datas.cpython-312.pyc b/homework/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..779d9e27d345705c5486bbec18da4744f6858016 Binary files /dev/null and b/homework/__pycache__/datas.cpython-312.pyc differ diff --git a/homework/datas.py b/homework/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..5a56bcf2b8b74999a58ffb7d01b881d1038bda90 --- /dev/null +++ b/homework/datas.py @@ -0,0 +1,76 @@ +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": 135, + "rooms": 3, + "school": 1, + "style": 1, + "price": 8300 + }, + { + "city":"吕梁", + "area":110, + "rooms":2, + "school":1, + "style":1, + "price":8200 + }, + { + "city": "吕梁", + "area": 130, + "rooms": 3, + "school": 2, + "style": 2, + "price": 6500 + }, + { + "city": "吕梁", + "area": 140, + "rooms": 3, + "school": 1, + "style": 1, + "price": 8600 + }, + { + "city": "太原", + "area": 110, + "rooms": 2, + "school": 1, + "style": 1, + "price": 8200 + }, + { + "city": "太原", + "area": 130, + "rooms": 3, + "school": 2, + "style": 2, + "price": 6500 + }, + { + "city": "太原", + "area": 140, + "rooms": 3, + "school": 1, + "style": 1, + "price": 8600 + }, +] +#a1*1+a2*2+a3*3+a4*4+a5*5 +#[a1,a2,.....] \ No newline at end of file diff --git a/homework/predict.py b/homework/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..f0e9faa49b1cc12c14f18900522a3a5281c41f39 --- /dev/null +++ b/homework/predict.py @@ -0,0 +1,18 @@ +import numpy as np +from datas import datas +X=[] +Y=[] +cityMark={"吕梁":1,"太原":2} +for item in datas: + signal=[] + signal.append(cityMark[item["city"]]) + signal.append(item["area"]) + signal.append(item["rooms"]) + signal.append(item["school"]) + signal.append(item["style"]) + X.append(signal) + 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])))