Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Thulani #62

Open
wants to merge 102 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
ef2cc91
Collaborative Based Filtering NOT WORKING
ThulaniNyama Jul 4, 2022
3dfe458
Merge pull request #1 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 4, 2022
e341e63
Changes
SoulR95 Jul 10, 2022
b999e2f
Merge pull request #2 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 11, 2022
36631e0
Added new Gif
SoulR95 Jul 11, 2022
82ecb47
Gif and Help Page
SoulR95 Jul 11, 2022
417412e
Merge pull request #3 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 11, 2022
2b6b593
New plots for stats page
SoulR95 Jul 12, 2022
18a5593
Merge pull request #4 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 12, 2022
c1c41ce
Moved stats function to stats.py
SoulR95 Jul 14, 2022
de22484
Merge pull request #5 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 15, 2022
61e7c77
Helper page added
SoulR95 Jul 15, 2022
f3e03f5
Merge pull request #6 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 16, 2022
b7eeaa4
comments in progress
ThulaniNyama Jul 16, 2022
07fc85d
Merge pull request #7 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 16, 2022
c299f4f
update
ThulaniNyama Jul 16, 2022
c139747
Merge pull request #8 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 16, 2022
fe726e4
creating about page and adding content
ElelwaniTshikovhi Jul 16, 2022
f48e283
Merge pull request #9 from Dream-Team-Unsupervised/ella
ThulaniNyama Jul 16, 2022
d74c74f
Update UPDATE.py
ThulaniNyama Jul 16, 2022
7a13708
Merge pull request #10 from Dream-Team-Unsupervised/Thulani
ElelwaniTshikovhi Jul 16, 2022
6e49207
more updates
ThulaniNyama Jul 16, 2022
7404c15
Merge pull request #11 from Dream-Team-Unsupervised/Thulani
ElelwaniTshikovhi Jul 16, 2022
88516f0
Added Rtest1
SoulR95 Jul 17, 2022
8c164a6
Added the mp4
SoulR95 Jul 17, 2022
d71d904
Attempting to Fix
SoulR95 Jul 17, 2022
2d02225
Attempting merge
SoulR95 Jul 17, 2022
21b7c0e
Delete helper.py
SoulR95 Jul 17, 2022
404f0ac
fix
SoulR95 Jul 17, 2022
d6fe48c
Merge branch 'Riaan' of https://github.com/Dream-Team-Unsupervised/un…
SoulR95 Jul 17, 2022
4090b48
Finished recommend
SoulR95 Jul 17, 2022
155c6eb
more and more changes
ThulaniNyama Jul 17, 2022
a7b2950
Merge pull request #12 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 17, 2022
b2a96da
Merge pull request #13 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 17, 2022
98c0462
animation works
ThulaniNyama Jul 17, 2022
c6a22d0
Merge pull request #14 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 17, 2022
4d05f8f
updated edsa to match master
SoulR95 Jul 18, 2022
e736661
Added the help page to home page
SoulR95 Jul 18, 2022
cfb392e
Update Help page
SoulR95 Jul 18, 2022
48f97c0
Created vids folder
SoulR95 Jul 18, 2022
7dee396
Update
SoulR95 Jul 18, 2022
9834913
Merge branch 'master' into Riaan
ThulaniNyama Jul 19, 2022
d5d3a02
Merge pull request #15 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 19, 2022
1fa9a4a
Minor
SoulR95 Jul 19, 2022
af1c0d1
more changes
ThulaniNyama Jul 19, 2022
899a489
Merge pull request #16 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 19, 2022
d567ed2
Merge pull request #17 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 19, 2022
a94ab49
Added Youtube link
SoulR95 Jul 19, 2022
42050e7
Merge pull request #18 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 19, 2022
5e1cb46
Update Home Page
SoulR95 Jul 19, 2022
359a9e7
Updated Contact Us
SoulR95 Jul 19, 2022
c13ab61
Updated
SoulR95 Jul 19, 2022
ea1828a
Merge pull request #19 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 20, 2022
da74080
content base updated
SiyandaMadlopha Jul 20, 2022
8319a6b
msg
ThulaniNyama Jul 21, 2022
f87870c
finer detail
ThulaniNyama Jul 22, 2022
839a77a
Merge branch 'master' into Thulani
ThulaniNyama Jul 22, 2022
8d19a56
Merge pull request #20 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 22, 2022
1feafd0
Updated py files for content and colab
alnaschutte Jul 22, 2022
c7b2858
Merge branch 'master' into Alna
alnaschutte Jul 22, 2022
365b8f0
Updated py for Content and colab
alnaschutte Jul 22, 2022
e711bc3
Merge pull request #21 from Dream-Team-Unsupervised/Alna
alnaschutte Jul 22, 2022
e0ed9b0
Updated the loading of the files
alnaschutte Jul 22, 2022
377ac80
Merge pull request #22 from Dream-Team-Unsupervised/Alna
alnaschutte Jul 22, 2022
6175de7
Updated file path
alnaschutte Jul 22, 2022
042e1ae
Merge pull request #23 from Dream-Team-Unsupervised/Alna
alnaschutte Jul 22, 2022
db34251
Statistics in progress
ThulaniNyama Jul 22, 2022
f663a13
stats in progress
ThulaniNyama Jul 22, 2022
9bd0c6e
Merge branch 'Thulani' of https://github.com/Dream-Team-Unsupervised/…
ThulaniNyama Jul 22, 2022
996a73a
Merge pull request #24 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 22, 2022
4805d43
content
ThulaniNyama Jul 23, 2022
ffee89a
Delete .streamlit directory
ThulaniNyama Jul 23, 2022
4075f2b
recovery in progress
ThulaniNyama Jul 23, 2022
56c8899
Merge branch 'master' into Thulani
ThulaniNyama Jul 23, 2022
b406892
Merge pull request #25 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 23, 2022
30b898b
Update collaborative_based.py
SiyandaMadlopha Jul 23, 2022
76d1bf6
Added about video
SoulR95 Jul 24, 2022
f883d62
Added Contact us vid
SoulR95 Jul 24, 2022
0f92a43
Merge branch 'master' into Riaan
ThulaniNyama Jul 25, 2022
83a439f
Merge pull request #26 from Dream-Team-Unsupervised/Riaan
ThulaniNyama Jul 25, 2022
c3c7d9e
Collab
ThulaniNyama Jul 25, 2022
f92c619
Merge branch 'master' into Thulani
ThulaniNyama Jul 25, 2022
7d880e7
Merge pull request #27 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 25, 2022
21252ad
2 plots
ThulaniNyama Jul 26, 2022
06bd098
Pre-Final
ThulaniNyama Jul 26, 2022
37c4f16
Merge pull request #28 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 26, 2022
34c9713
Test-final
ThulaniNyama Jul 26, 2022
2b48078
Merge pull request #29 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 26, 2022
81ccf0c
Stats video
SoulR95 Jul 27, 2022
f6858ac
Merge remote-tracking branch 'origin/Riaan'
SiyandaMadlopha Jul 27, 2022
596af7e
Create python-package-conda.yml
ThulaniNyama Jul 27, 2022
716f478
Home to Recommend
ThulaniNyama Jul 28, 2022
16e7f96
Merge pull request #30 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 28, 2022
499717a
just for autograder
ThulaniNyama Jul 28, 2022
4d17f26
Merge pull request #31 from Dream-Team-Unsupervised/Thulani
ThulaniNyama Jul 28, 2022
83f4f25
Final Push
ThulaniNyama Jul 29, 2022
324e20e
Revert "just for autograder"
ThulaniNyama Aug 24, 2022
6866235
requirements
ThulaniNyama Aug 24, 2022
2d6111a
Merge pull request #32 from Dream-Team-Unsupervised/revert-31-Thulani
ThulaniNyama Aug 24, 2022
02a8e31
Merge branch 'Thulani' of https://github.com/Dream-Team-Unsupervised/…
ThulaniNyama Aug 27, 2022
891c209
Update edsa_recommender.py
ThulaniNyama Aug 27, 2022
e7a90c4
Merge branch 'master' into Thulani
ThulaniNyama Aug 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Python Package using Conda

