import gradio as gr import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Load your data here if not already loaded # data = pd.read_csv('path_to_your_data.csv') def analyze_sentiment(data): # Calculate summary global sentiment overall_sentiment = data['airline_sentiment'].value_counts().reset_index() overall_sentiment.columns = ['Sentiment', 'Freq'] # Plot histogram plt.figure(figsize=(8, 6)) sns.barplot(data=overall_sentiment, x='Sentiment', y='Freq', palette=['indianred', 'deepskyblue']) plt.xlabel('Sentiment') plt.ylabel('Frequency') plt.title('Airline Sentiment Analysis') plt.tight_layout() # Save the plot plt.savefig('sentiment_analysis.png') return 'sentiment_analysis.png' iface = gr.Interface( fn=analyze_sentiment, inputs=gr.inputs.Dataframe(type='csv'), outputs='image' ) iface.launch()