Skip to content

Commit

Permalink
feat: add new recommend by gender movie or tv show (#17) closes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0v0ne authored Nov 18, 2023
1 parent 777791e commit 8cbb37f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 23,005 deletions.
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
streamlit==1.26.0
requests==2.31.0
pandas==2.0.3
numpy==1.24.0
numpy==1.24.0
joblib==1.3.2
scikit-learn==1.3.0
23 changes: 23 additions & 0 deletions src/components/query.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import pandas as pd
from components.responses import response_markdown, response_recommends
import joblib as jl

def recommends(
dataset:pd.DataFrame,
Expand Down Expand Up @@ -30,4 +32,25 @@ def recommends(
result = dataset[dataset['clusters_genre_type'] == k_id][cols_view][:int(top_n)]
result.set_index('title')

return response_recommends(result)


def recommender_by_gender(dataset, options: list, cols: list):

if options == 0:
return response_markdown('Empty')

input_group = {x: [0] for x in cols}
for x in options:
input_group[x] = [1]
y_input = pd.DataFrame(input_group)
path_model = os.path.join('./src/data', 'models', 'model_kmeans_20231118')
model = jl.load(f'{path_model}.pkl')

pred_test = model.predict(y_input)
pred_test[0]

result = dataset[dataset['clusters_genre_type'] == pred_test[0] ][['title', 'gender_type', 'channel_streaming']]
result.set_index('title')

return response_recommends(result)
2 changes: 1 addition & 1 deletion src/components/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def response_recommends(results: pd.DataFrame)-> st.dataframe:
st.dataframe(
results,
use_container_width=False,
use_container_width=True,
)

def response_markdown(text: str) -> st.markdown:
Expand Down
Loading

0 comments on commit 8cbb37f

Please sign in to comment.