on: [push]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: 3.10
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda env update --file environment.yml --name base
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
conda install pytest
pytest
128 changes: 84 additions & 44 deletions edsa_recommender.py
Original file line number Diff line number Diff line change
@@ -1,112 +1,152 @@
"""

Streamlit webserver-based Recommender Engine.

Author: Explore Data Science Academy.

Note:
---------------------------------------------------------------------
Please follow the instructions provided within the README.md file
located within the root of this repository for guidance on how to use
this script correctly.

NB: !! Do not remove/modify the code delimited by dashes !!

This application is intended to be partly marked in an automated manner.
Altering delimited code may result in a mark of 0.
---------------------------------------------------------------------

Description: This file is used to launch a minimal streamlit web
application. You are expected to extend certain aspects of this script
and its dependencies as part of your predict project.

For further help with the Streamlit framework, see:

https://docs.streamlit.io/en/latest/

"""
# Streamlit dependencies
import streamlit as st
import hydralit_components as hc

# Data handling dependencies
import pandas as pd
import numpy as np
from sympy import im

# Custom Libraries
from utils.data_loader import load_movie_titles
from recommenders.collaborative_based import collab_model
from recommenders.content_based import content_model

import functions.youtube_scrapper as top_trailers
import menu.trailers as t
import menu.data_professionals as dreamers
import menu.statistics as stat
import menu.helper as h
import menu.About as a
import time
# Data Loading
title_list = load_movie_titles('resources/data/movies.csv')
title_list = load_movie_titles('https://raw.githubusercontent.com/Dream-Team-Unsupervised/Data/main/movies.csv')

