From 8070576883c1620a7570d608f1629c2caa7be9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E6=95=B0=E4=B8=8D=E6=8C=82=E7=A7=91?= <2695705299@qq.com> Date: Fri, 5 Jul 2024 21:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=98=E5=AE=87=E7=BA=A2=E7=9A=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pythonProject/.idea/.gitignore | 8 +++ .../inspectionProfiles/profiles_settings.xml | 6 ++ pythonProject/.idea/misc.xml | 7 +++ pythonProject/.idea/modules.xml | 8 +++ pythonProject/.idea/pythonProject.iml | 10 ++++ .../7.5/__pycache__/datas.cpython-312.pyc | Bin 0 -> 540 bytes pythonProject/7.5/datas.py | 53 ++++++++++++++++++ pythonProject/7.5/predict.py | 28 +++++++++ 8 files changed, 120 insertions(+) create mode 100644 pythonProject/.idea/.gitignore create mode 100644 pythonProject/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 pythonProject/.idea/misc.xml create mode 100644 pythonProject/.idea/modules.xml create mode 100644 pythonProject/.idea/pythonProject.iml create mode 100644 pythonProject/7.5/__pycache__/datas.cpython-312.pyc create mode 100644 pythonProject/7.5/datas.py create mode 100644 pythonProject/7.5/predict.py diff --git a/pythonProject/.idea/.gitignore b/pythonProject/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/pythonProject/.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/pythonProject/.idea/inspectionProfiles/profiles_settings.xml b/pythonProject/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/pythonProject/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/pythonProject/.idea/misc.xml b/pythonProject/.idea/misc.xml new file mode 100644 index 0000000..2a01189 --- /dev/null +++ b/pythonProject/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/pythonProject/.idea/modules.xml b/pythonProject/.idea/modules.xml new file mode 100644 index 0000000..e15ec35 --- /dev/null +++ b/pythonProject/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/pythonProject/.idea/pythonProject.iml b/pythonProject/.idea/pythonProject.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/pythonProject/.idea/pythonProject.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pythonProject/7.5/__pycache__/datas.cpython-312.pyc b/pythonProject/7.5/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c7d6d507fd92bf728aa0c81c2281d7962d3a8b48 GIT binary patch literal 540 zcmchTKTE?v6u{r5xofSBHYr7lpCC&oMG$dv7Qsa%OUR|R(t06D!GMb{I*2&KR~%vDrBp4vXk#(+?>6G$M5(4@VI+5j56SPdpT`==>YFaeorNbNgLr7IB>!> zUcjq!ddJWiFJ_ri?lWlWmNTE_73@`RI81w76(owTCo!( zinl_s?|ZSc(p+}3_GXYwOKUyB`(1xM#O0tK5ItfT7YHF^24-Vetqo0UXl2o?e;P%~ U#@3$&@;`-bvQ*TLX^7te-zSoj>Hq)$ literal 0 HcmV?d00001 diff --git a/pythonProject/7.5/datas.py b/pythonProject/7.5/datas.py new file mode 100644 index 0000000..f8fed41 --- /dev/null +++ b/pythonProject/7.5/datas.py @@ -0,0 +1,53 @@ +datas=[ + { #模拟吕梁的第一类房子 + "city": "吕梁", + "area": 100, + "rooms": 2, + "school": 1, + "style": 1, + "price": 4500 + }, +{ #模拟吕梁的第二类房子 + "city": "吕梁", + "area": 120, + "rooms": 3, + "school": 2, + "style": 1, + "price": 5500 + }, +{ #模拟吕梁的第三类房子 + "city": "吕梁", + "area": 140, + "rooms": 2, + "school": 2, + "style": 2, + "price": 6500 + }, +{ #模拟太原的第一类房子 + "city": "太原", + "area": 130, + "rooms": 1, + "school": 2, + "style": 2, + "price": 5000 + }, +{ #模拟太原的第二类房子 + "city": "太原", + "area": 150, + "rooms": 3, + "school": 2, + "style": 2, + "price": 6000 + }, +{ #模拟太原的第三类房子 + "city": "太原", + "area": 170, + "rooms": 3, + "school": 2, + "style": 2, + "price": 7000 + }, + # 城市 *1 面积 *2 房间数量 *3 学区房 *4 装修 *5 + # a1*1+a2*2+a3*3+a4*4+a5*5+y + #[a1,a2....] 数学模型 机器学习 机器学习软件开发 +] \ No newline at end of file diff --git a/pythonProject/7.5/predict.py b/pythonProject/7.5/predict.py new file mode 100644 index 0000000..d7caf98 --- /dev/null +++ b/pythonProject/7.5/predict.py @@ -0,0 +1,28 @@ +# 1.先安装一个 科学计算器 +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([2,100,2,1,1]))) + + -- Gitee