Skip to content

Commit

Permalink
Minor modification made
Browse files Browse the repository at this point in the history
  • Loading branch information
SonyShrestha committed Jun 9, 2024
1 parent a3fd945 commit afb1812
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Website/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pages.closest_supermarket import closest_supermarket
from pages.sentiment_analysis import sentiment_analysis
from pages.time_series import show_feature5 as time_series
# from pages.food_recommender import food_recommender as food_recommender
from pages.food_recommender import food_recommender as food_recommender

# Set page configuration
st.set_page_config(page_title="SpicyBytes", layout="wide", initial_sidebar_state="collapsed")
Expand Down Expand Up @@ -76,7 +76,7 @@ def main():
'Customer Inventory': cust_purchase_expected_expiry,
'Dynamic Pricing': dynamic_pricing_streamlit,
'Closest Supermarket': closest_supermarket,
'Food Recommendation': sentiment_analysis,
'Food Recommendation': food_recommender,
'Sentiment Analysis': sentiment_analysis,
'Time Series Analysis': time_series
}
Expand Down
2 changes: 1 addition & 1 deletion Website/pages/food_recommender.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def preprocess_data(input_path):
def setup_langchain():
model_id = "meta-llama/Meta-Llama-3-8B"
# Create a pipeline for text generation
text_generator = pipeline("text-generation", model=model_id, model_kwargs={"torch_dtype": torch.bfloat16}, device_map="auto")
text_generator = pipeline("text-generation", model=model_id, token="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", model_kwargs={"torch_dtype": torch.bfloat16}, device_map="auto")

def generate_recipe(ingredients):
prompt = f"As a food recommender, create different delicious food from these ingredients: {ingredients}. Include the food name, detailed steps, and estimated time."
Expand Down
10 changes: 7 additions & 3 deletions Website/pages/sentiment_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ def display_reviews(df):
"review": "Review",
"Sentiment": "Sentiment",
"sentiment_label": "Sentiment Label",
"sentiment_score": "Sentiment Score"
"sentiment_score": "Sentiment Score",
"user_name":"User Name"
}, inplace=True)
# Exclude 'time' column from display
columns_to_display = [col for col in df.columns if col != 'time']
st.write(df[columns_to_display])
st.dataframe(df[columns_to_display], use_container_width=True)


def sentiment_analysis():
Expand Down Expand Up @@ -144,7 +145,10 @@ def sentiment_analysis():
df = df[(df['rating'] >= min_rating) & (df['rating'] <= max_rating)]
df = df[(df['date'] >= start_date) & (df['date'] <= end_date)]

df['business_name'] = df['business_name'].apply(lambda x: x.title())
if review_type == "Business Reviews":
df['business_name'] = df['business_name'].apply(lambda x: x.title())
else:
df['user_name'] = df['user_name'].apply(lambda x: x.title())
df['sentiment_label'] = df['sentiment_label'].apply(lambda x: x.title())
df['review'] = df['review'].apply(lambda x: x.capitalize())

Expand Down

0 comments on commit afb1812

Please sign in to comment.