databoyface commited on
Commit
9858a3e
·
verified ·
1 Parent(s): d9adda1

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -0
README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - databoyface/python-tf-ome-src-v4.1
5
+ language:
6
+ - en
7
+ ---
8
+
9
+ # Orthogonal Model of Emotions
10
+
11
+ A Text Classifier created using Sci-Kit Learn
12
+
13
+ ## Author
14
+
15
+ C.J. Pitchford
16
+
17
+ ## Published
18
+
19
+ 18 June 2025
20
+
21
+ ## Usage
22
+
23
+
24
+ import numpy as np
25
+ import tensorflow as tf
26
+
27
+ import tensorflow.keras.preprocessing.text as text
28
+
29
+ import pickle
30
+ from tensorflow.keras.preprocessing.sequence import pad_sequences
31
+
32
+ # 1. Load pre-trained model
33
+ model = tf.keras.models.load_model('OME4tf/ome-4a-model.h5')
34
+
35
+ # 2. Load tokenizer and label encoder
36
+ with open('OME4tf/ome-4a-tokenizer.pkl', 'rb') as f:
37
+ tokenizer = pickle.load(f)
38
+ with open('OME4tf/ome-4a-label_encoder.pkl', 'rb') as f:
39
+ label_encoder = pickle.load(f)
40
+
41
+ # 3. Test model with prediction on text "I failed to hide my distress."
42
+ text = "I failed to hide my distress."
43
+ text_seq = tokenizer.texts_to_sequences([text])
44
+ max_len = 1000
45
+ text_seq = pad_sequences(text_seq, maxlen=max_len, padding='post')
46
+ pred_probs = model.predict(text_seq)
47
+ pred_label = np.argmax(pred_probs, axis=1)
48
+ print(f"Statement: {text}\nPrediction: {label_encoder.classes_[pred_label][0]}")
49
+