Sheshank2609 commited on
Commit
f95be2b
·
verified ·
1 Parent(s): 23cceea

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +123 -3
README.md CHANGED
@@ -1,3 +1,123 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ # Complaint Classification FastText Model
6
+
7
+ This is a FastText model trained to classify student complaints into different departmental categories such as 'Mess/Food', 'Cleanliness', 'Infrastructure', 'Technical Issues', 'Academics', and 'Ragging'. It's designed to help streamline the process of directing student grievances to the correct department for resolution.
8
+
9
+ ## Model Description
10
+
11
+ This model is a supervised text classifier built using the FastText library. It takes a raw complaint text as input and outputs a predicted category along with a confidence score. The model was trained on a dataset of student complaints, which underwent specific text preprocessing steps including cleaning, slang normalization, and keyword boosting to improve classification accuracy.
12
+
13
+ ## Intended Use
14
+
15
+ This model is intended for use in educational institutions to automatically categorize student complaints, thereby improving the efficiency of complaint resolution systems. It can be integrated into ticketing systems, chatbots, or other platforms where initial complaint routing is required.
16
+
17
+ ## Training Data
18
+
19
+ The model was trained on a custom dataset of student complaints, `ML_Project_Complaint_Dataset_Duration_Imp.csv`. The dataset includes two primary columns: `complaint_text` and `category`.
20
+
21
+ **Preprocessing steps applied to the training data:**
22
+ 1. **Text Cleaning**: Lowercasing, removal of extra whitespace.
23
+ 2. **Slang Normalization**: Replacement of common informal words/slang with their standard equivalents (e.g., 'bakwass' to 'bakwas', 'plz' to 'please').
24
+ 3. **Keyword Boosting**: Addition of relevant keywords to complaints containing specific terms (e.g., adding 'mess food quality eating' to complaints mentioning 'food', 'mess', etc.) to enhance category recognition.
25
+
26
+ The dataset was balanced using random sampling to ensure each category had an equal number of samples before the train-test split.
27
+
28
+ ## Evaluation
29
+
30
+ The model was evaluated on a held-out test set. Key metrics are:
31
+ - **Precision**: 0.948
32
+ - **Recall**: 0.948
33
+
34
+ ## How to Use
35
+
36
+ To use this model for prediction, you need to first download it and then apply the same preprocessing steps that were used during training. Below is a Python example:
37
+
38
+ ```python
39
+ import fasttext
40
+ import re
41
+ from huggingface_hub import hf_hub_download
42
+
43
+ # --- Preprocessing Functions (MUST be the same as training) ---
44
+ def clean_text(text):
45
+ text = str(text).lower()
46
+ text = re.sub(r'\s+', ' ', text).strip()
47
+ return text
48
+
49
+ def normalize_slang(text):
50
+ replacements = {
51
+ "bakwass": "bakwas",
52
+ "boht": "bahut",
53
+ "nhi": "nahi",
54
+ "nai": "nahi",
55
+ "yaarrr": "yaar",
56
+ "yawwrrr": "yaar",
57
+ "pls": "please",
58
+ "plz": "please"
59
+ }
60
+ for k, v in replacements.items():
61
+ text = text.replace(k, v)
62
+ return text
63
+
64
+ def boost_keywords(text):
65
+ if any(word in text for word in ["khana", "khaana", "Jevan", "food", "mess", "roti", "sabzi", "rice", "milk"]):
66
+ text += " mess food quality eating"
67
+ if any(word in text for word in ["ganda","flush","toilet", "washroom", "dirty", "dust", "garbage", "smell"]):
68
+ text += " cleanliness hygiene sanitation"
69
+ # TECH
70
+ if any(word in text for word in ["wifi", "internet", "net", "network", "server", "pcs", "system"]):
71
+ text += " technical network issue"
72
+ # INFRA
73
+ if any(word in text for word in ["ac", "fan", "light", "door", "bench", "lock", "window"]):
74
+ text += " infrastructure maintenance"
75
+ # ACADEMICS
76
+ if any(word in text for word in ["teacher", "lecture", "class", "test", "exam", "assignment"]):
77
+ text += " academics study"
78
+ # RAGGING
79
+ if any(word in text for word in ["ragging", "bully", "harass", "senior"]):
80
+ text += " ragging harassment"
81
+ return text
82
+
83
+ # --- Download and Load Model ---
84
+ # Replace 'Sheshank2609/Complaint_Classifier' with your actual repo_id
85
+ model_path = hf_hub_download(repo_id="Sheshank2609/Complaint_Classifier", filename="complaint_classifier.ftz")
86
+ model = fasttext.load_model(model_path)
87
+
88
+ # --- Prediction Function ---
89
+ def predict_complaint_hf(text):
90
+ processed_text = clean_text(text)
91
+ processed_text = normalize_slang(processed_text)
92
+ processed_text = boost_keywords(processed_text)
93
+
94
+ predictions = model.predict(processed_text, k=1)
95
+ label = predictions[0][0].replace("__label__", "")
96
+ confidence = predictions[1][0] * 100
97
+
98
+ return label, round(confidence, 2)
99
+
100
+ # --- Example Usage ---
101
+ complaint1 = "My room is very dirty, full of dust."
102
+ label1, conf1 = predict_complaint_hf(complaint1)
103
+ print(f"Complaint: \"{complaint1}\"\nDepartment: {label1}\nConfidence: {conf1}%\n")
104
+
105
+ complaint2 = "The mess food is terrible today, no taste."
106
+ label2, conf2 = predict_complaint_hf(complaint2)
107
+ print(f"Complaint: \"{complaint2}\"\nDepartment: {label2}\nConfidence: {conf2}%\n")
108
+
109
+ complaint3 = "The wifi is not working in the hostel common room."
110
+ label3, conf3 = predict_complaint_hf(complaint3)
111
+ print(f"Complaint: \"{complaint3}\"\nDepartment: {label3}\nConfidence: {conf3}%\n")
112
+ ```
113
+
114
+ ## Limitations and Bias
115
+
116
+ * **Training Data Dependence**: The model's performance is highly dependent on the quality and diversity of the training data. It might not perform well on complaints that significantly differ in style, language, or content from the training set.
117
+ * **Slang Coverage**: While slang normalization is applied, new slang or region-specific informalities not present in the replacement dictionary may affect performance.
118
+ * **Category Specificity**: The defined categories might not cover all possible complaint types. Misclassifications can occur for complaints that are ambiguous or fall between defined categories.
119
+ * **Language**: The model is primarily trained for English text, potentially with some Hindi slang normalization. Performance on other languages will be poor.
120
+
121
+ ## Contact
122
+
123
+ For questions or feedback, please open an issue on the Hugging Face model repository or contact [Your Name/Email/Link].