diff --git a/2/.idea/.gitignore b/2/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..35410cacdc5e87f985c93a96520f5e11a5c822e4 --- /dev/null +++ b/2/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/2/.idea/2.iml b/2/.idea/2.iml new file mode 100644 index 0000000000000000000000000000000000000000..a5e51ba58ef6c6ebfc9c64b0f37f77006d077b89 --- /dev/null +++ b/2/.idea/2.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/2/.idea/inspectionProfiles/profiles_settings.xml b/2/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/2/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/2/.idea/misc.xml b/2/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..3a3f5d63dfb24ce50ed167852638c4549c2a3dc4 --- /dev/null +++ b/2/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/2/.idea/modules.xml b/2/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..fb4f10bbf912526056ba0d917df3956cb6684207 --- /dev/null +++ b/2/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/2/__pycache__/datas.cpython-310.pyc b/2/__pycache__/datas.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5be9863cb3c938c19e2dc865be8f8389cedefaf9 Binary files /dev/null and b/2/__pycache__/datas.cpython-310.pyc differ diff --git a/2/datas.py b/2/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..f5291da650a9774460361b3d316533754d65f9f9 --- /dev/null +++ b/2/datas.py @@ -0,0 +1,52 @@ +#是不是学区房 1 2 装修风格 1 2 +datas=[ + { + "city":"吕梁", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000 + }, + { + "city":"太原", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000 + }, + { + "city":"吕梁", + "area":102, + "rooms":2, + "school":1, + "style":1, + "price":9000 + }, + { + "city":"太原", + "area":120, + "rooms":2, + "school":1, + "style":1, + "price":9000 + }, + { + "city":"吕梁", + "area":100, + "rooms":2, + "school":2, + "style":1, + "price":80000 + }, + { + "city":"太原", + "area":100, + "rooms":2, + "school":1, + "style":2, + "price":80000 + } + +] \ No newline at end of file diff --git a/2/preject.py b/2/preject.py new file mode 100644 index 0000000000000000000000000000000000000000..4ceeb5e654912d0b7f6d5477f713a7efab2cd9b8 --- /dev/null +++ b/2/preject.py @@ -0,0 +1,22 @@ +import numpy as np +from datas import datas +X=[] +Y=[] +cityMark={"吕梁":1,"太原":2} +for i in datas: + single=[] + + single.append(cityMark[i["city"]]) + single.append(i["area"]) + single.append(i["rooms"]) + single.append(i["school"]) + single.append(i["style"]) + X.append(single) + Y.append(i["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])))