mrrandom123 commited on
Commit
1bef7aa
1 Parent(s): 268ce0a

Upload 8 files

Browse files
Files changed (8) hide show
  1. .gitignore +141 -0
  2. Books recommendation .ipynb +0 -0
  3. Procfile +1 -0
  4. README.md +0 -12
  5. app.py +69 -0
  6. requirements.txt +5 -0
  7. setup.py +26 -0
  8. setup.sh +0 -0
.gitignore ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # if using pycharm
132
+ .idea
133
+
134
+ # if using VScode
135
+ .vscode
136
+
137
+ # add secret keys or API keys here
138
+ configs/secrets.yaml
139
+
140
+ # add your env folder here if its there
141
+
Books recommendation .ipynb ADDED
The diff for this file is too large to render. See raw diff
 
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: sh setup.sh && streamlit run app.py
README.md CHANGED
@@ -1,12 +0,0 @@
1
- ---
2
- title: Book Recommendation
3
- emoji: 📊
4
- colorFrom: red
5
- colorTo: purple
6
- sdk: streamlit
7
- sdk_version: 1.15.2
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import streamlit as st
3
+ import numpy as np
4
+
5
+ st.header("Movie Recommender System using machine learning system")
6
+ model = pickle.load(open('artifacts/model.pkl','rb'))
7
+ books_name = pickle.load(open('artifacts/books_names.pkl','rb'))
8
+ final_rating = pickle.load(open('artifacts/final_rating.pkl','rb'))
9
+ book_pivot = pickle.load(open('artifacts/book_pivot.pkl','rb'))
10
+
11
+ selected_books = st.selectbox(
12
+ "Type or select a book",
13
+ books_name
14
+ )
15
+ def fetch_poster(suggestion):
16
+ books_name = []
17
+ ids_index = []
18
+ poster_url = []
19
+
20
+ for book_id in suggestion:
21
+ books_name.append(book_pivot.index[book_id])
22
+
23
+ for i in books_name[0]:
24
+ ids = np.where(final_rating['title']==i)[0][0]
25
+ ids_index.append(ids)
26
+
27
+ for idx in ids_index:
28
+ url = final_rating.iloc[idx]['img_url']
29
+ poster_url.append(url)
30
+ return poster_url
31
+
32
+
33
+
34
+ def recommend_book(book_name):
35
+ book_list = []
36
+ book_id = np.where(book_pivot.index == book_name)[0][0]
37
+ distance, suggestion = model.kneighbors(book_pivot.iloc[book_id,:].values.reshape(1,-1), n_neighbors=6 )
38
+
39
+ poster_url = fetch_poster(suggestion)
40
+
41
+
42
+ for i in range(len(suggestion)):
43
+ books = book_pivot.index[suggestion[i]]
44
+ for j in books:
45
+ book_list.append(j)
46
+ return book_list, poster_url
47
+
48
+ if st.button("Show Recommendation "):
49
+ recommended_books,poster_url = recommend_book(selected_books)
50
+ col1, col2, col3,col4, col5 = st.columns(5)
51
+
52
+ with col1:
53
+ st.text(recommended_books[1])
54
+ st.image(poster_url[1])
55
+
56
+ with col2:
57
+ st.text(recommended_books[2])
58
+ st.image(poster_url[2])
59
+
60
+ with col3:
61
+ st.text(recommended_books[3])
62
+ st.image(poster_url[3])
63
+ with col4:
64
+ st.text(recommended_books[4])
65
+ st.image(poster_url[4])
66
+ with col5:
67
+ st.text(recommended_books[5])
68
+ st.image(poster_url[5])
69
+
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit
2
+ numpy
3
+ scikit-learn
4
+
5
+ -e .
setup.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import setup
2
+
3
+ with open("README.md", "r", encoding="utf-8") as f:
4
+ long_description = f.read()
5
+
6
+ ## edit below variables as per your requirements -
7
+ REPO_NAME = "Books-Recommender-System-Using-Machine-Learning"
8
+ AUTHOR_USER_NAME = "entbappy"
9
+ SRC_REPO = "src"
10
+ LIST_OF_REQUIREMENTS = ['streamlit', 'numpy']
11
+
12
+
13
+ setup(
14
+ name=SRC_REPO,
15
+ version="0.0.1",
16
+ author=AUTHOR_USER_NAME,
17
+ description="A small package for Movie Recommender System",
18
+ long_description=long_description,
19
+ long_description_content_type="text/markdown",
20
+ url=f"https://github.com/{AUTHOR_USER_NAME}/{REPO_NAME}",
21
+ author_email="entbappy73@gmail.com",
22
+ packages=[SRC_REPO],
23
+ license="MIT",
24
+ python_requires=">=3.7",
25
+ install_requires=LIST_OF_REQUIREMENTS
26
+ )
setup.sh ADDED
File without changes