Fatser commited on
Commit
2d2ea1d
·
verified ·
1 Parent(s): e8f8ef6

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +39 -0
  2. movies.json +0 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from scipy import spatial
4
+ import json
5
+
6
+ # JSON dosyasını yükleme
7
+ with open('movies.json', 'r') as file:
8
+ movie_dict = json.load(file)
9
+
10
+ # Mesafe hesaplama fonksiyonu
11
+ def compute_distance(a,b):
12
+ genre_distance=spatial.distance.cosine(a[3],b[3])
13
+ popularity_distance=abs(a[2]-b[2])
14
+ return genre_distance+popularity_distance
15
+
16
+ # Uygulama başlığı
17
+ st.title("Film Benzerliği Hesaplama")
18
+
19
+ # Kullanıcıdan film adı alma
20
+ input_movie = st.selectbox("Bir film seçin:", list(movie_dict.keys()))
21
+
22
+ # "Hesapla" butonu
23
+ if st.button("Benzer Filmleri Bul"):
24
+ # Girilen film ile diğer filmler arasındaki mesafeleri hesaplamak
25
+ input_movie_data = movie_dict[input_movie]
26
+
27
+ # Mesafeleri hesaplama
28
+ distances = {}
29
+ for movie, data in movie_dict.items():
30
+ if movie != input_movie:
31
+ distances[movie] = compute_distance(input_movie_data, data)
32
+
33
+ # En benzer 5 filmi bulma
34
+ similar_movies = sorted(distances.items(), key=lambda x: x[1])[:5]
35
+
36
+ # Sonuçları gösterme
37
+ st.subheader("En benzer 5 film:")
38
+ for movie, distance in similar_movies:
39
+ st.write(f"{movie} - Mesafe: {distance:.2f}")
movies.json ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ scikit-learn