Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoOMaia committed Nov 26, 2023
1 parent 1752b60 commit 6222d74
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
3 changes: 0 additions & 3 deletions Kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ spec:
volumeMounts:
- name: persistent-volume
mountPath: /app/models
env:
- name: FILE_PATH_DATASET
value: "https://homepages.dcc.ufmg.br/~cunha/hosted/cloudcomp-2023s2-datasets/2023_spotify_ds1.csv"
## Persistent Volume ##
volumes:
- name: persistent-volume
Expand Down
Binary file modified Pickle/freq.pkl
Binary file not shown.
Binary file modified Pickle/rules.pkl
Binary file not shown.
4 changes: 0 additions & 4 deletions Rest_API/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ RUN adduser \
--uid "${UID}" \
appuser

RUN apt-get update && \
apt-get install -y wget && \
rm -rf /var/lib/apt/lists/

RUN pip install -r requirements.txt

USER appuser
Expand Down
4 changes: 2 additions & 2 deletions Rest_API/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def recommend():

@app.route('/api/songs', methods=['GET'])
def get_songs():
with open('/app/Tracknames/updated_track_names.json', 'r') as file:
with open('Tracknames/updated_track_names.json', 'r') as file:
songs_data = json.load(file)
return jsonify({'songs': songs_data})

if __name__ == '__main__':
app.run(port=32196)
app.run(port=32196, host="0.0.0.0")
19 changes: 11 additions & 8 deletions Train_model/ml.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import pickle
import pandas as pd
import os
import ssl
import requests
from io import StringIO
from mlxtend.frequent_patterns import apriori, association_rules

FILE_PATH_DATASET = os.environ.get('FILE_PATH_DATASET')
URL = "https://homepages.dcc.ufmg.br/~cunha/hosted/cloudcomp-2023s2-datasets/2023_spotify_ds1.csv"
RULES_PATH = "/app/models/rules.pkl"
FREK_PATH = "/app/models/freq.pkl"

min_support = 0.05
min_support = 0.04
min_threshold = 1

class FreqDatasetMining:
def __init__(self, file_path):
self.file_path = file_path
def __init__(self, file):
self.file = file
self.df = None
self.freq = None
self.rules = None

def group_by_pid_and_track_uri(self):
df = pd.read_csv(self.file_path)
df = self.file

df = df.groupby(['pid', 'track_name'])['track_name'].count().unstack().fillna(0)

Expand Down Expand Up @@ -48,7 +48,10 @@ def get_rules(self):


if __name__ == '__main__':
fdm = FreqDatasetMining(FILE_PATH_DATASET)
response = requests.get(URL, verify=False)
csv_data = StringIO(response.text)
df = pd.read_csv(csv_data)
fdm = FreqDatasetMining(df)
fdm.group_by_pid_and_track_uri()
fdm.get_freq()
fdm.get_rules()
3 changes: 2 additions & 1 deletion Train_model/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mlxtend
pandas
pandas
requests

0 comments on commit 6222d74

Please sign in to comment.