b22ee075 commited on
Commit
1ef0275
·
verified ·
1 Parent(s): af74c09

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -40
app.py DELETED
@@ -1,40 +0,0 @@
1
- pip install seaborn
2
- import gradio as gr
3
- import matplotlib.pyplot as plt
4
- import seaborn as sns
5
-
6
- # Function to classify sentiment
7
- def classify_sentiment(text):
8
- # Preprocess the text
9
- processed_text = wp(text)
10
- # Vectorize the text
11
- vectorized_text = vectorization.transform([processed_text])
12
- # Predict sentiment using logistic regression model
13
- prediction = logistic_model.predict(vectorized_text)[0]
14
- # Output sentiment label
15
- sentiment_label = output_label(prediction)
16
- # Get probabilities for each sentiment class
17
- probabilities = logistic_model.predict_proba(vectorized_text)[0]
18
-
19
- # Plot probabilities
20
- plt.figure(figsize=(8, 6))
21
- sns.barplot(x=["Negative", "Neutral", "Positive"], y=probabilities)
22
- plt.xlabel("Sentiment")
23
- plt.ylabel("Probability")
24
- plt.title("Sentiment Probability Distribution")
25
- plt.ylim([0, 1])
26
- plt.tight_layout()
27
- plt.savefig("sentiment_probabilities.png")
28
-
29
- return sentiment_label, "sentiment_probabilities.png"
30
-
31
- # Input and output components for the interface
32
- inputs = gr.Textbox(lines=10, label="Enter the text you want to analyze:")
33
- outputs = [
34
- gr.Textbox(label="Sentiment Prediction"),
35
- gr.Image(label="Sentiment Probability Distribution")
36
- ]
37
-
38
- # Create the Gradio interface
39
- interface = gr.Interface(fn=classify_sentiment, inputs=inputs, outputs=outputs, title="Sentiment Classification", description="Enter a piece of text and analyze its sentiment.")
40
- interface.launch()