diff --git a/soft/.idea/.gitignore b/soft/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..1c2fda565b94d0f2b94cb65ba7cca866e7a25478 --- /dev/null +++ b/soft/.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/soft/.idea/inspectionProfiles/profiles_settings.xml b/soft/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..105ce2da2d6447d11dfe32bfb846c3d5b199fc99 --- /dev/null +++ b/soft/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/soft/.idea/misc.xml b/soft/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..e9886119a4275cea9457f396e99d7dfc4e9522bb --- /dev/null +++ b/soft/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/soft/.idea/modules.xml b/soft/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..e09a7793fb01af2c9c581d167b4f43f5bdb1ac18 --- /dev/null +++ b/soft/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/soft/.idea/soft.iml b/soft/.idea/soft.iml new file mode 100644 index 0000000000000000000000000000000000000000..858c4d5c33d47e00d1447bfc0ed14dc96423be84 --- /dev/null +++ b/soft/.idea/soft.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/soft/7.5/__pycache__/datas.cpython-312.pyc b/soft/7.5/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..38b724d5c6b50b049ff8fd1e31cf888bb75f4bc2 Binary files /dev/null and b/soft/7.5/__pycache__/datas.cpython-312.pyc differ diff --git a/soft/7.5/datas.py b/soft/7.5/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..f8e42c9b853cac94fe5ec888549e400d4f2699f4 --- /dev/null +++ b/soft/7.5/datas.py @@ -0,0 +1,110 @@ + +datas = [ + #第一类 + { + "city":"吕梁", + "area":100, + "romes":2, + "school":1, + "style":1, + "price":8000 + }, + { + "city":"吕梁", + "area":100, + "romes":2, + "school":1, + "style":1, + "price":8200 + }, + { + "city":"吕梁", + "area":130, + "romes":3, + "school":1, + "style":1, + "price":8500 + }, + { + "city":"吕梁", + "area":135, + "romes":3, + "school":1, + "style":1, + "price":8300 + }, + { + "city":"吕梁", + "area":140, + "romes":3, + "school":1, + "style":1, + "price":8600 + }, +#第二类 + { + "city":"吕梁", + "area":130, + "romes":3, + "school":2, + "style":2, + "price":6500 + }, + { + "city":"吕梁", + "area":135, + "romes":3, + "school":2, + "style":2, + "price":6300 + }, + { + "city":"吕梁", + "area":140, + "romes":3, + "school":2, + "style":2, + "price":5600 + }, + { + "city":"太原", + "area":100, + "romes":2, + "school":1, + "style":1, + "price":10000 + }, + { + "city":"太原", + "area":100, + "romes":2, + "school":1, + "style":1, + "price":9800 + }, + { + "city":"太原", + "area":100, + "romes":2, + "school":1, + "style":1, + "price":9200 + }, + { + "city":"太原", + "area":130, + "romes":3, + "school":1, + "style":1, + "price":10500 + }, + { + "city":"太原", + "area":135, + "romes":3, + "school":1, + "style":1, + "price":10300 + }, + + ] \ No newline at end of file diff --git a/soft/7.5/predict.py b/soft/7.5/predict.py new file mode 100644 index 0000000000000000000000000000000000000000..18836cb7b6fb0a57b05b002f0a45326b5315a9d2 --- /dev/null +++ b/soft/7.5/predict.py @@ -0,0 +1,20 @@ +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["romes"]) + 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([1,120,2,1,2]))) diff --git a/soft/__pycache__/cos.cpython-312.pyc b/soft/__pycache__/cos.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..16c0ffab187c0d01dde9d89aaabc1e45cdf0b203 Binary files /dev/null and b/soft/__pycache__/cos.cpython-312.pyc differ diff --git a/soft/__pycache__/datas.cpython-312.pyc b/soft/__pycache__/datas.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8d2a5a7bdead8e7a10b468df9e1949e9d48ce2eb Binary files /dev/null and b/soft/__pycache__/datas.cpython-312.pyc differ diff --git a/soft/app.py b/soft/app.py new file mode 100644 index 0000000000000000000000000000000000000000..356f976d3bd6913cf7e5e6ca08cdb5e706ac239a --- /dev/null +++ b/soft/app.py @@ -0,0 +1,24 @@ +from flask import Flask,render_template +from datas import datas +from cos import angle +app=Flask(__name__) +@app.route("/") +def index(): + return render_template("index.html",datas=datas) + +@app.route('/tuijian/') +def tuijian(id): + current=datas[id] ["feature"] + arr=[] + for i in range(len(datas)): + if(i!=id): + obj={} + a=angle(current,datas[i] ["feature"]) + obj["angle"]=a + obj["id"]=i + arr.append(obj) + def k(v): + return v["angle"] + arr.sort(key=k) + return render_template("tuijian.html",datas=datas,arr=arr[:5]) +app.run() \ No newline at end of file diff --git a/soft/cos.py b/soft/cos.py new file mode 100644 index 0000000000000000000000000000000000000000..f0e2d51976085b58c117371ea49df366666a253c --- /dev/null +++ b/soft/cos.py @@ -0,0 +1,21 @@ +def dot(a,b): + sum=0; + c=zip(a,b) + for item in c: + sum+=item[0]*item[1] + return sum +def mo(a): + sum=0 + for i in a: + sum+=i*i + return sum**0.5 + +import math +def angle(a,b): + ji=dot(a,b) + amo=mo(a) + bmo=mo(b) + cos=ji/(amo*bmo) + hudu=math.acos(cos) + jiaodu=hudu*180/math.pi + return jiaodu \ No newline at end of file diff --git a/soft/datas.py b/soft/datas.py new file mode 100644 index 0000000000000000000000000000000000000000..58f43e3e24ac4ca7090f4a7db69e73c8522db1fc --- /dev/null +++ b/soft/datas.py @@ -0,0 +1,18 @@ +datas = [ + {"name": "默杀", "score": 6.9,"image_url": '/static/img/1.png',"feature":[1,2,3,3]}, + {"name": "头脑特工队", "score": 8.4,"image_url": '/static/img/2.png',"feature":[1,2,1,3]}, + {"name": "寂静之地:入侵日 A Quiet Place: Day One", "score": 5.8,"image_url": '/static/img/3.png',"feature":[1,2,2,2]}, + {"name": "来福大酒店", "score": 7.3,"image_url": '/static/img/4.png',"feature":[1,3,3,3]}, + {"name": "扫黑·决不放弃", "score": 6.6,"image_url": '/static/img/5.png',"feature":[1,2,2,3]}, + {"name": "云边有个小卖部", "score": 5.1,"image_url": '/static/img/6.png',"feature":[2,2,3,3]}, + {"name": "走走停停 ", "score": 8.0,"image_url": '/static/img/7.png',"feature":[1,2,2,3]}, + {"name": "海关战线", "score": 6.3,"image_url": '/static/img/8.png',"feature":[2,2,3,3]}, + {"name": "疯狂的麦克斯:狂暴女神 Furiosa: A Mad Max Saga", "score": 7.5,"image_url": '/static/img/9.png',"feature":[3,2,3,3]}, + {"name": "谈判专家", "score": 7.5,"image_url": '/static/img/10.png',"feature":[2,2,3,3]}, + {"name": "排球少年!!垃圾场决战", "score": 8.3,"image_url": '/static/img/11.png',"feature":[1,2,2,3]}, + {"name": "绝地战警:生死与共 Bad Boys: Ride or Die", "score": 6.5,"image_url": '/static/img/12.png',"feature":[1,3,3,3]}, + {"name": "我才不要和你做朋友呢 ", "score": 6.3,"image_url": '/static/img/13.png',"feature":[1,2,3,2]}, + {"name": "沙漏", "score": 0,"image_url": '/static/img/14.png',"feature":[1,1,3,3]}, + {"name": "朱同在三年级丢失了超能力", "score": 8.1,"image_url": '/static/img/15.png',"feature":[1,3,3,3]}, + +] \ No newline at end of file diff --git a/soft/static/img/1.png b/soft/static/img/1.png new file mode 100644 index 0000000000000000000000000000000000000000..0f9a9bb41b05208a41bfa0c68f19d0ec3041f05b Binary files /dev/null and b/soft/static/img/1.png differ diff --git a/soft/static/img/10.png b/soft/static/img/10.png new file mode 100644 index 0000000000000000000000000000000000000000..7af8e9e40b69b2fa529a8e218afb39a33d7bc27e Binary files /dev/null and b/soft/static/img/10.png differ diff --git a/soft/static/img/11.png b/soft/static/img/11.png new file mode 100644 index 0000000000000000000000000000000000000000..ecd8b3d086ee8545aded97ee166ed082c8610b9a Binary files /dev/null and b/soft/static/img/11.png differ diff --git a/soft/static/img/12.png b/soft/static/img/12.png new file mode 100644 index 0000000000000000000000000000000000000000..ac4382fca85327bfbb66e00fdef37b9b47027ab5 Binary files /dev/null and b/soft/static/img/12.png differ diff --git a/soft/static/img/13.png b/soft/static/img/13.png new file mode 100644 index 0000000000000000000000000000000000000000..29ba1b6f606492cd92cc6de70cf9e97f543c8b07 Binary files /dev/null and b/soft/static/img/13.png differ diff --git a/soft/static/img/14.png b/soft/static/img/14.png new file mode 100644 index 0000000000000000000000000000000000000000..ec2fb1dc575fa3e1e8f59b08f5d8621c430f441f Binary files /dev/null and b/soft/static/img/14.png differ diff --git a/soft/static/img/15.png b/soft/static/img/15.png new file mode 100644 index 0000000000000000000000000000000000000000..596c8f5ebb1c094fc9881ed8815f010fedb6b858 Binary files /dev/null and b/soft/static/img/15.png differ diff --git a/soft/static/img/2.png b/soft/static/img/2.png new file mode 100644 index 0000000000000000000000000000000000000000..4ea0c71ae745bade1ab81dc50476c7a0734062ea Binary files /dev/null and b/soft/static/img/2.png differ diff --git a/soft/static/img/3.png b/soft/static/img/3.png new file mode 100644 index 0000000000000000000000000000000000000000..39cc4811cb6d3020545540dff22deee7106b5378 Binary files /dev/null and b/soft/static/img/3.png differ diff --git a/soft/static/img/4.png b/soft/static/img/4.png new file mode 100644 index 0000000000000000000000000000000000000000..e0b3a4aee4de4649bd8ca5ce4b60681d0771e2d3 Binary files /dev/null and b/soft/static/img/4.png differ diff --git a/soft/static/img/5.png b/soft/static/img/5.png new file mode 100644 index 0000000000000000000000000000000000000000..5b5b036c7f278c9ea1e048e64e0a57e0e2f0e014 Binary files /dev/null and b/soft/static/img/5.png differ diff --git a/soft/static/img/6.png b/soft/static/img/6.png new file mode 100644 index 0000000000000000000000000000000000000000..7bbec6b32f64f8738c76b2753c658bde800f6fbb Binary files /dev/null and b/soft/static/img/6.png differ diff --git a/soft/static/img/7.png b/soft/static/img/7.png new file mode 100644 index 0000000000000000000000000000000000000000..cb3fc3c56f152d75c50baef4052c542bcc3ce8c7 Binary files /dev/null and b/soft/static/img/7.png differ diff --git a/soft/static/img/8.png b/soft/static/img/8.png new file mode 100644 index 0000000000000000000000000000000000000000..1d5ffdc372627b458a563d09bf03db34bb12136a Binary files /dev/null and b/soft/static/img/8.png differ diff --git a/soft/static/img/9.png b/soft/static/img/9.png new file mode 100644 index 0000000000000000000000000000000000000000..34011bbf764ace7cb5da82c0c1a1546ddde98ebb Binary files /dev/null and b/soft/static/img/9.png differ diff --git a/soft/templates/index.html b/soft/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..f259a16fdc45d84c3374c680246792042122e52c --- /dev/null +++ b/soft/templates/index.html @@ -0,0 +1,60 @@ + + + + + + 电影推荐系统 + + + +
+ {% for i in range(datas|length) %} +
+
+ {{ datas[i].name }} +
+
+

{{ datas[i].name }}

+

评分: {{ datas[i].score }}

+ 推荐电影 +
+ +
+ {% endfor %} +
+ + \ No newline at end of file diff --git a/soft/templates/tuijian.html b/soft/templates/tuijian.html new file mode 100644 index 0000000000000000000000000000000000000000..a10f95351acd6b77d9d4093cf579f228c0c76563 --- /dev/null +++ b/soft/templates/tuijian.html @@ -0,0 +1,50 @@ + + + + + Title + + + +
+ {%for item in arr%} +
+
+ +
+
+

{{ datas[item.id].name }}

+

评分: {{datas[item.id].score }}

+ {{item.angle}} +
+
+ {%endfor%} +
+ + \ No newline at end of file