diff --git a/Project1/.idea/.gitignore b/Project1/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..35410cacdc5e87f985c93a96520f5e11a5c822e4
--- /dev/null
+++ b/Project1/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/Project1/.idea/Project1.iml b/Project1/.idea/Project1.iml
new file mode 100644
index 0000000000000000000000000000000000000000..2c80e1269497d12e018fd6afa29982e56b0fb70d
--- /dev/null
+++ b/Project1/.idea/Project1.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Project1/.idea/inspectionProfiles/profiles_settings.xml b/Project1/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99
--- /dev/null
+++ b/Project1/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Project1/.idea/misc.xml b/Project1/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ccd691a38af011048903443d1b37e83f5cc4f00f
--- /dev/null
+++ b/Project1/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Project1/.idea/modules.xml b/Project1/.idea/modules.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3db647aa02b73db81b98a595bedaeafad2e9731f
--- /dev/null
+++ b/Project1/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Project1/__pycache__/datas.cpython-312.pyc b/Project1/__pycache__/datas.cpython-312.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..5ae132d4838104045186032e768423443a8ab15b
Binary files /dev/null and b/Project1/__pycache__/datas.cpython-312.pyc differ
diff --git a/Project1/app.py b/Project1/app.py
new file mode 100644
index 0000000000000000000000000000000000000000..c3d66f3c8b93962da7f1183c7777d9a00be383e1
--- /dev/null
+++ b/Project1/app.py
@@ -0,0 +1,65 @@
+from flask import Flask, request, render_template
+import numpy as np
+from datas import datas
+
+app = Flask(__name__)
+
+cityMark = {"吕梁": 1, "太原": 2}
+
+
+def prepare_data(datas):
+ X = []
+ Y = []
+ for item in datas:
+ single = [
+ cityMark[item["city"]],
+ item["area"],
+ item["rooms"],
+ item["school"],
+ item["style"]
+ ]
+ X.append(single)
+ Y.append(item["price"])
+ return np.array(X), np.array(Y)
+
+
+X, Y = prepare_data(datas)
+
+
+theta = np.linalg.pinv(X.T.dot(X)).dot(X.T).dot(Y)
+
+
+@app.route('/')
+def home():
+ return render_template('index.html')
+
+
+@app.route('/predict', methods=['POST'])
+def predict():
+ city = request.form['city']
+ area = float(request.form['area'])
+ rooms = int(request.form['rooms'])
+ school = int(request.form['school'])
+ style = int(request.form['style'])
+
+ x = np.array([
+ cityMark[city],
+ area,
+ rooms,
+ school,
+ style
+ ])
+ price = theta.dot(x)
+
+ return render_template('index.html',
+ prediction_text=f'预测的房价是 {price:.2f} 元/平方米',
+ city=city,
+ area=area,
+ rooms=rooms,
+ school=school,
+ style=style)
+
+
+if __name__ == "__main__":
+ app.run(debug=True)
+
diff --git a/Project1/datas.py b/Project1/datas.py
new file mode 100644
index 0000000000000000000000000000000000000000..c18fb2b1f9b2012f34835caaa4c31ec1b3707c4e
--- /dev/null
+++ b/Project1/datas.py
@@ -0,0 +1,162 @@
+datas=[
+ {
+ "city": "太原",
+ "area": 135,
+ "rooms": 3,
+ "school": 2,
+ "style": 2,
+ "price": 8500
+ },
+ {
+ "city": "太原",
+ "area": 120,
+ "rooms": 2,
+ "school": 1,
+ "style": 1,
+ "price": 8300
+ },
+ {
+ "city": "太原",
+ "area": 140,
+ "rooms": 4,
+ "school": 3,
+ "style": 2,
+ "price": 8700
+ },
+ {
+ "city": "太原",
+ "area": 125,
+ "rooms": 3,
+ "school": 2,
+ "style": 1,
+ "price": 8400
+ },
+ {
+ "city": "太原",
+ "area": 150,
+ "rooms": 4,
+ "school": 3,
+ "style": 2,
+ "price": 8900
+ },
+ {
+ "city": "太原",
+ "area": 110,
+ "rooms": 2,
+ "school": 1,
+ "style": 1,
+ "price": 8200
+ },
+ {
+ "city": "太原",
+ "area": 145,
+ "rooms": 3,
+ "school": 2,
+ "style": 2,
+ "price": 8600
+ },
+ {
+ "city": "太原",
+ "area": 130,
+ "rooms": 3,
+ "school": 2,
+ "style": 2,
+ "price": 8500
+ },
+ {
+ "city": "太原",
+ "area": 132,
+ "rooms": 3,
+ "school": 2,
+ "style": 1,
+ "price": 8400
+ },
+ {
+ "city": "太原",
+ "area": 138,
+ "rooms": 4,
+ "school": 3,
+ "style": 2,
+ "price": 8700
+ },
+ {
+ "city": "吕梁",
+ "area": 135,
+ "rooms": 3,
+ "school": 2,
+ "style": 2,
+ "price": 6500
+ },
+ {
+ "city": "吕梁",
+ "area": 120,
+ "rooms": 2,
+ "school": 1,
+ "style": 1,
+ "price": 6300
+ },
+ {
+ "city": "吕梁",
+ "area": 140,
+ "rooms": 4,
+ "school": 3,
+ "style": 2,
+ "price": 6700
+ },
+ {
+ "city": "吕梁",
+ "area": 125,
+ "rooms": 3,
+ "school": 2,
+ "style": 1,
+ "price": 6400
+ },
+ {
+ "city": "吕梁",
+ "area": 150,
+ "rooms": 4,
+ "school": 3,
+ "style": 2,
+ "price": 6900
+ },
+ {
+ "city": "吕梁",
+ "area": 110,
+ "rooms": 2,
+ "school": 1,
+ "style": 1,
+ "price": 6200
+ },
+ {
+ "city": "吕梁",
+ "area": 145,
+ "rooms": 3,
+ "school": 2,
+ "style": 2,
+ "price": 6600
+ },
+ {
+ "city": "吕梁",
+ "area": 130,
+ "rooms": 3,
+ "school": 2,
+ "style": 2,
+ "price": 6500
+ },
+ {
+ "city": "吕梁",
+ "area": 132,
+ "rooms": 3,
+ "school": 2,
+ "style": 1,
+ "price": 6400
+ },
+ {
+ "city": "吕梁",
+ "area": 138,
+ "rooms": 4,
+ "school": 3,
+ "style": 2,
+ "price": 6800
+ }
+]
\ No newline at end of file
diff --git a/Project1/templates/index.html b/Project1/templates/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..7e7cf96202240a3ed275fcfbb251e443eead9e60
--- /dev/null
+++ b/Project1/templates/index.html
@@ -0,0 +1,48 @@
+
+
+
+
+
+ 房价预测
+
+
+
+
+
房价预测
+
+ {% if prediction_text %}
+
+
输入结果:
+
城市: {{ city }}
+
面积: {{ area }} 平方米
+
房间数: {{ rooms }}
+
学校数量: {{ school }}
+
装修风格: {{ style }}
+
{{ prediction_text }}
+
+ {% endif %}
+
+
+
\ No newline at end of file