st.set_page_config(page_icon='resources/imgs/MovieXplorer.png', page_title= 'Movie Xplorer', layout='wide', initial_sidebar_state='auto')

over_theme = {'txc_inactive': '#FFFFFF'}

# specify the primary menu definition
menu_data = [
{'icon': "far fa-copy", 'label':'About'},
{'id':'Trailers','icon':'fas fa-film','label':'Trailers'},
{'icon': 'far fa-chart-bar', 'label':'Statistics'}, #no tooltip message
{'id':'Contact Us','icon': 'fas fa-laptop', 'label':'Contact Us'},
{'id':'Help', 'icon': 'fas fa-question', 'label':'Help'}
]

# App declaration
def main():

def main():
# define hydralit navbar
menu_id = hc.nav_bar(
menu_definition=menu_data,
override_theme=over_theme,

home_name='Home',
# login_name='Logout',
hide_streamlit_markers=False, #will show the st hamburger as well as the navbar now!
sticky_nav=True, #at the top or not
sticky_mode='pinned', #jumpy or not-jumpy, but sticky or pinned
)
page_selection = f'{menu_id}'
# DO NOT REMOVE the 'Recommender System' option below, however,
# you are welcome to add more options to enrich your app.
page_options = ["Recommender System","Solution Overview"]
# page_options = ["Recommender System", "About", "Trailers", "Statistics", "The Dream Team", "Help Page"]

# -------------------------------------------------------------------
# ----------- !! THIS CODE MUST NOT BE ALTERED !! -------------------
# -------------------------------------------------------------------
page_selection = st.sidebar.selectbox("Choose Option", page_options)
if page_selection == "Recommender System":
# page_selection = st.sidebar.selectbox("Choose Option", page_options)

