deeksonparlma commited on
Commit
739ab27
·
1 Parent(s): a034e84
Files changed (2) hide show
  1. app.py +17 -4
  2. model.ipynb +4 -2
app.py CHANGED
@@ -23,10 +23,23 @@ tokenizer = AutoTokenizer.from_pretrained("rabiaqayyum/autotrain-mental-health-a
23
  model = pickle.load(open("model.pkl", "rb"))
24
 
25
  def classify_text(inp):
26
- input_ids = tokenizer.encode(inp, return_tensors='pt')
27
- output = model.predict(input_ids)
28
- return output.logits.argmax().item()
29
-
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  iface = gr.Interface(fn=classify_text, inputs="text", outputs="label",
31
  interpretation="default", examples=[
32
  ["I am feeling depressed"],
 
23
  model = pickle.load(open("model.pkl", "rb"))
24
 
25
  def classify_text(inp):
26
+ # input_ids = tokenizer.encode(inp, return_tensors='pt')
27
+ # output = model.predict(input_ids)
28
+ # return output.logits.argmax().item()
29
+ vectorizer = TfidfVectorizer()
30
+ X = vectorizer.fit_transform(inp)
31
+ return model.predict(X)
32
+
33
+
34
+
35
+ # # encode the input text
36
+ # encoded_input = tokenizer(text, return_tensors='pt')
37
+ # # get the prediction
38
+ # output = model(**encoded_input)
39
+ # # get the label
40
+ # label = output[0].argmax().item()
41
+ # # return the label
42
+ # return label
43
  iface = gr.Interface(fn=classify_text, inputs="text", outputs="label",
44
  interpretation="default", examples=[
45
  ["I am feeling depressed"],
model.ipynb CHANGED
@@ -181,7 +181,7 @@
181
  },
182
  {
183
  "cell_type": "code",
184
- "execution_count": 5,
185
  "id": "c5dde0e4",
186
  "metadata": {},
187
  "outputs": [
@@ -189,7 +189,8 @@
189
  "name": "stdout",
190
  "output_type": "stream",
191
  "text": [
192
- "Accuracy: 0.06666666666666667\n"
 
193
  ]
194
  }
195
  ],
@@ -212,6 +213,7 @@
212
  "X = vectorizer.fit_transform(questions)\n",
213
  "y = responses\n",
214
  "\n",
 
215
  "# Step 2: Split data into training and testing sets\n",
216
  "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n",
217
  "\n",
 
181
  },
182
  {
183
  "cell_type": "code",
184
+ "execution_count": 10,
185
  "id": "c5dde0e4",
186
  "metadata": {},
187
  "outputs": [
 
189
  "name": "stdout",
190
  "output_type": "stream",
191
  "text": [
192
+ "(148, 252)\n",
193
+ "Accuracy: 0.0\n"
194
  ]
195
  }
196
  ],
 
213
  "X = vectorizer.fit_transform(questions)\n",
214
  "y = responses\n",
215
  "\n",
216
+ "\n",
217
  "# Step 2: Split data into training and testing sets\n",
218
  "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\n",
219
  "\n",