Gurucharan11204 commited on
Commit
af6755e
·
1 Parent(s): 9546428

Add Gradio app and model files

Browse files
Files changed (3) hide show
  1. app.py +28 -0
  2. model.pkl +3 -0
  3. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ import joblib
4
+
5
+ # Load your trained model from the model file
6
+ model = joblib.load("model.pkl")
7
+
8
+ # Define a function to use with the Gradio interface
9
+ def predict_sentiment(text):
10
+ prediction = model.predict([text])[0]
11
+ probabilities = model.predict_proba([text])[0]
12
+ return {
13
+ "Prediction": prediction,
14
+ "Probabilities": dict(zip(model.classes_, probabilities))
15
+ }
16
+
17
+ # Create a Gradio interface
18
+ interface = gr.Interface(
19
+ fn=predict_sentiment,
20
+ inputs=gr.Textbox(lines=2, placeholder="Enter your text here..."),
21
+ outputs=gr.JSON(label="Prediction and Probabilities"),
22
+ title="Sentiment Analysis App",
23
+ description="This app predicts sentiment responses using a trained logistic regression model."
24
+ )
25
+
26
+ # Launch the interface
27
+ if __name__ == "__main__":
28
+ interface.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c0f66e2084a15e883d8ee26675d93e88f70ba07689ebe512c24ab1e3e151db8
3
+ size 2397780
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ scikit-learn
3
+ joblib