-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update gitignore, add IDE * feat: add dockerfile to streamlit app * feat: create scripts * feat: move files * feat: resolve error in dockerfile * feat: update function recommends and add new components * feat: add checkbox in service * feat: remove description * feat: split page in colunmns * feat: remove variable * feat: remove variable * feat: add improves in pipeline --------- Co-authored-by: eddi <[email protected]>
- Loading branch information
Showing
19 changed files
with
69,176 additions
and
46,068 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,3 +120,6 @@ dmypy.json | |
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# IDE | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM python:3.10 | ||
|
||
|
||
COPY /requirements.txt / | ||
|
||
RUN pip install --upgrade pip & \ | ||
pip install -r requirements.txt | ||
|
||
WORKDIR /streamlit | ||
|
||
COPY /src /streamlit/src | ||
#COPY /.streamlit /streamlit/.streamlit | ||
#COPY /main.py /streamlit | ||
|
||
EXPOSE 7999 | ||
|
||
ENTRYPOINT ["streamlit", "run", "/streamlit/src/main.py", "--server.port=7999"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,37 @@ | ||
import os | ||
|
||
import joblib | ||
import numpy as np | ||
import pandas as pd | ||
from sklearn.cluster import KMeans | ||
|
||
|
||
def pipeline_clusters(path_input, data_train, all_data): | ||
def init_train(path_input, data_train, all_data): | ||
print('-' * 100) | ||
print('Final') | ||
path_train = os.path.join(path_input, 'processed', data_train) | ||
print('Initialize Train') | ||
path_train = os.path.join(path_input, 'data', 'processed', data_train) | ||
X_train = np.array(pd.read_csv(path_train)) | ||
|
||
kmeans_model = KMeans(n_clusters=35, random_state=0) | ||
kmeans_model = KMeans(n_clusters=277, random_state=123456) | ||
y_clusters = kmeans_model.fit_predict(X_train) | ||
|
||
path_dataset = os.path.join(path_input, 'processed' ,all_data) | ||
|
||
print('Prepare new Dataframe') | ||
path_dataset = os.path.join(path_input, 'data', 'processed', all_data) | ||
dataset = pd.read_csv(path_dataset) | ||
dataset['clusters_genre_type'] = y_clusters | ||
OUTPUT= os.path.join(path_input, 'final') | ||
|
||
print('Save outputs') | ||
OUTPUT= os.path.join(path_input, 'data', 'final') | ||
|
||
if not os.path.exists(OUTPUT): | ||
os.mkdir(OUTPUT) | ||
dataset.to_csv('data/final/dataset_titles_final.csv', index=False) | ||
print('Sucefully data final') | ||
|
||
|
||
OUTPUT_MODEL = os.path.join(path_input, 'data', 'models') | ||
|
||
if not os.path.exists(OUTPUT_MODEL): | ||
os.mkdir(OUTPUT_MODEL) | ||
|
||
model_path = os.path.join(OUTPUT_MODEL, 'model_kmeans_20231118.pkl') | ||
joblib.dump(kmeans_model, model_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
docker build . -f ./containers/Dockerfile.streamlit -t streamlit_app:latest --rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
bash ./scripts/build.sh | ||
docker run -v ${PWD}/src:/streamlit/src -p 7999:7999 streamlit_app:latest |
File renamed without changes.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,33 @@ | ||
def query_name_title(dataset, nome, top_n): | ||
new_search = nome.upper() | ||
movie = dataset[dataset['title'] == new_search][['clusters_genre_type']] | ||
import pandas as pd | ||
from components.responses import response_markdown, response_recommends | ||
|
||
def recommends( | ||
dataset:pd.DataFrame, | ||
name: str, | ||
top_n: int, | ||
extra_cols: dict, | ||
) -> pd.DataFrame: | ||
|
||
rename = name.lower() | ||
exists_title = len(dataset[dataset['title'].str.contains(rename)]) | ||
|
||
if exists_title == 0: | ||
return response_markdown('This title not exists') | ||
|
||
try: | ||
top_n = int(top_n) | ||
except Exception as e: | ||
print('Exception', e) | ||
return response_markdown('This is not number') | ||
|
||
extra_cols = [x for x, y in extra_cols.items() if y] | ||
|
||
movie = dataset[dataset['title'] == rename][['clusters_genre_type']] | ||
reset_movie = movie.reset_index() | ||
reset_movie = reset_movie.at[0, 'clusters_genre_type'] | ||
k_id = int(reset_movie) | ||
result = dataset[dataset['clusters_genre_type'] == k_id][['title', 'gender_type']][:int(top_n)] | ||
cols_view = ['title', 'gender_type'] + extra_cols | ||
result = dataset[dataset['clusters_genre_type'] == k_id][cols_view][:int(top_n)] | ||
result.set_index('title') | ||
return result | ||
|
||
return response_recommends(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pandas as pd | ||
import streamlit as st | ||
|
||
|
||
def response_recommends(results: pd.DataFrame)-> st.dataframe: | ||
st.dataframe( | ||
results, | ||
use_container_width=False, | ||
) | ||
|
||
def response_markdown(text: str) -> st.markdown: | ||
st.markdown(text) |
Oops, something went wrong.