Spaces:
Runtime error
Runtime error
import joblib | |
import gradio as gr | |
# Load the model and vectorizer | |
model = joblib.load('logistic_regression_model.pkl') | |
vectorizer = joblib.load('tfidf_vectorizer.pkl') | |
def predict_review_rating(review_text): | |
# Transform the review text using the loaded vectorizer | |
review_tfidf = vectorizer.transform([review_text]) | |
# Make prediction | |
prediction = model.predict(review_tfidf) | |
return prediction[0] | |
# Create the Gradio interface | |
interface = gr.Interface( | |
fn=predict_review_rating, | |
inputs=gr.Textbox(label="Enter Review Text"), | |
outputs=gr.Textbox(label="Predicted Rating"), | |
title="TripAdvisor Review Rating Predictor", | |
description="Enter a TripAdvisor review and get the predicted rating (1-5)." | |
) | |
# Launch the interface | |
interface.launch() | |