Spaces:
Sleeping
Sleeping
import streamlit as st | |
import pandas as pd | |
from sklearn.ensemble import RandomForestClassifier | |
from joblib import load | |
st.title("Tabular Data Sentiment Analysis") | |
model = load('random_forest_model.joblib') | |
df = pd.DataFrame( | |
[{'product_id': 30, | |
'Review_Length': 252, | |
'Rating': 4, | |
'Avg_Word_Length': 5, | |
'Times_purchased': 13, | |
'unique_words': 40}]) | |
edited_df = st.data_editor(df, num_rows="dynamic") | |
if st.button("Predict Sentiment", type="primary"): | |
output = model.predict(edited_df) | |
edited_df['predicted sentiment'] = output | |
edited_df['predicted sentiment'].replace({0:"Positive", 1:"Negative"}, inplace=True) | |
st.text(edited_df) | |