diff --git a/pythonProject3/.idea/.gitignore b/pythonProject3/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /dev/null +++ b/pythonProject3/.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/pythonProject3/.idea/inspectionProfiles/profiles_settings.xml b/pythonProject3/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/pythonProject3/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/pythonProject3/.idea/misc.xml b/pythonProject3/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..2a08db1706d0c3bcef43f907d58b10d624f3f7de --- /dev/null +++ b/pythonProject3/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/pythonProject3/.idea/modules.xml b/pythonProject3/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..1fb3c8be37acbe2ac220221f9983c305224ff79c --- /dev/null +++ b/pythonProject3/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject3/.idea/pythonProject3.iml b/pythonProject3/.idea/pythonProject3.iml new file mode 100644 index 0000000000000000000000000000000000000000..1ae7eb3368e423c0915d0f8e9c7d5c229256febd --- /dev/null +++ b/pythonProject3/.idea/pythonProject3.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject3/__pycache__/datas.cpython-312.pyc b/pythonProject3/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..42212612c01682a3182a7e1265d5090c58365e40 Binary files /dev/null and b/pythonProject3/__pycache__/datas.cpython-312.pyc differ diff --git a/pythonProject3/datas.py b/pythonProject3/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..a821bf2aae1bb4c8766d0197447ad2640f27b35c --- /dev/null +++ b/pythonProject3/datas.py @@ -0,0 +1,17 @@ +datas=[ + {"city":"吕梁", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000 + }, + {"city": "吕梁", + "area": 100, + "rooms": 2, + "school": 2, + "style": 2, + "price": 8000 + } + +] diff --git a/pythonProject3/predict.py b/pythonProject3/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..18bb3250045fc2ab5f61cf258fe79550878cea80 --- /dev/null +++ b/pythonProject3/predict.py @@ -0,0 +1,20 @@ +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) + +theta=np.linalg.pinv(X.T.dot(X)).dot(X.T).dot(Y) + +print(theta.dot(np.array([1,120,2,1,2]))) \ No newline at end of file