From 151d68f6184689bbed4149021ca27f5006d97ec7 Mon Sep 17 00:00:00 2001 From: leimengting <3213246383@qq.com> Date: Fri, 5 Jul 2024 21:33:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E5=B7=A54=E7=8F=AD-=E9=9B=B7=E6=A2=A6?= =?UTF-8?q?=E5=A9=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- work/.idea/.gitignore | 8 ++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ work/.idea/misc.xml | 4 ++ work/.idea/modules.xml | 8 ++++ work/.idea/work.iml | 8 ++++ work/datas.py | 48 +++++++++++++++++++ work/main.py | 1 + work/predict.py | 21 ++++++++ 8 files changed, 104 insertions(+) create mode 100644 work/.idea/.gitignore create mode 100644 work/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 work/.idea/misc.xml create mode 100644 work/.idea/modules.xml create mode 100644 work/.idea/work.iml create mode 100644 work/datas.py create mode 100644 work/main.py create mode 100644 work/predict.py diff --git a/work/.idea/.gitignore b/work/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/work/.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/work/.idea/inspectionProfiles/profiles_settings.xml b/work/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/work/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/work/.idea/misc.xml b/work/.idea/misc.xml new file mode 100644 index 0000000..08c484f --- /dev/null +++ b/work/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/work/.idea/modules.xml b/work/.idea/modules.xml new file mode 100644 index 0000000..263cec1 --- /dev/null +++ b/work/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/work/.idea/work.iml b/work/.idea/work.iml new file mode 100644 index 0000000..b67588f --- /dev/null +++ b/work/.idea/work.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/work/datas.py b/work/datas.py new file mode 100644 index 0000000..1e0cdf6 --- /dev/null +++ b/work/datas.py @@ -0,0 +1,48 @@ + +datas = [ + { + "city":"吕梁" , + "area":100, + "rooms":2, + "school":2, + "style":2, + "price":4300, + }, + + + { + "city":"吕梁" , + "area":120, + "rooms":3, + "school":1, + "style":1, + "price":5000, + }, + + { + "city":"太原", + "area":100, + "rooms":2, + "school":2, + "style":2, + "price":7000, + }, + + { + "city":"太原" , + "area":100, + "rooms":3, + "school":1, + "style":1, + "price":8600, + }, + + { + "city":"太原" , + "area":100, + "rooms":2, + "school":1, + "style":2, + "price":8000, + }, +] \ No newline at end of file diff --git a/work/main.py b/work/main.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/work/main.py @@ -0,0 +1 @@ + diff --git a/work/predict.py b/work/predict.py new file mode 100644 index 0000000..34fb274 --- /dev/null +++ b/work/predict.py @@ -0,0 +1,21 @@ +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(cityMark[item["area"]]) + single.append(cityMark[item["rooms"]]) + single.append(cityMark[item["school"]]) + single.append(cityMark[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