curtpond commited on
Commit
925e416
1 Parent(s): e03a483

Updated app.py and requirements.txt files.

Browse files
Files changed (2) hide show
  1. app.py +27 -0
  2. requirements.txt +1 -0
app.py CHANGED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Imports
2
+ import gradio as gr
3
+ from sklearn.linear_model import LogisticRegression
4
+
5
+ # Load model from pickle file
6
+ model = pickle.load(open('lg_classifier.sav', 'rb'))
7
+
8
+ # Define function to predict
9
+ def predict(text):
10
+ return model.predict([text])[0]
11
+
12
+ # Define interface
13
+ iface = gr.Interface(fn=predict,
14
+ inputs=gr.inputs.Textbox(lines=10, label="Text"),
15
+ outputs="text",
16
+ title="Text Classification",
17
+ description="Classify text as other[0], healthcare[1], or technology[2]",
18
+ examples=[
19
+ 'As a psychologist, I often hear stories about fighting. After all, conflict is a normal part of any relationship and, during heated conversations, feelings of anger and frustration can swell, causing us to snap at our partners. However, when I hear about people who make threats, resort to name-calling, and yell whenever they get riled up, I get concerned. It’s normal to lose one\'s cool occasionally if you’re arguing with your partner about something, but if these verbal slingshots happen regularly, it may be a sign of emotional abuse. Because the signs may be subtle, discerning between a heated argument and verbal abuse can be tricky.',
20
+ 'Google welcomed a decision on Monday by London’s High Court to block an attempt to bring legal action over claims it had collected sensitive data from 4 million iPhone users in England and Wales.',
21
+ 'The U.S. Food and Drug Administration on Monday approved the first drug to treat a rare genetic disorder that causes severe muscle weakness and fatigue, the agency said in a statement.'
22
+ 'The success of Hudson’s Bay Co Executive Chairman Richard Baker’s $1.3 billion bid to take the department store operator private hinges on whether an independent valuator will view the company more as a retailer and less as a real estate owner, corporate governance experts and analysts said.'],
23
+ allow_flagging='never'
24
+ )
25
+
26
+
27
+
requirements.txt CHANGED
@@ -0,0 +1 @@
 
 
1
+ scikit-learn