diff --git a/py_study/.idea/.gitignore b/py_study/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..1c2fda565b94d0f2b94cb65ba7cca866e7a25478 --- /dev/null +++ b/py_study/.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/py_study/.idea/inspectionProfiles/profiles_settings.xml b/py_study/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/py_study/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/py_study/.idea/misc.xml b/py_study/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..f1bf6faf0a2b7cdd6d4f628a104b5bc582f0fc00 --- /dev/null +++ b/py_study/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/py_study/.idea/modules.xml b/py_study/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..64826d116fb71b91d991f33684f869511dbc931e --- /dev/null +++ b/py_study/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/py_study/.idea/py_study.iml b/py_study/.idea/py_study.iml new file mode 100644 index 0000000000000000000000000000000000000000..d9e6024fc5bad71514b25a89333834e81d5cd8f4 --- /dev/null +++ b/py_study/.idea/py_study.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/py_study/__pycache__/data.cpython-312.pyc b/py_study/__pycache__/data.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5965af636004a4cd6fa6db734c296db3f28f41e0 Binary files /dev/null and b/py_study/__pycache__/data.cpython-312.pyc differ diff --git a/py_study/data.py b/py_study/data.py new file mode 100644 index 0000000000000000000000000000000000000000..2b2ae5fc303d3fc864ab73cf1983a55ab579272f --- /dev/null +++ b/py_study/data.py @@ -0,0 +1,81 @@ +data=[{ + "city":"吕梁", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000, +}, +{ + "city":"吕梁", + "area":130, + "rooms":3, + "school":1, + "style":1, + "price":8500, +}, +{ + "city":"吕梁", + "area":120, + "rooms":3, + "school":2, + "style":1, + "price":8300, +}, +{ + "city":"吕梁", + "area":150, + "rooms":2, + "school":2, + "style":2, + "price":7600, +}, +{ + "city":"吕梁", + "area":140, + "rooms":3, + "school":2, + "style":2, + "price":7500, +}, +{ + "city":"太原", + "area":120, + "rooms":2, + "school":1, + "style":1, + "price":8500, +}, +{ + "city":"太原", + "area":100, + "rooms":2, + "school":1, + "style":1, + "price":8000, +}, +{ + "city":"太原", + "area":150, + "rooms":3, + "school":1, + "style":1, + "price":8900, +}, +{ + "city":"太原", + "area":130, + "rooms":3, + "school":2, + "style":2, + "price":8000, +}, +{ + "city":"太原", + "area":150, + "rooms":3, + "school":2, + "style":2, + "price":8300, +}, +] \ No newline at end of file diff --git a/py_study/fangjia.py b/py_study/fangjia.py new file mode 100644 index 0000000000000000000000000000000000000000..b781f5eb1f541d949858327f425372a4b897af85 --- /dev/null +++ b/py_study/fangjia.py @@ -0,0 +1,19 @@ +import numpy as np +from data import data +X=[] +Y=[] +cityMark={"吕梁":1,"太原":2} +for i in data: + print(i) + 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"]) + print(X) + print(Y) + theta=np.linalg.pinv(X.T.dot(X)).dot(X.T).dot(Y) + print(theta.dot(np.array([2,100,2,1,1]))) \ No newline at end of file