diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000000000000000000000000000000000000..4ebeef73e1a72b62075747eb1e5bb3b86786fd87 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..8cbcddf774a1c2dafe725b8902b676636ae5c1c0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..6a542fcda6668a5fc1372734237d01d2ec1a8eea --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/pythonProject1.iml b/.idea/pythonProject1.iml new file mode 100644 index 0000000000000000000000000000000000000000..858c4d5c33d47e00d1447bfc0ed14dc96423be84 --- /dev/null +++ b/.idea/pythonProject1.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000000000000000000000000000000000000..cc0fb64b7c4460b38ca59327267ea74a5c0a398f --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1720165940354 + + + + + + + + + + file://$PROJECT_DIR$/main.py + 8 + + + + + + + + + \ No newline at end of file diff --git a/7.5/__pycache__/datas.cpython-312.pyc b/7.5/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e064b69b26ed4f0c04a7cb687263bd5b85b9d269 Binary files /dev/null and b/7.5/__pycache__/datas.cpython-312.pyc differ diff --git a/7.5/datas.py b/7.5/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..8e4f08dea7c691197b7da3b7a5e011a9afe618a5 --- /dev/null +++ b/7.5/datas.py @@ -0,0 +1,160 @@ +# 经验是来源于数据 +# 大数据 爬虫 + +# 模拟太原 和吕梁的房价数据 +# 怎么模拟 城市 面积 户型 是不是学区房 装修的风格 +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": 8300 + }, + { + "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": 1, + "style": 1, + "price": 5000 + }, + { + "city":"吕梁", + "area":135, + "rooms":3, + "school":1, + "style":1, + "price":5300 + }, + { + "city":"吕梁", + "area":140, + "rooms":3, + "school":1, + "style":1, + "price":6300 + }, + { + "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": 8300 + }, + { + "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": 1, + "style": 1, + "price": 8500 + }, + { + "city": "太原", + "area": 135, + "rooms": 3, + "school": 1, + "style": 1, + "price": 8300 + }, + { + "city": "太原", + "area": 140, + "rooms": 3, + "school": 2, + "style": 2, + "price": 8600 + }, + + +] + diff --git a/7.5/predict.py b/7.5/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..5d3520525c411ccaf28fec6a1a8533197660bb23 --- /dev/null +++ b/7.5/predict.py @@ -0,0 +1,33 @@ +import numpy as np + +# a=np.array([[1,2,3],[1,2,3],[1,2,3]]) +# b=np.array([1,2,3]) +# # 奇异矩阵 +# print(a.dot(b)) +# +# print(a) +# print(a.T) # 转置 +# print(np.linalg.pinv(a)) #求逆矩阵 + + +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([2,100,2,1,1]))) +# print(theta)