AyushAI14 commited on
Commit
6d750bd
·
verified ·
1 Parent(s): 01b6654

book recommender

Browse files
Model/BookRecommender.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
Model/book_compressed.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d639e67af8713a788b8101009f2539a707d48262feb9af013e8f63325c60e572
3
+ size 13547261
Model/finaldf_compressed.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:93eaa9da025f0d09f3fe8e5b3ebc0ee1a30c70523f06f9239c15e1d63991f36d
3
+ size 505905
Model/finalpopularitycompressed.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e526745ba41687ca6f61c32d74b52d554c80cecc42b862a1616a8583961883cc
3
+ size 3348
Model/similarity_score_compressed.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee9b8b532fcc1dc3e370ec6c7954918c1f89d64283ce5e14af09c1476546fffb
3
+ size 4145718
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request
2
+ import numpy as np
3
+ import pickle
4
+ import gzip
5
+
6
+ # Load models and data
7
+ with gzip.open('Model/finaldf_compressed.gz', 'rb') as f:
8
+ finaldf = pickle.load(f)
9
+
10
+ with gzip.open('Model/book_compressed.gz', 'rb') as f:
11
+ book = pickle.load(f)
12
+
13
+ with gzip.open('Model/finalpopularitycompressed.gz', 'rb') as f:
14
+ finalpopularity = pickle.load(f)
15
+
16
+ with gzip.open('Model/similarity_score_compressed.gz', 'rb') as f:
17
+ similarityScore = pickle.load(f)
18
+
19
+ # Initialize Flask app
20
+ app = Flask(__name__, template_folder='templates', static_folder='static', static_url_path='/')
21
+
22
+ @app.route("/")
23
+ def start():
24
+ return render_template(
25
+ "home.html",
26
+ bookName=list(finalpopularity["Book-Title"].values),
27
+ Image=list(finalpopularity["Image-URL-M"].values),
28
+ Isbn=list(finalpopularity["ISBN"].values),
29
+ bookauthor=list(finalpopularity["Book-Author"].values),
30
+ NoRating=list(finalpopularity["Book-Rating"].values),
31
+ )
32
+
33
+ @app.route("/recommend")
34
+ def recommend():
35
+ return render_template("recommend.html")
36
+
37
+ @app.route("/Userrecommend", methods=["POST"])
38
+ def Userrecommend():
39
+ Userinput = request.form.get("Userinput")
40
+ try:
41
+ index = np.where(finaldf.index == Userinput)[0][0]
42
+ similarBook = sorted(
43
+ list(enumerate(similarityScore[index])),
44
+ key=lambda x: x[1],
45
+ reverse=True
46
+ )[1:6]
47
+
48
+ data = []
49
+ for i in similarBook:
50
+ item = []
51
+ tempdf = book[book["Book-Title"] == finaldf.index[i[0]]]
52
+ item.extend(list(tempdf.drop_duplicates("Book-Title")["Book-Title"].values))
53
+ item.extend(list(tempdf.drop_duplicates("Book-Title")["Image-URL-M"].values))
54
+ item.extend(list(tempdf.drop_duplicates("Book-Title")["Book-Author"].values))
55
+ item.extend(list(tempdf.drop_duplicates("Book-Title")["ISBN"].values))
56
+ data.append(item)
57
+
58
+ return render_template("recommend.html", data=data, user_input=Userinput)
59
+
60
+ except IndexError:
61
+ return render_template("recommend.html", error="User input not found!", user_input=Userinput)
62
+
63
+ if __name__ == "__main__":
64
+ # Disable reloader to avoid threading issues
65
+ app.run(debug=True, use_reloader=False)
dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python image
2
+ FROM python:3.10-slim
3
+
4
+ # Set the working directory
5
+ WORKDIR /app
6
+
7
+ # Copy application files
8
+ COPY . /app
9
+
10
+ # Install dependencies
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Expose the port Flask will run on
14
+ EXPOSE 7860
15
+
16
+ # Define the entry point for the app
17
+ CMD ["python", "app.py"]
index.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from wsgi import app
requirements.txt ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ asttokens==3.0.0
2
+ blinker==1.9.0
3
+ click==8.1.8
4
+ comm==0.2.2
5
+ compress-pickle==2.1.0
6
+ debugpy==1.8.11
7
+ decorator==5.1.1
8
+ executing==2.1.0
9
+ Flask==3.1.0
10
+ gunicorn==23.0.0
11
+ ipykernel==6.29.5
12
+ ipython==8.31.0
13
+ itsdangerous==2.2.0
14
+ jedi==0.19.2
15
+ Jinja2==3.1.5
16
+ joblib==1.4.2
17
+ jupyter_client==8.6.3
18
+ jupyter_core==5.7.2
19
+ MarkupSafe==3.0.2
20
+ matplotlib-inline==0.1.7
21
+ nest-asyncio==1.6.0
22
+ numpy==2.2.1
23
+ packaging==24.2
24
+ pandas==2.2.3
25
+ parso==0.8.4
26
+ pexpect==4.9.0
27
+ platformdirs==4.3.6
28
+ prompt_toolkit==3.0.48
29
+ psutil==6.1.1
30
+ ptyprocess==0.7.0
31
+ pure_eval==0.2.3
32
+ Pygments==2.18.0
33
+ python-dateutil==2.9.0.post0
34
+ pytz==2024.2
35
+ pyzmq==26.2.0
36
+ scikit-learn==1.6.0
37
+ scipy==1.14.1
38
+ setuptools==75.6.0
39
+ six==1.17.0
40
+ stack-data==0.6.3
41
+ threadpoolctl==3.5.0
42
+ tornado==6.4.2
43
+ traitlets==5.14.3
44
+ tzdata==2024.2
45
+ wcwidth==0.2.13
46
+ Werkzeug==3.1.3
47
+ wheel==0.45.1
static/home.css ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html {
2
+ scroll-behavior: smooth;
3
+ }
4
+
5
+ body {
6
+ background-color: rgb(36, 41, 46);
7
+ margin: 0;
8
+ }
9
+
10
+ a:link {
11
+ color: white;
12
+ /* Unvisited link */
13
+ }
14
+
15
+ a:visited {
16
+ color: white;
17
+ /* Visited link */
18
+ }
19
+
20
+ a:hover {
21
+ color: white;
22
+ /* On mouse hover */
23
+ }
24
+
25
+ a:active {
26
+ color: white;
27
+ /* Active (clicked) link */
28
+ }
29
+
30
+ div.container1 {
31
+ padding: 20px 23px 0px 23px;
32
+ }
33
+
34
+ header.navBar {
35
+ display: flex;
36
+ justify-content: space-between;
37
+ }
38
+
39
+ a.logo {
40
+ font-size: 2.2em;
41
+ display: flex;
42
+ gap: 8px;
43
+ text-decoration: none;
44
+ align-items: center;
45
+ }
46
+
47
+ span.greyColor {
48
+ color: gray;
49
+ }
50
+
51
+ a span.logoName {
52
+ font-family: "Bonheur Royale", serif;
53
+ font-weight: 900;
54
+ font-size: 2.5rem;
55
+ font-style: normal;
56
+ color: #ffd000;
57
+ }
58
+
59
+ ul.menu {
60
+ display: flex;
61
+ gap: 20px;
62
+ list-style-type: none;
63
+ font-family: "Jaro", sans-serif;
64
+ font-optical-sizing: auto;
65
+ font-weight: 400;
66
+ font-style: normal;
67
+
68
+ }
69
+ .hed{
70
+ font-family: "Jaro", sans-serif;
71
+ font-optical-sizing: auto;
72
+ font-weight: 400;
73
+ font-style: normal;
74
+ margin: 70px 70px;
75
+ text-align: center;
76
+ font-size: 3rem;
77
+ }
78
+
79
+ ul.menu li a:hover {
80
+ color: #20ff00;
81
+ transform: translateY(-3px);
82
+ transition: all .3s ease 0s;
83
+
84
+ }
85
+
86
+ .decoration {
87
+ text-decoration: none;
88
+ }
89
+
90
+ div.container2 h3{
91
+ font-family: "Jaro", sans-serif;
92
+ font-optical-sizing: auto;
93
+ font-weight: 400;
94
+ }
95
+ div.container2 {
96
+ display: flex;
97
+ flex-direction: row;
98
+ margin: 70px 70px;
99
+ justify-content: center;
100
+ font-style: normal;
101
+ flex-wrap: wrap;
102
+ }
103
+
104
+ div.card {
105
+ width: 250px;
106
+ margin:5px 5px 5px 5px;
107
+ padding: 30px 30px 30px 30px;
108
+ border: 1px solid gray;
109
+ border-radius: 12px;
110
+ box-sizing: border-box;
111
+ }
112
+
113
+ div.card img {
114
+ width: 130px;
115
+ border-radius: 12px;
116
+ margin-left:25px ;
117
+ }
118
+ .long-text {
119
+ overflow-wrap: break-word; /* Wrap long words */
120
+ white-space: normal;
121
+ }
122
+
123
+
124
+ .containerContactMe7{
125
+ display: flex;
126
+ /* justify-content:baseline ; */
127
+ margin: 60px 60px 60px 250px;
128
+
129
+
130
+ }
131
+ .name{
132
+ display: flex;
133
+ align-items: center;
134
+ }
135
+
136
+
137
+ i{
138
+ margin: 12px;
139
+ font-size: 40px;
140
+ }
141
+ .AboutMain{
142
+ font-family: "Jaro", sans-serif;
143
+ font-optical-sizing: auto;
144
+ font-weight: 400;
145
+ font-style: normal;
146
+ }
static/recommend.css ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ form{
2
+ display: flex;
3
+ gap: 10px;
4
+ justify-content: center;
5
+ margin: 30px;
6
+
7
+ }
8
+ input.inputText{
9
+ width: 70%;
10
+ padding: 12px 12px 12px 12px;
11
+ border: none;
12
+ border-radius: 12px;
13
+ }
14
+ input.inputBtn{
15
+ padding: 12px 12px 12px 12px;
16
+ border: none;
17
+ border-radius: 12px;
18
+ }
19
+ div.cont{
20
+ margin: 70px 70px;
21
+ font-style: normal;
22
+ flex-wrap: wrap;
23
+ }
24
+ .height{
25
+ height: 50vh;
26
+ }
27
+ div.card1 {
28
+ width: 250px;
29
+ margin:5px 5px 5px 5px;
30
+ padding: 20px 20px 20px 20px;
31
+ border: 1px solid gray;
32
+ border-radius: 12px;
33
+ box-sizing: border-box;
34
+ height: 450px;
35
+ }
36
+ div.card1 img {
37
+ width: 130px;
38
+ border-radius: 12px;
39
+ margin-left:25px ;
40
+ }
41
+
42
+ div.co{
43
+ display: flex;
44
+ flex-wrap: wrap;
45
+ justify-content: center;
46
+ gap: 10px;
47
+ }
templates/home.html ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link rel="preconnect" href="https://fonts.googleapis.com">
8
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
9
+ <link href="https://fonts.googleapis.com/css2?family=Bonheur+Royale&display=swap" rel="stylesheet">
10
+
11
+ <link href="https://fonts.googleapis.com/css2?family=Lacquer&display=swap" rel="stylesheet">
12
+
13
+ <link rel="preconnect" href="https://fonts.googleapis.com">
14
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
15
+ <link href="https://fonts.googleapis.com/css2?family=Jaro:opsz@6..72&display=swap" rel="stylesheet">
16
+ <link rel="stylesheet" href="{{ url_for('static', filename='MainStyle.css') }}">
17
+ <link rel="stylesheet" href="{{ url_for('static', filename='home.css') }}">
18
+ <title>Recommendation system</title>
19
+ </head>
20
+
21
+ <body>
22
+ <div class="container1">
23
+ <header class="navBar">
24
+ <a href="/" class="logo">
25
+ <span class="greyColor">
26
+
27
+ <span class="logoName">Recommend Yourself</span>
28
+
29
+
30
+ </a>
31
+ <ul class="menu">
32
+ <li><a href="{{ url_for('start') }}" class="decoration">Home</a></li>
33
+ <li><a href="{{ url_for('recommend') }}" class="decoration">Recommend</a></li>
34
+ <li><a href="" class="decoration">Blank</a></li>
35
+ <li><a href="#Contact" class="decoration">Contact me</a></li>
36
+ </ul>
37
+ </header>
38
+ </div>
39
+ <h1 class="hed">Some Top Books </h1>
40
+ <hr style="width: 70%;">
41
+ <div class="container2">
42
+
43
+ {% for i in range(bookName|length) %}
44
+ <div class="card">
45
+ <img src="{{ Image[i] }}" alt="">
46
+ <h3 class="long-text" >{{ bookName[i] }}</h3>
47
+ <p class="long-text">{{ bookauthor[i] }}</p>
48
+ <p class="long-text">ISBN : {{ Isbn[i] }}</p>
49
+ <p class="long-text">No. of Rating : {{ NoRating[i] }}</p>
50
+ </div>
51
+ {% endfor %}
52
+
53
+
54
+
55
+ </div>
56
+ <div class="containerContactMe7">
57
+ <div class="greetDivision">
58
+ <div class="left">
59
+ <div class="name">
60
+ <h1 style="font-size: 3rem;" id="Contact">Contact Me</h1>
61
+ <img alt="☎️" draggable="false" src="https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/260e.png" style="height: 4em; width: 4em; margin: 0px 0.05em 0px 3.1em; vertical-align: -0.1em;">
62
+ </div>
63
+ <h3 class="AboutMain">Discuss a project or just want to say hi? My Inbox is open for all.</h3>
64
+ <h1 style="font-size: 2rem;">Ayushaiml14@gmail.com</h1>
65
+ <div class="ContactsContainer1">
66
+ <a href="https://github.com/AyushAI14" target="_blank"><i
67
+ class="fa-brands fa-square-github"></i></a>
68
+ <a href="https://www.linkedin.com/in/ayush-vishwakarma-a2450a28b/" target="_blank"><i
69
+ class="fa-brands fa-linkedin"></i></a>
70
+ <a href="mailto:ayushaiml14@gmail.com" target="_blank"><i class="fa-solid fa-envelope"></i></a>
71
+ </div>
72
+ </div>
73
+
74
+ </div>
75
+ <script src="https://kit.fontawesome.com/73c3b1fe1f.js" crossorigin="anonymous"></script>
76
+
77
+ </body>
78
+
79
+ </html>
templates/recommend.html ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link rel="preconnect" href="https://fonts.googleapis.com">
8
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
9
+ <link href="https://fonts.googleapis.com/css2?family=Bonheur+Royale&display=swap" rel="stylesheet">
10
+
11
+ <link href="https://fonts.googleapis.com/css2?family=Lacquer&display=swap" rel="stylesheet">
12
+
13
+ <link rel="preconnect" href="https://fonts.googleapis.com">
14
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
15
+ <link href="https://fonts.googleapis.com/css2?family=Jaro:opsz@6..72&display=swap" rel="stylesheet">
16
+ <link rel="stylesheet" href="{{ url_for('static', filename='recommend.css') }}">
17
+ <link rel="stylesheet" href="{{ url_for('static', filename='home.css') }}">
18
+ <title>Recommendation system</title>
19
+ </head>
20
+
21
+ <body>
22
+ <div class="container1">
23
+ <header class="navBar">
24
+ <a href="/" class="logo">
25
+ <span class="greyColor">
26
+
27
+ <span class="logoName">Recommend Yourself</span>
28
+
29
+
30
+ </a>
31
+ <ul class="menu">
32
+ <li><a href="{{ url_for('start') }}" class="decoration">Home</a></li>
33
+ <li><a href="{{ url_for('recommend') }}" class="decoration">Recommend</a></li>
34
+ <li><a href="" class="decoration">Blank</a></li>
35
+ <li><a href="#Contact" class="decoration">Contact me</a></li>
36
+ </ul>
37
+ </header>
38
+ </div>
39
+ <h1 class="hed">Recommend Some Books</h1>
40
+ <hr style="width: 70%;">
41
+ <div class="cont">
42
+ <form action="/Userrecommend" method="post">
43
+ <input name="Userinput" class="inputText" type="text" placeholder="Enter Book Name">
44
+ <input class="inputBtn" type="submit" value="submit">
45
+ </form>
46
+ <h1 style="margin-left: 230px;">Books like : {{ user_input }}</h1> <br>
47
+ <div class="co">
48
+ {% if data %}
49
+
50
+ {% for i in data %}
51
+
52
+ <div class="height">
53
+ <div class="card1">
54
+ <img src={{ i[1] }} alt="">
55
+ <h3 style="font-size: 1rem;" class="long-text">{{i[0]}}</h3>
56
+ <p style="font-size: 1rem;" class="long-text">{{ i[2] }}</p>
57
+ <p style="font-size: 1rem;" class="long-text">ISBN : {{ i[3] }}</p>
58
+ </div>
59
+ </div>
60
+ {% endfor %}
61
+
62
+
63
+ {% endif %}
64
+
65
+
66
+
67
+ </div>
68
+
69
+ </div>
70
+ <div class="containerContactMe7">
71
+ <div class="greetDivision">
72
+ <div class="left">
73
+ <div class="name">
74
+ <h1 style="font-size: 3rem;" id="Contact">Contact Me</h1>
75
+ <img alt="☎️" draggable="false"
76
+ src="https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/260e.png"
77
+ style="height: 4em; width: 4em; margin: 0px 0.05em 0px 3.1em; vertical-align: -0.1em;">
78
+ </div>
79
+ <h3 class="AboutMain">Discuss a project or just want to say hi? My Inbox is open for all.</h3>
80
+ <h1 style="font-size: 2rem;">Ayushaiml14@gmail.com</h1>
81
+ <div class="ContactsContainer1">
82
+ <a href="https://github.com/AyushAI14" target="_blank"><i
83
+ class="fa-brands fa-square-github"></i></a>
84
+ <a href="https://www.linkedin.com/in/ayush-vishwakarma-a2450a28b/" target="_blank"><i
85
+ class="fa-brands fa-linkedin"></i></a>
86
+ <a href="mailto:ayushaiml14@gmail.com" target="_blank"><i class="fa-solid fa-envelope"></i></a>
87
+ </div>
88
+ </div>
89
+
90
+ </div>
91
+ <script src="https://kit.fontawesome.com/73c3b1fe1f.js" crossorigin="anonymous"></script>
92
+
93
+ </body>
94
+
95
+ </html>
wsgi.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from Webapp.app import app
2
+
3
+ if __name__ == "__main__":
4
+ app.run(debug=True)