Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +77 -0
- rf_amazon.pkl +3 -0
- svm_amazon.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import joblib
|
| 3 |
+
import neattext.functions as nfx
|
| 4 |
+
|
| 5 |
+
# Sayfa Ayarları / Page Settings
|
| 6 |
+
st.set_page_config(page_title="Amazon Review AI", page_icon="🛒", layout="centered")
|
| 7 |
+
|
| 8 |
+
# Modeli Yükle / Load the Model
|
| 9 |
+
try:
|
| 10 |
+
svm_model = joblib.load("svm_amazon.pkl")
|
| 11 |
+
except:
|
| 12 |
+
st.error("Model dosyası (svm_amazon.pkl) bulunamadı! / Model file not found!")
|
| 13 |
+
|
| 14 |
+
# --- SOL MENÜ (SIDEBAR) ---
|
| 15 |
+
with st.sidebar:
|
| 16 |
+
st.title("💡 Sample Reviews / Örnek Yorumlar")
|
| 17 |
+
st.write("Copy and paste to test: / Test etmek için kopyalayın:")
|
| 18 |
+
|
| 19 |
+
st.subheader("✅ Positive / Pozitif")
|
| 20 |
+
st.code("This product is fantastic and totally worth the buy!")
|
| 21 |
+
st.code("Great quality, I am very satisfied with this purchase.")
|
| 22 |
+
|
| 23 |
+
st.subheader("❌ Negative / Negatif")
|
| 24 |
+
st.code("Worst product ever. It broke in one day, total waste of money.")
|
| 25 |
+
st.code("Terrible experience. The quality is very poor and awful.")
|
| 26 |
+
|
| 27 |
+
st.divider()
|
| 28 |
+
|
| 29 |
+
# Teknik Not Bölümü / Technical Note Section
|
| 30 |
+
st.info("""
|
| 31 |
+
**📊 Technical Note / Teknik Not:**
|
| 32 |
+
|
| 33 |
+
This app uses the **SVM (Support Vector Machine)** model.
|
| 34 |
+
During the training phase, **Random Forest (84.6%)** and **SVM (92.6%)** models were compared.
|
| 35 |
+
The SVM model, which provided the highest accuracy, was deployed.
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
Bu uygulama arka planda **SVM** modelini kullanmaktadır.
|
| 40 |
+
Eğitim aşamasında **Random Forest (%84.6)** ve **SVM (%92.6)** modelleri karşılaştırılmış, en yüksek doğruluğu veren SVM modeli yayına alınmıştır.
|
| 41 |
+
""")
|
| 42 |
+
|
| 43 |
+
# --- ANA PANEL (MAIN PANEL) ---
|
| 44 |
+
st.title("🛒 Amazon Review Sentiment Analysis")
|
| 45 |
+
st.subheader("Sentiment Analysis Dashboard / Duygu Analizi Paneli")
|
| 46 |
+
st.write("Enter a review, and AI will analyze it. / Yorumunuzu girin, yapay zeka analiz etsin.")
|
| 47 |
+
|
| 48 |
+
# Kullanıcı Girişi / User Input
|
| 49 |
+
user_input = st.text_area(
|
| 50 |
+
"Your Review / Yorumunuz:",
|
| 51 |
+
height=150,
|
| 52 |
+
placeholder="Type here or paste a sample from the left... / Buraya yazın veya soldan bir örnek seçin..."
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
# Analiz Butonu / Analysis Button
|
| 56 |
+
predict_btn = st.button("🔍 Analyze Sentiment / Duyguyu Analiz Et", use_container_width=True)
|
| 57 |
+
|
| 58 |
+
if predict_btn:
|
| 59 |
+
if user_input.strip() == "":
|
| 60 |
+
st.warning("Please enter a text for analysis! / Lütfen analiz için bir metin girin!")
|
| 61 |
+
else:
|
| 62 |
+
# Metni temizle / Clean the text
|
| 63 |
+
clean_text = nfx.normalize(user_input)
|
| 64 |
+
|
| 65 |
+
# Tahmin (SVM) / Prediction
|
| 66 |
+
pred = svm_model.predict([clean_text])[0]
|
| 67 |
+
|
| 68 |
+
# Sonuç Ekranı / Result Display
|
| 69 |
+
st.divider()
|
| 70 |
+
if pred == 1:
|
| 71 |
+
st.success("### ✨ RESULT: POSITIVE / SONUÇ: POZİTİF 😊")
|
| 72 |
+
st.balloons()
|
| 73 |
+
else:
|
| 74 |
+
st.error("### ⚠️ RESULT: NEGATIVE / SONUÇ: NEGATİF 😡")
|
| 75 |
+
|
| 76 |
+
# Alt Bilgi / Footer Caption
|
| 77 |
+
st.caption("Analysis performed with SVM algorithm (%92.6 Accuracy). / Analiz SVM algoritması ile %92.6 doğrulukla yapılmıştır.")
|
rf_amazon.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ddb0d19999e854219fcd8b06f49409aeca105ca06c0978b1d95e8fbebc9b1a00
|
| 3 |
+
size 15324727
|
svm_amazon.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8924bdb0b700f29b4945532cba6d5443f97dadf4f6e4f6fc09c1d343404bc83a
|
| 3 |
+
size 381741
|