From 2dc747366e8ebc998a2192a40f71c5f4a6286fc7 Mon Sep 17 00:00:00 2001 From: software-engineering-class-4 <3222422927@qq.com> Date: Fri, 5 Jul 2024 21:56:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9D=8E=E6=98=8E=E6=85=A7=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=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 From a766d814bbe71edce8a65b8bc9c07c8ff549df2a Mon Sep 17 00:00:00 2001 From: software-engineering-class-4 <3222422927@qq.com> Date: Fri, 5 Jul 2024 22:55:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9D=8E=E6=98=8E=E6=85=A7=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=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 540 -> 0 bytes pythonProject/7.5/datas.py | 53 ------------------ pythonProject/7.5/predict.py | 28 --------- 8 files changed, 120 deletions(-) delete mode 100644 pythonProject/.idea/.gitignore delete mode 100644 pythonProject/.idea/inspectionProfiles/profiles_settings.xml delete mode 100644 pythonProject/.idea/misc.xml delete mode 100644 pythonProject/.idea/modules.xml delete mode 100644 pythonProject/.idea/pythonProject.iml delete mode 100644 pythonProject/7.5/__pycache__/datas.cpython-312.pyc delete mode 100644 pythonProject/7.5/datas.py delete mode 100644 pythonProject/7.5/predict.py diff --git a/pythonProject/.idea/.gitignore b/pythonProject/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/pythonProject/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 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 deleted file mode 100644 index 105ce2d..0000000 --- a/pythonProject/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/pythonProject/.idea/misc.xml b/pythonProject/.idea/misc.xml deleted file mode 100644 index 2a01189..0000000 --- a/pythonProject/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/pythonProject/.idea/modules.xml b/pythonProject/.idea/modules.xml deleted file mode 100644 index e15ec35..0000000 --- a/pythonProject/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/pythonProject/.idea/pythonProject.iml b/pythonProject/.idea/pythonProject.iml deleted file mode 100644 index 74d515a..0000000 --- a/pythonProject/.idea/pythonProject.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ 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 deleted file mode 100644 index c7d6d507fd92bf728aa0c81c2281d7962d3a8b48..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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)$ diff --git a/pythonProject/7.5/datas.py b/pythonProject/7.5/datas.py deleted file mode 100644 index f8fed41..0000000 --- a/pythonProject/7.5/datas.py +++ /dev/null @@ -1,53 +0,0 @@ -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 deleted file mode 100644 index d7caf98..0000000 --- a/pythonProject/7.5/predict.py +++ /dev/null @@ -1,28 +0,0 @@ -# 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