if page_selection == 'Home':
# Header contents
st.write('# Movie Recommender Engine')
st.write('### EXPLORE Data Science Academy Unsupervised Predict')
st.image('resources/imgs/Image_header.png',use_column_width=True)
st.write('# Movie Xplorer')
# st.write('### EXPLORE Data Science Academy Unsupervised Predict')
st.image('resources/imgs/Header2L.gif',use_column_width=True)
# Recommender System algorithm selection
sys = st.radio("Select an algorithm",
('Content Based Filtering',
'Collaborative Based Filtering'))
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;justify-content: right;} </style>', unsafe_allow_html=True)
st.write('<style>div.st-bf{flex-direction:column;} div.st-ag{font-weight:bold;padding-right:2px;}</style>', unsafe_allow_html=True)
sys = st.radio("", ('Content Based Filtering', 'Collaborative Based Filtering'))

# User-based preferences
st.write('### Enter Your Three Favorite Movies')
movie_1 = st.selectbox('Fisrt Option',title_list[14930:15200])
movie_2 = st.selectbox('Second Option',title_list[25055:25255])
movie_3 = st.selectbox('Third Option',title_list[21100:21200])
st.write('### Select Your Three Favorite Movies')
movie_1 = st.selectbox('1ˢᵗ Movie',title_list[14930:15200])
movie_2 = st.selectbox('2ⁿᵈ Movie',title_list[25055:25255])
movie_3 = st.selectbox('3ʳᵈ Movie',title_list[21100:21200])
fav_movies = [movie_1,movie_2,movie_3]

# Perform top-10 movie recommendation generation
if sys == 'Content Based Filtering':
if st.button("Recommend"):
if st.button('Recommend'):
try:
with st.spinner('Crunching the numbers...'):
top_recommendations = content_model(movie_list=fav_movies,
top_n=10)
st.title("We think you'll like:")
# intialize hydralit loaders
with hc.HyLoader('We\'re getting movies only you will love...\n',hc.Loaders.standard_loaders,index=[5,0,3]):
# get top 10 recommended movies using the content_model algorithm
top_recommendations = content_model(movie_list=fav_movies, top_n=10)
time.sleep(5)
st.title('Only you will love these movies...')
for i,j in enumerate(top_recommendations):
st.subheader(str(i+1)+'. '+j)
# get trailer from youtube
top_trailers.youtubeScrapper(top_recommendations[i])
except:
st.error("Oops! Looks like this algorithm does't work.\
We'll need to fix it!")


if sys == 'Collaborative Based Filtering':
if st.button("Recommend"):
if st.button('Recommend'):
try:
with st.spinner('Crunching the numbers...'):
top_recommendations = collab_model(movie_list=fav_movies,
top_n=10)
st.title("We think you'll like:")
# intialize hydralit loaders
with hc.HyLoader('We\'re getting movies only you will love...\n',hc.Loaders.standard_loaders,index=[5,0,3]):
# get top 10 recommended movies using the collab_model algorithm
top_recommendations = collab_model(movie_list=fav_movies, top_n=10)
time.sleep(5)
st.title('Only you will love these movies...')
for i,j in enumerate(top_recommendations):
st.subheader(str(i+1)+'. '+j)
# get trailer from youtube
top_trailers.youtubeScrapper(top_recommendations[i])
except:
st.error("Oops! Looks like this algorithm does't work.\
We'll need to fix it!")


# -------------------------------------------------------------------

# ------------- SAFE FOR ALTERING/EXTENSION -------------------
if page_selection == "Solution Overview":
st.title("Solution Overview")
st.write("Describe your winning approach on this page")

# ------------- SAFE FOR ALTERING/EXTENSION -------------------------
elif page_selection == 'About':
# navigate to the About page
a.about()
elif page_selection == 'Trailers':
# navigate to the Trailers page
t.vids()
elif page_selection == 'Contact Us':
# navigate to the Contact Us page
dreamers.data_professionals()
elif page_selection == 'Statistics':
# navigate to the Statistics page
stat.visuals()
elif page_selection == 'Help':
# navigate to the Help page
h.helppage()
# You may want to add more sections here for aspects such as an EDA,
# or to provide your business pitch.


if __name__ == '__main__':
main()
7 changes: 7 additions & 0 deletions functions/CRUD/CREATE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import csv

