diff --git a/form_configs/review_sentiments.json b/form_configs/review_sentiments.json new file mode 100644 index 00000000..03474436 --- /dev/null +++ b/form_configs/review_sentiments.json @@ -0,0 +1,9 @@ +{ + "Review Sentiments Form": { + "Review": { + "field_name": "review", + "type": "text", + "required": true + } + } +} diff --git a/models/Review_sentiments/data/dataset.csv b/models/Review_sentiments/data/dataset.csv new file mode 100644 index 00000000..3eea33f1 --- /dev/null +++ b/models/Review_sentiments/data/dataset.csv @@ -0,0 +1,103 @@ +text,sentiment +"I love this product! It's fantastic.",1 +"This is the worst experience ever.",0 +"Absolutely fantastic service!",1 +"Not worth the money.",0 +"I'm so happy with my purchase!",1 +"Terrible customer support.",0 +"This is the best thing I've ever bought!",1 +"I hate this! So disappointing.",0 +"Highly recommend this to everyone!",1 +"Will never buy this again.",0 +"This has changed my life for the better.",1 +"Awful experience, I want a refund.",0 +"Great quality for the price.",1 +"Too good to be true, but it is!",1 +"Very unsatisfied with my order.",0 +"I am thrilled with my purchase!",1 +"Do not waste your money on this.",0 +"Such a wonderful experience!",1 +"Will not recommend to friends.",0 +"Perfect! Exactly what I wanted.",1 +"Terrible product, do not buy.",0 +"I couldn't be happier with my purchase!",1 +"The quality is amazing, highly recommend!",1 +"Very disappointed, it broke after one use.",0 +"Best purchase I’ve made all year!",1 +"Awful service, I will not be returning.",0 +"This is an absolute gem, I love it!",1 +"Not what I expected at all, very misleading.",0 +"Fantastic! I use it every day.",1 +"I had high hopes, but I'm let down.",0 +"Such a great value for the money!",1 +"Really poor quality, I'm returning it.",0 +"This makes my life so much easier!",1 +"I would give this 0 stars if I could.",0 +"I'm impressed with the quality!",1 +"Never again, I'm so upset with this purchase.",0 +"Great customer service experience!",1 +"Disappointing, did not meet expectations.",0 +"I'm absolutely in love with this!",1 +"Terrible experience, will not recommend.",0 +"Best decision I ever made!",1 +"Awful, I should have read the reviews first.",0 +"Such a handy tool, I recommend it!",1 +"Not worth the hype, very disappointing.",0 +"I'm so glad I bought this!",1 +"Will never purchase from here again.",0 +"Brilliant product, works perfectly!",1 +"Really bad experience, I regret it.",0 +"This is a lifesaver, I love it!",1 +"Very dissatisfied, it does not work as promised.",0 +"Fantastic results, I'm very pleased!",1 +"Absolutely terrible, I want my money back.",0 +"Excellent value, I would buy again!",1 +"Awful, it broke after one day.",0 +"Thrilled with this purchase!",1 +"Not what I expected at all, I'm disappointed.",0 +"Best thing I've bought this year!",1 +"I will never buy this brand again.",0 +"Such a wonderful addition to my life!",1 +"Terrible product, completely useless.",0 +"Love this! It exceeded my expectations.",1 +"Very unhappy with my purchase.",0 +"Great product, I use it daily!",1 +"Complete waste of money.",0 +"I'm so impressed, thank you!",1 +"Disappointed, it didn't live up to the hype.",0 +"This is everything I wanted!",1 +"Never buying from this company again.",0 +"Fantastic quality, highly recommend!",1 +"Really bad experience, never again.",0 +"Absolutely love it, will buy again!",1 +"Very disappointed, not worth it at all.",0 +"This is just perfect for me!",1 +"Awful service, I'm very upset.",0 +"Great results, very satisfied!",1 +"I was misled, it's not what I expected.",0 +"Such a helpful product, I love it!",1 +"Very unhappy with this, it doesn't work.",0 +"This is a must-have for anyone!",1 +"Completely unsatisfied, do not recommend.",0 +"I'll definitely buy this again!",1 +"Very bad quality, I'm returning it.",0 +"Wonderful product, I'm very happy!",1 +"Not worth the price, very disappointed.",0 +"Exceptional product, I love it!",1 +"Awful purchase, I regret it.",0 +"Fantastic service, I will return!",1 +"Very unsatisfied, it broke so fast.",0 +"This has been a game changer for me!",1 +"Total waste of money, very unhappy.",0 +"Great experience from start to finish!",1 +"Very unhappy, I expected better.",0 +"Absolutely perfect for my needs!",1 +"Will not buy this again, I'm let down.",0 +"I would recommend this to anyone!",1 +"Very bad experience, don't buy this.",0 +"Great product! Works like a charm.",1 +"I'm really disappointed in this purchase.",0 +"Highly recommend this to anyone looking!",1 +"Terrible, it broke right away.",0 +"Super happy with my decision to buy this!",1 +"Very disappointed with the quality.",0 diff --git a/models/Review_sentiments/predict.py b/models/Review_sentiments/predict.py new file mode 100644 index 00000000..ec44cb23 --- /dev/null +++ b/models/Review_sentiments/predict.py @@ -0,0 +1,17 @@ +import joblib +import pandas as pd + +# Load the model and vectorizer +model = joblib.load("models/review_sentiments/saved_models/model (2).pkl") +vectorizer = joblib.load( + "models/review_sentiments/saved_models/vectorizer.pkl" +) + +def predict_sentiment(tweet): + # Transform the input tweet + tweet_vectorized = vectorizer.transform([tweet]) + + # Make prediction + prediction = model.predict(tweet_vectorized)[0] + + return "Positive" if prediction == 1 else "Negative" diff --git a/models/Review_sentiments/saved_models/model (2).pkl b/models/Review_sentiments/saved_models/model (2).pkl new file mode 100644 index 00000000..d8029534 Binary files /dev/null and b/models/Review_sentiments/saved_models/model (2).pkl differ diff --git a/models/Review_sentiments/saved_models/vectorizer.pkl b/models/Review_sentiments/saved_models/vectorizer.pkl new file mode 100644 index 00000000..4a779390 Binary files /dev/null and b/models/Review_sentiments/saved_models/vectorizer.pkl differ diff --git a/pages/Review_Sentiments.py b/pages/Review_Sentiments.py new file mode 100644 index 00000000..df253ca6 --- /dev/null +++ b/pages/Review_Sentiments.py @@ -0,0 +1,25 @@ +import streamlit as st +import json +from models.review_sentiments.predict import predict_sentiment + +# Load form configuration +with open("form_configs/review_sentiments.json") as f: + form_config = json.load(f) + +st.title("Review Sentiments") + +# Generate form based on custom form config +input_data = { + field_data["field_name"]: st.text_area(field_name, height=100) + for field_name, field_data in form_config["Review Sentiments Form"].items() + if field_data["type"] == "text" +} + +# Submit button +if st.button("Predict"): + review = input_data.get("review", "").strip() + if review: + result = predict_sentiment(review) + st.write(f"Prediction: {result}") + else: + st.warning("Please enter a review before predicting.") diff --git a/pages/pages.json b/pages/pages.json index cc76fe56..6714a03a 100644 --- a/pages/pages.json +++ b/pages/pages.json @@ -173,7 +173,6 @@ } ] }, - "Insurance Cost Predictor": { "title": "Insurance Cost Predictor", "page_title": "Insurance Cost Predictor",