adithegod commited on
Commit
86f00bc
·
verified ·
1 Parent(s): fd4c846

Create Readme.md

Browse files
Files changed (1) hide show
  1. Readme.md +137 -0
Readme.md ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ language:
4
+ - en
5
+ library_name: sklearn
6
+ pipeline_tag: text-classification
7
+ tags:
8
+ - text-classification
9
+ - tabular-classification
10
+ - interview-questions
11
+ - placements
12
+ - scikit-learn
13
+ datasets:
14
+ - adithegod/askedbefore-cs-interview-questions
15
+ metrics:
16
+ - f1
17
+ model-index:
18
+ - name: prepmap-question-classifier
19
+ results:
20
+ - task:
21
+ type: text-classification
22
+ name: Subject classification (15 classes)
23
+ dataset:
24
+ name: AskedBefore CS Interview Questions
25
+ type: adithegod/askedbefore-cs-interview-questions
26
+ metrics:
27
+ - type: f1
28
+ name: Macro F1 (5-fold CV)
29
+ value: 0.7617
30
+ - task:
31
+ type: text-classification
32
+ name: Difficulty classification (3 classes)
33
+ dataset:
34
+ name: AskedBefore CS Interview Questions
35
+ type: adithegod/askedbefore-cs-interview-questions
36
+ metrics:
37
+ - type: f1
38
+ name: Macro F1 (5-fold CV)
39
+ value: 0.564
40
+ ---
41
+
42
+ # PrepMap Question Classifier
43
+
44
+ Two scikit-learn models that power the **PrepMap** website:
45
+
46
+ 1. **Subject classifier:** reads an interview or placement question and predicts its subject (15 classes, such as DSA, Operating Systems, DBMS & SQL, Quantitative Aptitude or Behavioral / HR).
47
+ 2. **Difficulty classifier:** predicts whether the question is easy, medium or hard.
48
+
49
+ Combined with `company_rules.json`, the predictions tell PrepMap which companies a new question is recommended for (for example, a medium DSA question is recommended for Infosys, Oracle, Google and Amazon).
50
+
51
+ ## Results
52
+
53
+ All scores are macro F1 from stratified 5-fold cross-validation on the 1,770 questions of the [AskedBefore dataset](https://huggingface.co/datasets/adithegod/askedbefore-cs-interview-questions).
54
+
55
+ ### Subject (15 classes)
56
+
57
+ | Model | Macro F1 |
58
+ |---|---:|
59
+ | **Logistic Regression** (used) | **0.762** |
60
+ | Random Forest (baseline) | 0.628 |
61
+ | XGBoost | 0.603 |
62
+
63
+ Random guessing would score about 0.07 with 15 classes. Logistic Regression beats the Random Forest baseline by 13 points, which is typical for short text represented with sparse TF-IDF features.
64
+
65
+ ### Difficulty (3 classes)
66
+
67
+ | Model | Macro F1 |
68
+ |---|---:|
69
+ | **Random Forest** (used) | **0.564** |
70
+ | Logistic Regression | 0.520 |
71
+ | XGBoost | 0.510 |
72
+
73
+ Random guessing would score about 0.33. Difficulty is much harder to predict than subject, because it depends on the concept being tested rather than the words used, so treat difficulty predictions as a rough guide.
74
+
75
+ ## Model details
76
+
77
+ - **Features:** TF-IDF word 1-2 grams (English stop words removed, sublinear TF) combined with TF-IDF character 3-5 grams.
78
+ - **Subject model:** Logistic Regression, C = 10, balanced class weights.
79
+ - **Difficulty model:** Random Forest, 500 trees, balanced class weights.
80
+ - Each model is a single scikit-learn `Pipeline` (features + classifier), so it takes raw question text as input.
81
+ - Built with **scikit-learn 1.6.1**. Use the same version to load the files.
82
+
83
+ ## Files
84
+
85
+ | File | What it is | Size |
86
+ |---|---|---:|
87
+ | `subject_model.joblib` | Subject classifier (TF-IDF + Logistic Regression) | 4.2 MB |
88
+ | `difficulty_model.joblib` | Difficulty classifier (TF-IDF + Random Forest) | 48.5 MB |
89
+ | `subject_label_encoder.joblib` | Maps subject numbers to names | < 1 KB |
90
+ | `difficulty_label_encoder.joblib` | Maps difficulty numbers to names | < 1 KB |
91
+ | `company_rules.json` | Subject weights and difficulty focus for 19 companies | 6 KB |
92
+ | `results.json` | Cross-validation scores for all models | < 1 KB |
93
+
94
+ ## Usage
95
+
96
+ ```python
97
+ # pip install scikit-learn==1.6.1 huggingface_hub joblib
98
+ import json, joblib
99
+ from huggingface_hub import hf_hub_download
100
+
101
+ repo = "adithegod/prepmap-question-classifier"
102
+ load = lambda f: joblib.load(hf_hub_download(repo, f))
103
+
104
+ subject_model = load("subject_model.joblib")
105
+ difficulty_model = load("difficulty_model.joblib")
106
+ le_subject = load("subject_label_encoder.joblib")
107
+ le_difficulty = load("difficulty_label_encoder.joblib")
108
+ rules = json.load(open(hf_hub_download(repo, "company_rules.json")))
109
+
110
+ question = "Explain the difference between a process and a thread."
111
+ subject = le_subject.inverse_transform(subject_model.predict([question]))[0]
112
+ difficulty = le_difficulty.inverse_transform(difficulty_model.predict([question]))[0]
113
+
114
+ relevance = {3: "core", 2: "frequent", 1: "occasional"}
115
+ companies = [(c, relevance[r["weights"][subject]]) for c, r in rules.items()
116
+ if subject in r["weights"] and difficulty in r["difficulty"]]
117
+
118
+ print(subject, difficulty) # e.g. Operating Systems, easy
119
+ print(companies) # e.g. [('TCS', 'occasional'), ('HCLTech', 'frequent'), ...]
120
+ ```
121
+
122
+ **Safety note:** `.joblib` files are Python pickles, which can run code when loaded. Only load these files from this repository.
123
+
124
+ ## Training data
125
+
126
+ [AskedBefore CS Interview Questions](https://huggingface.co/datasets/adithegod/askedbefore-cs-interview-questions): 1,770 original interview and placement questions across 15 subjects, with difficulty labels and company mappings for 19 companies.
127
+
128
+ ## Limitations
129
+
130
+ - **Short, clean, English questions only.** Accuracy on long or messy real interview text will be lower.
131
+ - **Overlapping subjects get confused.** Programming Fundamentals, Operating Systems and DSA share vocabulary, as do Statistics and Machine Learning.
132
+ - **Difficulty is subjective,** and its predictions are only moderately reliable (0.56 macro F1).
133
+ - **Company recommendations are rules, not predictions.** They come from public descriptions of each company's hiring process, not from records of questions the company actually asked.
134
+
135
+ ## License
136
+
137
+ CC BY 4.0.