def insert(post):
with open('./resources/data/comments.csv', 'a', newline='', encoding='UTF8') as c:
writer = csv.writer(c)
# write the data
writer.writerow(post)
16 changes: 16 additions & 0 deletions functions/CRUD/READ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import csv
import streamlit as st

COMMENT_TEMPLATE_MD = """{} - {}
> {}"""

def select():
# opening the CSV file
with open('./resources/data/comments.csv', mode='r') as c:
# reading the CSV file
csvFile = csv.reader(c)
# displaying the contents of the CSV file
next(csvFile)
for lines in csvFile:
st.markdown(COMMENT_TEMPLATE_MD.format(lines[0], lines[2], lines[1]))

7 changes: 7 additions & 0 deletions functions/CRUD/UPDATE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import csv

def insert(post):
with open('./resources/data/comments.csv', 'a', newline='', encoding='UTF8') as c:
writer = csv.writer(c)
# write the data
writer.writerow(post)
21 changes: 21 additions & 0 deletions functions/comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from datetime import datetime
import streamlit as st
import functions.CRUD.CREATE as create
import functions.CRUD.READ as read

def commenter(yr):

read.select()

form = st.form(yr + 'comments')
name = form.text_input('Name')
comment = form.text_area('Comment')
submit = form.form_submit_button('Share comment')

if submit:
date = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
par = [name, comment, date]
create.insert(par)
if "just_posted" not in st.session_state:
st.session_state["just_posted"] = True
st.experimental_rerun()
26 changes: 26 additions & 0 deletions functions/youtube_scrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import urllib.request
import requests
import unicodedata
import re
from streamlit_player import st_player
# import os
# import streamlit as st
# import googleapiclient.discovery

def youtubeScrapper(top_10):
search_string = unicodedata.normalize('NFKD', top_10).encode('ascii', 'ignore').decode()
youtube_str = re.sub("[ ]", "+", search_string)
html = urllib.request.urlopen('https://www.youtube.com/results?search_query=' + youtube_str + '+trailer')
vid_id = re.findall(r'watch\?v=(\S{11})', html.read().decode())

# Below we verify that the video contains nudity or not
# os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
# api_service_name = "youtube"
# api_version = "v3"
# youtube = googleapiclient.discovery.build(api_service_name, api_version, developerKey = 'AIzaSyCLfeDKMIRoTZ9JsDGALP3gbNnTb-3DLTQ')
# request = youtube.videos().getRating(id=str(vid_id[0]))
# response = request.execute()
# st.write(str(response))

trailer_res = 'https://www.youtube.com/watch?v=' + vid_id[0]
st_player(trailer_res)
26 changes: 26 additions & 0 deletions menu/About.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import streamlit as st

def about():
#about page title
st.title("Trends Analytics")
# company behind the app infomation
about_movieXplorer, movieXplorer_logo, = st.columns([2, 3])

with about_movieXplorer:
st.write("**About Trends Analytics**.")
st.info("Founded in 2022, Trends Analytics is a data driven company which provides data and business solutions. " +
"We use Artificial Intelligence (AI) and Advanced Analytics to enable more personalised " +
"solutions for your business needs. We are passionate about Artificial Intelligence and its impact in the " +
"future of our society. We help optimise operations, superior customer experiences and innovative business models. " +
"We have a team of certified Data Professionals, which consists of Data Scientists, Engineers, Analysts and Project Managers.")
st.markdown("")
#app information
st.write("**About Movie Xplorer**.")
st.info("Movie Xplorer is a movie recommendation application which uses collaborative and content-based algorithms to recommend " +
"movies to the user. The dataset is obtained from MovieLens and is maintained by the GroupLens research group in the " +
"Department of Computer Science and Engineering at the University of Minnesota. Additional movie content data was legally " +
"scraped from IMDB. The movie recommendations are catered to each user\'s needs and the user can comment about the movies they" +
" have watched. The video content is legally scraped from YouTube.")
st.markdown("")
with movieXplorer_logo:
st.image('resources/imgs/MovieXplorer.png', caption="© The Dream Team")
Loading