Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +21 -0
- course_feedback_nlp/1strun/plots/confusion_matrix.png +3 -0
- course_feedback_nlp/1strun/plots/review_length_analysis.png +3 -0
- course_feedback_nlp/1strun/plots/training_history.png +0 -0
- course_feedback_nlp/1strun/sentiment_model/config.json +41 -0
- course_feedback_nlp/1strun/sentiment_model/model.safetensors +3 -0
- course_feedback_nlp/1strun/sentiment_model/results.pt +3 -0
- course_feedback_nlp/1strun/sentiment_model/tokenizer.json +0 -0
- course_feedback_nlp/1strun/sentiment_model/tokenizer_config.json +14 -0
- course_feedback_nlp/1strun/sentiment_model/training_info.pt +3 -0
- course_feedback_nlp/2ndrun/plots/confusion_matrix.png +3 -0
- course_feedback_nlp/2ndrun/plots/training_history.png +0 -0
- course_feedback_nlp/2ndrun/sentiment_model/config.json +41 -0
- course_feedback_nlp/2ndrun/sentiment_model/model.safetensors +3 -0
- course_feedback_nlp/2ndrun/sentiment_model/results.pt +3 -0
- course_feedback_nlp/2ndrun/sentiment_model/tokenizer.json +0 -0
- course_feedback_nlp/2ndrun/sentiment_model/tokenizer_config.json +14 -0
- course_feedback_nlp/2ndrun/sentiment_model/training_info.pt +3 -0
- course_feedback_nlp/Coursera_reviews.csv +3 -0
- course_feedback_nlp/distilbert-base-uncased/LICENSE +201 -0
- course_feedback_nlp/distilbert-base-uncased/README.md +218 -0
- course_feedback_nlp/distilbert-base-uncased/config.json +22 -0
- course_feedback_nlp/distilbert-base-uncased/tokenizer.json +0 -0
- course_feedback_nlp/distilbert-base-uncased/tokenizer_config.json +1 -0
- course_feedback_nlp/distilbert-base-uncased/vocab.txt +0 -0
- course_feedback_nlp/plots/confidence_distribution.png +0 -0
- course_feedback_nlp/plots/confusion_matrix_3class.png +0 -0
- course_feedback_nlp/plots/error_analysis.png +0 -0
- course_feedback_nlp/plots/per_class_metrics_3class.png +0 -0
- course_feedback_nlp/plots/per_class_recall.png +0 -0
- course_feedback_nlp/plots/training_history.png +0 -0
- course_feedback_nlp/sentiment_model/config.json +40 -0
- course_feedback_nlp/sentiment_model/tokenizer.json +0 -0
- course_feedback_nlp/sentiment_model/tokenizer_config.json +14 -0
- course_feedback_nlp/teacher_sentiment_model/config.json +35 -0
- course_feedback_nlp/teacher_sentiment_model/results.json +15 -0
- course_feedback_nlp/teacher_sentiment_model/tokenizer.json +0 -0
- course_feedback_nlp/teacher_sentiment_model/tokenizer_config.json +14 -0
- course_feedback_nlp/teacher_sentiment_model/training_config.json +16 -0
- dropout_binaryclass/correlation_matrix.png +3 -0
- dropout_binaryclass/correlation_with_target.png +3 -0
- dropout_binaryclass/realistic/comparison_xgboost/model_config.json +117 -0
- dropout_binaryclass/realistic/comparison_xgboost/train.py +352 -0
- dropout_binaryclass/realistic/model_config.json +117 -0
- dropout_binaryclass/realistic/train.py +227 -0
- dropout_binaryclass/student_dropout_model.pkl +3 -0
- grade_multiclass/01_feature_distributions.png +3 -0
- grade_multiclass/07_pairplot.png +3 -0
- grade_multiclass/08_confusion_matrix_random_forest.png +3 -0
- grade_multiclass/confusion_matrix_tuned_random_forest.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,24 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
course_feedback_nlp/2ndrun/plots/confusion_matrix.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
course_feedback_nlp/1strun/plots/confusion_matrix.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
course_feedback_nlp/1strun/plots/review_length_analysis.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
lr_attendance/train_data_scaled.csv filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
course_feedback_nlp/Coursera_reviews.csv filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
dropout_binaryclass/correlation_matrix.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
dropout_binaryclass/correlation_with_target.png filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
grade_multiclass/01_feature_distributions.png filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
grade_multiclass/08_confusion_matrix_random_forest.png filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
grade_multiclass/07_pairplot.png filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
grade_multiclass/confusion_matrix_tuned_random_forest.png filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
grade_multiclass/feature_distributions.png filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
lr_attendance/attendance_with_features.csv filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
lr_attendance/attendance_features_complete.csv filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
lr_attendance/test_data_scaled.csv filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
lr_attendance/plots_first_run/best_model_analysis.png filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
lr_attendance/plots_first_run/correlation_heatmap.png filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
lr_attendance/plots_first_run/eda_plots.png filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
lr_attendance/plots_first_run/final_model_analysis.png filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
lr_attendance/plots_first_run/school_variation_analysis.png filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
lr_attendance/plots_first_run/residual_analysis.png filter=lfs diff=lfs merge=lfs -text
|
course_feedback_nlp/1strun/plots/confusion_matrix.png
ADDED
|
Git LFS Details
|
course_feedback_nlp/1strun/plots/review_length_analysis.png
ADDED
|
Git LFS Details
|
course_feedback_nlp/1strun/plots/training_history.png
ADDED
|
course_feedback_nlp/1strun/sentiment_model/config.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"dim": 768,
|
| 9 |
+
"dropout": 0.1,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"eos_token_id": null,
|
| 12 |
+
"hidden_dim": 3072,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "LABEL_0",
|
| 15 |
+
"1": "LABEL_1",
|
| 16 |
+
"2": "LABEL_2",
|
| 17 |
+
"3": "LABEL_3",
|
| 18 |
+
"4": "LABEL_4"
|
| 19 |
+
},
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"label2id": {
|
| 22 |
+
"LABEL_0": 0,
|
| 23 |
+
"LABEL_1": 1,
|
| 24 |
+
"LABEL_2": 2,
|
| 25 |
+
"LABEL_3": 3,
|
| 26 |
+
"LABEL_4": 4
|
| 27 |
+
},
|
| 28 |
+
"max_position_embeddings": 512,
|
| 29 |
+
"model_type": "distilbert",
|
| 30 |
+
"n_heads": 12,
|
| 31 |
+
"n_layers": 6,
|
| 32 |
+
"pad_token_id": 0,
|
| 33 |
+
"problem_type": "single_label_classification",
|
| 34 |
+
"qa_dropout": 0.1,
|
| 35 |
+
"seq_classif_dropout": 0.2,
|
| 36 |
+
"sinusoidal_pos_embds": false,
|
| 37 |
+
"tie_weights_": true,
|
| 38 |
+
"tie_word_embeddings": true,
|
| 39 |
+
"transformers_version": "5.0.0",
|
| 40 |
+
"vocab_size": 30522
|
| 41 |
+
}
|
course_feedback_nlp/1strun/sentiment_model/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1dec82d9db7dba1620edf63c7b411c591cd9af6c3855d2a77694d9236e5c5ccc
|
| 3 |
+
size 267841796
|
course_feedback_nlp/1strun/sentiment_model/results.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:48923e24fc083d6f080ce366f414ee275b815f944b63d15f5cad37c7bc1c2625
|
| 3 |
+
size 2221
|
course_feedback_nlp/1strun/sentiment_model/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
course_feedback_nlp/1strun/sentiment_model/tokenizer_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": true,
|
| 6 |
+
"mask_token": "[MASK]",
|
| 7 |
+
"model_max_length": 512,
|
| 8 |
+
"pad_token": "[PAD]",
|
| 9 |
+
"sep_token": "[SEP]",
|
| 10 |
+
"strip_accents": null,
|
| 11 |
+
"tokenize_chinese_chars": true,
|
| 12 |
+
"tokenizer_class": "BertTokenizer",
|
| 13 |
+
"unk_token": "[UNK]"
|
| 14 |
+
}
|
course_feedback_nlp/1strun/sentiment_model/training_info.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6ee82096ea30700d1e21e9dbc465688486c7b00457ce73e21979f2899ed51ee3
|
| 3 |
+
size 2065
|
course_feedback_nlp/2ndrun/plots/confusion_matrix.png
ADDED
|
Git LFS Details
|
course_feedback_nlp/2ndrun/plots/training_history.png
ADDED
|
course_feedback_nlp/2ndrun/sentiment_model/config.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"dim": 768,
|
| 9 |
+
"dropout": 0.1,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"eos_token_id": null,
|
| 12 |
+
"hidden_dim": 3072,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "LABEL_0",
|
| 15 |
+
"1": "LABEL_1",
|
| 16 |
+
"2": "LABEL_2",
|
| 17 |
+
"3": "LABEL_3",
|
| 18 |
+
"4": "LABEL_4"
|
| 19 |
+
},
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"label2id": {
|
| 22 |
+
"LABEL_0": 0,
|
| 23 |
+
"LABEL_1": 1,
|
| 24 |
+
"LABEL_2": 2,
|
| 25 |
+
"LABEL_3": 3,
|
| 26 |
+
"LABEL_4": 4
|
| 27 |
+
},
|
| 28 |
+
"max_position_embeddings": 512,
|
| 29 |
+
"model_type": "distilbert",
|
| 30 |
+
"n_heads": 12,
|
| 31 |
+
"n_layers": 6,
|
| 32 |
+
"pad_token_id": 0,
|
| 33 |
+
"problem_type": "single_label_classification",
|
| 34 |
+
"qa_dropout": 0.1,
|
| 35 |
+
"seq_classif_dropout": 0.2,
|
| 36 |
+
"sinusoidal_pos_embds": false,
|
| 37 |
+
"tie_weights_": true,
|
| 38 |
+
"tie_word_embeddings": true,
|
| 39 |
+
"transformers_version": "5.0.0",
|
| 40 |
+
"vocab_size": 30522
|
| 41 |
+
}
|
course_feedback_nlp/2ndrun/sentiment_model/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ec3b327b5e5a9e4dfdd1115d94bca8022cb0fa2a9fb2b1d43ed273b8fdb6e7b
|
| 3 |
+
size 267841796
|
course_feedback_nlp/2ndrun/sentiment_model/results.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0b7b900d295b13675f7b20761cf73e286044843a5e7b2c701dea697eae49b4f2
|
| 3 |
+
size 2221
|
course_feedback_nlp/2ndrun/sentiment_model/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
course_feedback_nlp/2ndrun/sentiment_model/tokenizer_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": true,
|
| 6 |
+
"mask_token": "[MASK]",
|
| 7 |
+
"model_max_length": 512,
|
| 8 |
+
"pad_token": "[PAD]",
|
| 9 |
+
"sep_token": "[SEP]",
|
| 10 |
+
"strip_accents": null,
|
| 11 |
+
"tokenize_chinese_chars": true,
|
| 12 |
+
"tokenizer_class": "BertTokenizer",
|
| 13 |
+
"unk_token": "[UNK]"
|
| 14 |
+
}
|
course_feedback_nlp/2ndrun/sentiment_model/training_info.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5c172250a7bf6d9cd7656ee0006ac903c62b15260d5f417ce83e47486e450eaf
|
| 3 |
+
size 2065
|
course_feedback_nlp/Coursera_reviews.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a8db44269ab9b75af45ce55a2c40f14deed143f14792ca9d0c10274741d9eabb
|
| 3 |
+
size 272095806
|
course_feedback_nlp/distilbert-base-uncased/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
course_feedback_nlp/distilbert-base-uncased/README.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
tags:
|
| 4 |
+
- exbert
|
| 5 |
+
license: apache-2.0
|
| 6 |
+
datasets:
|
| 7 |
+
- bookcorpus
|
| 8 |
+
- wikipedia
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# DistilBERT base model (uncased)
|
| 12 |
+
|
| 13 |
+
This model is a distilled version of the [BERT base model](https://huggingface.co/bert-base-uncased). It was
|
| 14 |
+
introduced in [this paper](https://arxiv.org/abs/1910.01108). The code for the distillation process can be found
|
| 15 |
+
[here](https://github.com/huggingface/transformers/tree/main/examples/research_projects/distillation). This model is uncased: it does
|
| 16 |
+
not make a difference between english and English.
|
| 17 |
+
|
| 18 |
+
## Model description
|
| 19 |
+
|
| 20 |
+
DistilBERT is a transformers model, smaller and faster than BERT, which was pretrained on the same corpus in a
|
| 21 |
+
self-supervised fashion, using the BERT base model as a teacher. This means it was pretrained on the raw texts only,
|
| 22 |
+
with no humans labelling them in any way (which is why it can use lots of publicly available data) with an automatic
|
| 23 |
+
process to generate inputs and labels from those texts using the BERT base model. More precisely, it was pretrained
|
| 24 |
+
with three objectives:
|
| 25 |
+
|
| 26 |
+
- Distillation loss: the model was trained to return the same probabilities as the BERT base model.
|
| 27 |
+
- Masked language modeling (MLM): this is part of the original training loss of the BERT base model. When taking a
|
| 28 |
+
sentence, the model randomly masks 15% of the words in the input then run the entire masked sentence through the
|
| 29 |
+
model and has to predict the masked words. This is different from traditional recurrent neural networks (RNNs) that
|
| 30 |
+
usually see the words one after the other, or from autoregressive models like GPT which internally mask the future
|
| 31 |
+
tokens. It allows the model to learn a bidirectional representation of the sentence.
|
| 32 |
+
- Cosine embedding loss: the model was also trained to generate hidden states as close as possible as the BERT base
|
| 33 |
+
model.
|
| 34 |
+
|
| 35 |
+
This way, the model learns the same inner representation of the English language than its teacher model, while being
|
| 36 |
+
faster for inference or downstream tasks.
|
| 37 |
+
|
| 38 |
+
## Intended uses & limitations
|
| 39 |
+
|
| 40 |
+
You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended to
|
| 41 |
+
be fine-tuned on a downstream task. See the [model hub](https://huggingface.co/models?filter=distilbert) to look for
|
| 42 |
+
fine-tuned versions on a task that interests you.
|
| 43 |
+
|
| 44 |
+
Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)
|
| 45 |
+
to make decisions, such as sequence classification, token classification or question answering. For tasks such as text
|
| 46 |
+
generation you should look at model like GPT2.
|
| 47 |
+
|
| 48 |
+
### How to use
|
| 49 |
+
|
| 50 |
+
You can use this model directly with a pipeline for masked language modeling:
|
| 51 |
+
|
| 52 |
+
```python
|
| 53 |
+
>>> from transformers import pipeline
|
| 54 |
+
>>> unmasker = pipeline('fill-mask', model='distilbert-base-uncased')
|
| 55 |
+
>>> unmasker("Hello I'm a [MASK] model.")
|
| 56 |
+
|
| 57 |
+
[{'sequence': "[CLS] hello i'm a role model. [SEP]",
|
| 58 |
+
'score': 0.05292855575680733,
|
| 59 |
+
'token': 2535,
|
| 60 |
+
'token_str': 'role'},
|
| 61 |
+
{'sequence': "[CLS] hello i'm a fashion model. [SEP]",
|
| 62 |
+
'score': 0.03968575969338417,
|
| 63 |
+
'token': 4827,
|
| 64 |
+
'token_str': 'fashion'},
|
| 65 |
+
{'sequence': "[CLS] hello i'm a business model. [SEP]",
|
| 66 |
+
'score': 0.034743521362543106,
|
| 67 |
+
'token': 2449,
|
| 68 |
+
'token_str': 'business'},
|
| 69 |
+
{'sequence': "[CLS] hello i'm a model model. [SEP]",
|
| 70 |
+
'score': 0.03462274372577667,
|
| 71 |
+
'token': 2944,
|
| 72 |
+
'token_str': 'model'},
|
| 73 |
+
{'sequence': "[CLS] hello i'm a modeling model. [SEP]",
|
| 74 |
+
'score': 0.018145186826586723,
|
| 75 |
+
'token': 11643,
|
| 76 |
+
'token_str': 'modeling'}]
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
Here is how to use this model to get the features of a given text in PyTorch:
|
| 80 |
+
|
| 81 |
+
```python
|
| 82 |
+
from transformers import DistilBertTokenizer, DistilBertModel
|
| 83 |
+
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased')
|
| 84 |
+
model = DistilBertModel.from_pretrained("distilbert-base-uncased")
|
| 85 |
+
text = "Replace me by any text you'd like."
|
| 86 |
+
encoded_input = tokenizer(text, return_tensors='pt')
|
| 87 |
+
output = model(**encoded_input)
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
and in TensorFlow:
|
| 91 |
+
|
| 92 |
+
```python
|
| 93 |
+
from transformers import DistilBertTokenizer, TFDistilBertModel
|
| 94 |
+
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased')
|
| 95 |
+
model = TFDistilBertModel.from_pretrained("distilbert-base-uncased")
|
| 96 |
+
text = "Replace me by any text you'd like."
|
| 97 |
+
encoded_input = tokenizer(text, return_tensors='tf')
|
| 98 |
+
output = model(encoded_input)
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
### Limitations and bias
|
| 102 |
+
|
| 103 |
+
Even if the training data used for this model could be characterized as fairly neutral, this model can have biased
|
| 104 |
+
predictions. It also inherits some of
|
| 105 |
+
[the bias of its teacher model](https://huggingface.co/bert-base-uncased#limitations-and-bias).
|
| 106 |
+
|
| 107 |
+
```python
|
| 108 |
+
>>> from transformers import pipeline
|
| 109 |
+
>>> unmasker = pipeline('fill-mask', model='distilbert-base-uncased')
|
| 110 |
+
>>> unmasker("The White man worked as a [MASK].")
|
| 111 |
+
|
| 112 |
+
[{'sequence': '[CLS] the white man worked as a blacksmith. [SEP]',
|
| 113 |
+
'score': 0.1235365942120552,
|
| 114 |
+
'token': 20987,
|
| 115 |
+
'token_str': 'blacksmith'},
|
| 116 |
+
{'sequence': '[CLS] the white man worked as a carpenter. [SEP]',
|
| 117 |
+
'score': 0.10142576694488525,
|
| 118 |
+
'token': 10533,
|
| 119 |
+
'token_str': 'carpenter'},
|
| 120 |
+
{'sequence': '[CLS] the white man worked as a farmer. [SEP]',
|
| 121 |
+
'score': 0.04985016956925392,
|
| 122 |
+
'token': 7500,
|
| 123 |
+
'token_str': 'farmer'},
|
| 124 |
+
{'sequence': '[CLS] the white man worked as a miner. [SEP]',
|
| 125 |
+
'score': 0.03932540491223335,
|
| 126 |
+
'token': 18594,
|
| 127 |
+
'token_str': 'miner'},
|
| 128 |
+
{'sequence': '[CLS] the white man worked as a butcher. [SEP]',
|
| 129 |
+
'score': 0.03351764753460884,
|
| 130 |
+
'token': 14998,
|
| 131 |
+
'token_str': 'butcher'}]
|
| 132 |
+
|
| 133 |
+
>>> unmasker("The Black woman worked as a [MASK].")
|
| 134 |
+
|
| 135 |
+
[{'sequence': '[CLS] the black woman worked as a waitress. [SEP]',
|
| 136 |
+
'score': 0.13283951580524445,
|
| 137 |
+
'token': 13877,
|
| 138 |
+
'token_str': 'waitress'},
|
| 139 |
+
{'sequence': '[CLS] the black woman worked as a nurse. [SEP]',
|
| 140 |
+
'score': 0.12586183845996857,
|
| 141 |
+
'token': 6821,
|
| 142 |
+
'token_str': 'nurse'},
|
| 143 |
+
{'sequence': '[CLS] the black woman worked as a maid. [SEP]',
|
| 144 |
+
'score': 0.11708822101354599,
|
| 145 |
+
'token': 10850,
|
| 146 |
+
'token_str': 'maid'},
|
| 147 |
+
{'sequence': '[CLS] the black woman worked as a prostitute. [SEP]',
|
| 148 |
+
'score': 0.11499975621700287,
|
| 149 |
+
'token': 19215,
|
| 150 |
+
'token_str': 'prostitute'},
|
| 151 |
+
{'sequence': '[CLS] the black woman worked as a housekeeper. [SEP]',
|
| 152 |
+
'score': 0.04722772538661957,
|
| 153 |
+
'token': 22583,
|
| 154 |
+
'token_str': 'housekeeper'}]
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
This bias will also affect all fine-tuned versions of this model.
|
| 158 |
+
|
| 159 |
+
## Training data
|
| 160 |
+
|
| 161 |
+
DistilBERT pretrained on the same data as BERT, which is [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset
|
| 162 |
+
consisting of 11,038 unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia)
|
| 163 |
+
(excluding lists, tables and headers).
|
| 164 |
+
|
| 165 |
+
## Training procedure
|
| 166 |
+
|
| 167 |
+
### Preprocessing
|
| 168 |
+
|
| 169 |
+
The texts are lowercased and tokenized using WordPiece and a vocabulary size of 30,000. The inputs of the model are
|
| 170 |
+
then of the form:
|
| 171 |
+
|
| 172 |
+
```
|
| 173 |
+
[CLS] Sentence A [SEP] Sentence B [SEP]
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
|
| 177 |
+
the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
|
| 178 |
+
consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
|
| 179 |
+
"sentences" has a combined length of less than 512 tokens.
|
| 180 |
+
|
| 181 |
+
The details of the masking procedure for each sentence are the following:
|
| 182 |
+
- 15% of the tokens are masked.
|
| 183 |
+
- In 80% of the cases, the masked tokens are replaced by `[MASK]`.
|
| 184 |
+
- In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
|
| 185 |
+
- In the 10% remaining cases, the masked tokens are left as is.
|
| 186 |
+
|
| 187 |
+
### Pretraining
|
| 188 |
+
|
| 189 |
+
The model was trained on 8 16 GB V100 for 90 hours. See the
|
| 190 |
+
[training code](https://github.com/huggingface/transformers/tree/main/examples/research_projects/distillation) for all hyperparameters
|
| 191 |
+
details.
|
| 192 |
+
|
| 193 |
+
## Evaluation results
|
| 194 |
+
|
| 195 |
+
When fine-tuned on downstream tasks, this model achieves the following results:
|
| 196 |
+
|
| 197 |
+
Glue test results:
|
| 198 |
+
|
| 199 |
+
| Task | MNLI | QQP | QNLI | SST-2 | CoLA | STS-B | MRPC | RTE |
|
| 200 |
+
|:----:|:----:|:----:|:----:|:-----:|:----:|:-----:|:----:|:----:|
|
| 201 |
+
| | 82.2 | 88.5 | 89.2 | 91.3 | 51.3 | 85.8 | 87.5 | 59.9 |
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
### BibTeX entry and citation info
|
| 205 |
+
|
| 206 |
+
```bibtex
|
| 207 |
+
@article{Sanh2019DistilBERTAD,
|
| 208 |
+
title={DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter},
|
| 209 |
+
author={Victor Sanh and Lysandre Debut and Julien Chaumond and Thomas Wolf},
|
| 210 |
+
journal={ArXiv},
|
| 211 |
+
year={2019},
|
| 212 |
+
volume={abs/1910.01108}
|
| 213 |
+
}
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
<a href="https://huggingface.co/exbert/?model=distilbert-base-uncased">
|
| 217 |
+
<img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png">
|
| 218 |
+
</a>
|
course_feedback_nlp/distilbert-base-uncased/config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForMaskedLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"dim": 768,
|
| 8 |
+
"dropout": 0.1,
|
| 9 |
+
"hidden_dim": 3072,
|
| 10 |
+
"initializer_range": 0.02,
|
| 11 |
+
"max_position_embeddings": 512,
|
| 12 |
+
"model_type": "distilbert",
|
| 13 |
+
"n_heads": 12,
|
| 14 |
+
"n_layers": 6,
|
| 15 |
+
"pad_token_id": 0,
|
| 16 |
+
"qa_dropout": 0.1,
|
| 17 |
+
"seq_classif_dropout": 0.2,
|
| 18 |
+
"sinusoidal_pos_embds": false,
|
| 19 |
+
"tie_weights_": true,
|
| 20 |
+
"transformers_version": "4.10.0.dev0",
|
| 21 |
+
"vocab_size": 30522
|
| 22 |
+
}
|
course_feedback_nlp/distilbert-base-uncased/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
course_feedback_nlp/distilbert-base-uncased/tokenizer_config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"do_lower_case": true, "model_max_length": 512}
|
course_feedback_nlp/distilbert-base-uncased/vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
course_feedback_nlp/plots/confidence_distribution.png
ADDED
|
course_feedback_nlp/plots/confusion_matrix_3class.png
ADDED
|
course_feedback_nlp/plots/error_analysis.png
ADDED
|
course_feedback_nlp/plots/per_class_metrics_3class.png
ADDED
|
course_feedback_nlp/plots/per_class_recall.png
ADDED
|
course_feedback_nlp/plots/training_history.png
ADDED
|
course_feedback_nlp/sentiment_model/config.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"dim": 768,
|
| 9 |
+
"dropout": 0.1,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"eos_token_id": null,
|
| 12 |
+
"hidden_dim": 3072,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "LABEL_0",
|
| 15 |
+
"1": "LABEL_1",
|
| 16 |
+
"2": "LABEL_2",
|
| 17 |
+
"3": "LABEL_3",
|
| 18 |
+
"4": "LABEL_4"
|
| 19 |
+
},
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"label2id": {
|
| 22 |
+
"LABEL_0": 0,
|
| 23 |
+
"LABEL_1": 1,
|
| 24 |
+
"LABEL_2": 2,
|
| 25 |
+
"LABEL_3": 3,
|
| 26 |
+
"LABEL_4": 4
|
| 27 |
+
},
|
| 28 |
+
"max_position_embeddings": 512,
|
| 29 |
+
"model_type": "distilbert",
|
| 30 |
+
"n_heads": 12,
|
| 31 |
+
"n_layers": 6,
|
| 32 |
+
"pad_token_id": 0,
|
| 33 |
+
"qa_dropout": 0.1,
|
| 34 |
+
"seq_classif_dropout": 0.2,
|
| 35 |
+
"sinusoidal_pos_embds": false,
|
| 36 |
+
"tie_weights_": true,
|
| 37 |
+
"tie_word_embeddings": true,
|
| 38 |
+
"transformers_version": "5.0.0",
|
| 39 |
+
"vocab_size": 30522
|
| 40 |
+
}
|
course_feedback_nlp/sentiment_model/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
course_feedback_nlp/sentiment_model/tokenizer_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": true,
|
| 6 |
+
"mask_token": "[MASK]",
|
| 7 |
+
"model_max_length": 512,
|
| 8 |
+
"pad_token": "[PAD]",
|
| 9 |
+
"sep_token": "[SEP]",
|
| 10 |
+
"strip_accents": null,
|
| 11 |
+
"tokenize_chinese_chars": true,
|
| 12 |
+
"tokenizer_class": "BertTokenizer",
|
| 13 |
+
"unk_token": "[UNK]"
|
| 14 |
+
}
|
course_feedback_nlp/teacher_sentiment_model/config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForMaskedLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"dim": 768,
|
| 9 |
+
"dropout": 0.1,
|
| 10 |
+
"eos_token_id": null,
|
| 11 |
+
"hidden_dim": 3072,
|
| 12 |
+
"id2label": {
|
| 13 |
+
"0": "Negative",
|
| 14 |
+
"1": "Neutral",
|
| 15 |
+
"2": "Positive"
|
| 16 |
+
},
|
| 17 |
+
"initializer_range": 0.02,
|
| 18 |
+
"label2id": {
|
| 19 |
+
"Negative": 0,
|
| 20 |
+
"Neutral": 1,
|
| 21 |
+
"Positive": 2
|
| 22 |
+
},
|
| 23 |
+
"max_position_embeddings": 512,
|
| 24 |
+
"model_type": "distilbert",
|
| 25 |
+
"n_heads": 12,
|
| 26 |
+
"n_layers": 6,
|
| 27 |
+
"pad_token_id": 0,
|
| 28 |
+
"qa_dropout": 0.1,
|
| 29 |
+
"seq_classif_dropout": 0.2,
|
| 30 |
+
"sinusoidal_pos_embds": false,
|
| 31 |
+
"tie_weights_": true,
|
| 32 |
+
"tie_word_embeddings": true,
|
| 33 |
+
"transformers_version": "5.0.0",
|
| 34 |
+
"vocab_size": 30522
|
| 35 |
+
}
|
course_feedback_nlp/teacher_sentiment_model/results.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"test_accuracy": 96.15760092399076,
|
| 3 |
+
"negative_recall": 94.3649373881932,
|
| 4 |
+
"negative_precision": 83.0926752428459,
|
| 5 |
+
"negative_f1": 88.37079435990506,
|
| 6 |
+
"neutral_recall": 89.8115551874094,
|
| 7 |
+
"positive_recall": 96.42464286494796,
|
| 8 |
+
"missed_struggling_students": 189,
|
| 9 |
+
"total_negative_cases": 3354,
|
| 10 |
+
"missed_percentage": 5.635062611806798,
|
| 11 |
+
"low_confidence_predictions": 14728,
|
| 12 |
+
"low_confidence_percentage": 10.12539874601254,
|
| 13 |
+
"macro_f1": 83.2724728076938,
|
| 14 |
+
"weighted_f1": 96.65053538273234
|
| 15 |
+
}
|
course_feedback_nlp/teacher_sentiment_model/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
course_feedback_nlp/teacher_sentiment_model/tokenizer_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": true,
|
| 6 |
+
"mask_token": "[MASK]",
|
| 7 |
+
"model_max_length": 512,
|
| 8 |
+
"pad_token": "[PAD]",
|
| 9 |
+
"sep_token": "[SEP]",
|
| 10 |
+
"strip_accents": null,
|
| 11 |
+
"tokenize_chinese_chars": true,
|
| 12 |
+
"tokenizer_class": "BertTokenizer",
|
| 13 |
+
"unk_token": "[UNK]"
|
| 14 |
+
}
|
course_feedback_nlp/teacher_sentiment_model/training_config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"num_classes": 3,
|
| 3 |
+
"class_names": [
|
| 4 |
+
"Negative",
|
| 5 |
+
"Neutral",
|
| 6 |
+
"Positive"
|
| 7 |
+
],
|
| 8 |
+
"class_mapping": {
|
| 9 |
+
"0": 0,
|
| 10 |
+
"1": 0,
|
| 11 |
+
"2": 1,
|
| 12 |
+
"3": 2,
|
| 13 |
+
"4": 2
|
| 14 |
+
},
|
| 15 |
+
"max_length": 96
|
| 16 |
+
}
|
dropout_binaryclass/correlation_matrix.png
ADDED
|
Git LFS Details
|
dropout_binaryclass/correlation_with_target.png
ADDED
|
Git LFS Details
|
dropout_binaryclass/realistic/comparison_xgboost/model_config.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_name": "Student Dropout Predictor",
|
| 3 |
+
"model_type": "XGBoost (Tuned)",
|
| 4 |
+
"features": [
|
| 5 |
+
"Curricular units 2nd sem (approved)",
|
| 6 |
+
"Curricular units 2nd sem (evaluations)",
|
| 7 |
+
"Curricular units 2nd sem (without evaluations)",
|
| 8 |
+
"Tuition fees up to date",
|
| 9 |
+
"Scholarship holder",
|
| 10 |
+
"Debtor",
|
| 11 |
+
"Gender",
|
| 12 |
+
"Age at enrollment",
|
| 13 |
+
"Daytime/evening attendance",
|
| 14 |
+
"Displaced"
|
| 15 |
+
],
|
| 16 |
+
"num_features": 10,
|
| 17 |
+
"performance": {
|
| 18 |
+
"roc_auc": 0.9434,
|
| 19 |
+
"roc_auc_std": 0.0045,
|
| 20 |
+
"accuracy": 0.892,
|
| 21 |
+
"accuracy_std": 0.0069
|
| 22 |
+
},
|
| 23 |
+
"feature_importance": [
|
| 24 |
+
{
|
| 25 |
+
"feature": "Curricular units 2nd sem (approved)",
|
| 26 |
+
"importance": 0.4266107976436615
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"feature": "Tuition fees up to date",
|
| 30 |
+
"importance": 0.2472454458475113
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"feature": "Scholarship holder",
|
| 34 |
+
"importance": 0.07887265831232071
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"feature": "Debtor",
|
| 38 |
+
"importance": 0.06558725982904434
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"feature": "Curricular units 2nd sem (evaluations)",
|
| 42 |
+
"importance": 0.05764281377196312
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"feature": "Gender",
|
| 46 |
+
"importance": 0.032258644700050354
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"feature": "Age at enrollment",
|
| 50 |
+
"importance": 0.03202906996011734
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"feature": "Curricular units 2nd sem (without evaluations)",
|
| 54 |
+
"importance": 0.025066660717129707
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"feature": "Displaced",
|
| 58 |
+
"importance": 0.023970549926161766
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"feature": "Daytime/evening attendance",
|
| 62 |
+
"importance": 0.010716132819652557
|
| 63 |
+
}
|
| 64 |
+
],
|
| 65 |
+
"input_schema": {
|
| 66 |
+
"units_approved": {
|
| 67 |
+
"description": "Number of curricular units passed this semester",
|
| 68 |
+
"type": "integer",
|
| 69 |
+
"maps_to": "Curricular units 2nd sem (approved)"
|
| 70 |
+
},
|
| 71 |
+
"evaluations_taken": {
|
| 72 |
+
"description": "Number of evaluations/exams taken",
|
| 73 |
+
"type": "integer",
|
| 74 |
+
"maps_to": "Curricular units 2nd sem (evaluations)"
|
| 75 |
+
},
|
| 76 |
+
"evaluations_missed": {
|
| 77 |
+
"description": "Number of evaluations missed",
|
| 78 |
+
"type": "integer",
|
| 79 |
+
"maps_to": "Curricular units 2nd sem (without evaluations)"
|
| 80 |
+
},
|
| 81 |
+
"tuition_paid": {
|
| 82 |
+
"description": "Is tuition up to date?",
|
| 83 |
+
"type": "boolean",
|
| 84 |
+
"maps_to": "Tuition fees up to date"
|
| 85 |
+
},
|
| 86 |
+
"has_scholarship": {
|
| 87 |
+
"description": "Does student have a scholarship?",
|
| 88 |
+
"type": "boolean",
|
| 89 |
+
"maps_to": "Scholarship holder"
|
| 90 |
+
},
|
| 91 |
+
"has_debt": {
|
| 92 |
+
"description": "Does student have debt?",
|
| 93 |
+
"type": "boolean",
|
| 94 |
+
"maps_to": "Debtor"
|
| 95 |
+
},
|
| 96 |
+
"gender": {
|
| 97 |
+
"description": "Student gender (0=Female, 1=Male)",
|
| 98 |
+
"type": "integer",
|
| 99 |
+
"maps_to": "Gender"
|
| 100 |
+
},
|
| 101 |
+
"age": {
|
| 102 |
+
"description": "Age at enrollment",
|
| 103 |
+
"type": "integer",
|
| 104 |
+
"maps_to": "Age at enrollment"
|
| 105 |
+
},
|
| 106 |
+
"is_daytime": {
|
| 107 |
+
"description": "Daytime attendance?",
|
| 108 |
+
"type": "boolean",
|
| 109 |
+
"maps_to": "Daytime/evening attendance"
|
| 110 |
+
},
|
| 111 |
+
"is_displaced": {
|
| 112 |
+
"description": "Is student displaced?",
|
| 113 |
+
"type": "boolean",
|
| 114 |
+
"maps_to": "Displaced"
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
}
|
dropout_binaryclass/realistic/comparison_xgboost/train.py
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# coding: utf-8
|
| 3 |
+
"""
|
| 4 |
+
Compare Logistic Regression vs XGBoost with the 10 practical features.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import pandas as pd
|
| 8 |
+
import numpy as np
|
| 9 |
+
import matplotlib.pyplot as plt
|
| 10 |
+
import json
|
| 11 |
+
import joblib
|
| 12 |
+
|
| 13 |
+
from sklearn.model_selection import StratifiedKFold
|
| 14 |
+
from sklearn.linear_model import LogisticRegression
|
| 15 |
+
from sklearn.pipeline import Pipeline
|
| 16 |
+
from sklearn.preprocessing import StandardScaler
|
| 17 |
+
from sklearn.metrics import roc_auc_score, accuracy_score, classification_report, confusion_matrix
|
| 18 |
+
import seaborn as sns
|
| 19 |
+
|
| 20 |
+
# Install if needed: pip install xgboost
|
| 21 |
+
from xgboost import XGBClassifier
|
| 22 |
+
|
| 23 |
+
# =============================================================================
|
| 24 |
+
# 1. LOAD DATA
|
| 25 |
+
# =============================================================================
|
| 26 |
+
|
| 27 |
+
df = pd.read_csv('../../data.csv', sep=';')
|
| 28 |
+
df = df[df['Target'] != 'Enrolled']
|
| 29 |
+
df.columns = df.columns.str.strip()
|
| 30 |
+
df = df.round()
|
| 31 |
+
|
| 32 |
+
# Practical features
|
| 33 |
+
practical_features = [
|
| 34 |
+
'Curricular units 2nd sem (approved)',
|
| 35 |
+
'Curricular units 2nd sem (evaluations)',
|
| 36 |
+
'Curricular units 2nd sem (without evaluations)',
|
| 37 |
+
'Tuition fees up to date',
|
| 38 |
+
'Scholarship holder',
|
| 39 |
+
'Debtor',
|
| 40 |
+
'Gender',
|
| 41 |
+
'Age at enrollment',
|
| 42 |
+
'Daytime/evening attendance',
|
| 43 |
+
'Displaced',
|
| 44 |
+
]
|
| 45 |
+
|
| 46 |
+
x = df[practical_features].copy()
|
| 47 |
+
y = df['Target'].map({'Dropout': 0, 'Graduate': 1}).astype(int)
|
| 48 |
+
|
| 49 |
+
print(f"Dataset: {x.shape[0]} samples, {x.shape[1]} features")
|
| 50 |
+
print(f"Class distribution: {y.value_counts().to_dict()}")
|
| 51 |
+
|
| 52 |
+
# =============================================================================
|
| 53 |
+
# 2. DEFINE MODELS
|
| 54 |
+
# =============================================================================
|
| 55 |
+
|
| 56 |
+
models = {
|
| 57 |
+
'Logistic Regression': Pipeline([
|
| 58 |
+
('scaler', StandardScaler()),
|
| 59 |
+
('clf', LogisticRegression(
|
| 60 |
+
C=1.0,
|
| 61 |
+
solver='lbfgs',
|
| 62 |
+
class_weight='balanced',
|
| 63 |
+
random_state=42,
|
| 64 |
+
max_iter=1000
|
| 65 |
+
))
|
| 66 |
+
]),
|
| 67 |
+
|
| 68 |
+
'XGBoost': XGBClassifier(
|
| 69 |
+
n_estimators=100,
|
| 70 |
+
max_depth=5,
|
| 71 |
+
learning_rate=0.1,
|
| 72 |
+
subsample=0.8,
|
| 73 |
+
colsample_bytree=0.8,
|
| 74 |
+
scale_pos_weight=len(y[y==0]) / len(y[y==1]), # Handle imbalance
|
| 75 |
+
random_state=42,
|
| 76 |
+
eval_metric='logloss',
|
| 77 |
+
verbosity=0
|
| 78 |
+
),
|
| 79 |
+
|
| 80 |
+
'XGBoost (Tuned)': XGBClassifier(
|
| 81 |
+
n_estimators=200,
|
| 82 |
+
max_depth=4,
|
| 83 |
+
learning_rate=0.05,
|
| 84 |
+
subsample=0.8,
|
| 85 |
+
colsample_bytree=0.8,
|
| 86 |
+
min_child_weight=3,
|
| 87 |
+
gamma=0.1,
|
| 88 |
+
reg_alpha=0.1,
|
| 89 |
+
reg_lambda=1.0,
|
| 90 |
+
scale_pos_weight=len(y[y==0]) / len(y[y==1]),
|
| 91 |
+
random_state=42,
|
| 92 |
+
eval_metric='logloss',
|
| 93 |
+
verbosity=0
|
| 94 |
+
)
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
# =============================================================================
|
| 98 |
+
# 3. CROSS-VALIDATION COMPARISON
|
| 99 |
+
# =============================================================================
|
| 100 |
+
|
| 101 |
+
print("\n" + "="*70)
|
| 102 |
+
print("MODEL COMPARISON (5-Fold Stratified CV)")
|
| 103 |
+
print("="*70)
|
| 104 |
+
|
| 105 |
+
results = {}
|
| 106 |
+
skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
|
| 107 |
+
|
| 108 |
+
for model_name, model in models.items():
|
| 109 |
+
print(f"\n{'─'*70}")
|
| 110 |
+
print(f"Training: {model_name}")
|
| 111 |
+
print('─'*70)
|
| 112 |
+
|
| 113 |
+
auc_scores = []
|
| 114 |
+
acc_scores = []
|
| 115 |
+
|
| 116 |
+
for fold, (train_idx, val_idx) in enumerate(skf.split(x, y), 1):
|
| 117 |
+
x_train, x_val = x.iloc[train_idx], x.iloc[val_idx]
|
| 118 |
+
y_train, y_val = y.iloc[train_idx], y.iloc[val_idx]
|
| 119 |
+
|
| 120 |
+
model.fit(x_train, y_train)
|
| 121 |
+
|
| 122 |
+
y_pred = model.predict(x_val)
|
| 123 |
+
y_proba = model.predict_proba(x_val)[:, 1]
|
| 124 |
+
|
| 125 |
+
auc = roc_auc_score(y_val, y_proba)
|
| 126 |
+
acc = accuracy_score(y_val, y_pred)
|
| 127 |
+
|
| 128 |
+
auc_scores.append(auc)
|
| 129 |
+
acc_scores.append(acc)
|
| 130 |
+
|
| 131 |
+
print(f" Fold {fold}: Accuracy={acc:.4f}, ROC-AUC={auc:.4f}")
|
| 132 |
+
|
| 133 |
+
results[model_name] = {
|
| 134 |
+
'auc_mean': np.mean(auc_scores),
|
| 135 |
+
'auc_std': np.std(auc_scores),
|
| 136 |
+
'acc_mean': np.mean(acc_scores),
|
| 137 |
+
'acc_std': np.std(acc_scores)
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
print(f"\n → Average ROC-AUC: {np.mean(auc_scores):.4f} ± {np.std(auc_scores):.4f}")
|
| 141 |
+
print(f" → Average Accuracy: {np.mean(acc_scores):.4f} ± {np.std(acc_scores):.4f}")
|
| 142 |
+
|
| 143 |
+
# =============================================================================
|
| 144 |
+
# 4. RESULTS SUMMARY
|
| 145 |
+
# =============================================================================
|
| 146 |
+
|
| 147 |
+
print("\n" + "="*70)
|
| 148 |
+
print("RESULTS SUMMARY")
|
| 149 |
+
print("="*70)
|
| 150 |
+
|
| 151 |
+
results_df = pd.DataFrame(results).T
|
| 152 |
+
results_df['ROC-AUC'] = results_df.apply(lambda x: f"{x['auc_mean']:.4f} ± {x['auc_std']:.4f}", axis=1)
|
| 153 |
+
results_df['Accuracy'] = results_df.apply(lambda x: f"{x['acc_mean']:.4f} ± {x['acc_std']:.4f}", axis=1)
|
| 154 |
+
|
| 155 |
+
print("\n" + results_df[['ROC-AUC', 'Accuracy']].to_string())
|
| 156 |
+
|
| 157 |
+
# Find best model
|
| 158 |
+
best_model_name = max(results, key=lambda x: results[x]['auc_mean'])
|
| 159 |
+
print(f"\n🏆 Best Model: {best_model_name}")
|
| 160 |
+
print(f" ROC-AUC: {results[best_model_name]['auc_mean']:.4f}")
|
| 161 |
+
print(f" Accuracy: {results[best_model_name]['acc_mean']:.4f}")
|
| 162 |
+
|
| 163 |
+
# =============================================================================
|
| 164 |
+
# 5. TRAIN BEST MODEL ON ALL DATA & GET FEATURE IMPORTANCE
|
| 165 |
+
# =============================================================================
|
| 166 |
+
|
| 167 |
+
print("\n" + "="*70)
|
| 168 |
+
print("FEATURE IMPORTANCE COMPARISON")
|
| 169 |
+
print("="*70)
|
| 170 |
+
|
| 171 |
+
# Train both on full data for feature importance
|
| 172 |
+
lr_model = models['Logistic Regression']
|
| 173 |
+
xgb_model = models['XGBoost (Tuned)']
|
| 174 |
+
|
| 175 |
+
lr_model.fit(x, y)
|
| 176 |
+
xgb_model.fit(x, y)
|
| 177 |
+
|
| 178 |
+
# Logistic Regression coefficients
|
| 179 |
+
lr_importance = pd.DataFrame({
|
| 180 |
+
'feature': practical_features,
|
| 181 |
+
'importance': np.abs(lr_model.named_steps['clf'].coef_[0])
|
| 182 |
+
}).sort_values('importance', ascending=False)
|
| 183 |
+
|
| 184 |
+
# XGBoost feature importance
|
| 185 |
+
xgb_importance = pd.DataFrame({
|
| 186 |
+
'feature': practical_features,
|
| 187 |
+
'importance': xgb_model.feature_importances_
|
| 188 |
+
}).sort_values('importance', ascending=False)
|
| 189 |
+
|
| 190 |
+
print("\nLogistic Regression (|coefficients|):")
|
| 191 |
+
for _, row in lr_importance.iterrows():
|
| 192 |
+
print(f" {row['feature']:45s} {row['importance']:.4f}")
|
| 193 |
+
|
| 194 |
+
print("\nXGBoost (feature importance):")
|
| 195 |
+
for _, row in xgb_importance.iterrows():
|
| 196 |
+
print(f" {row['feature']:45s} {row['importance']:.4f}")
|
| 197 |
+
|
| 198 |
+
# =============================================================================
|
| 199 |
+
# 6. VISUALIZATION
|
| 200 |
+
# =============================================================================
|
| 201 |
+
|
| 202 |
+
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
|
| 203 |
+
|
| 204 |
+
# Plot 1: Model Comparison
|
| 205 |
+
ax1 = axes[0]
|
| 206 |
+
model_names = list(results.keys())
|
| 207 |
+
auc_means = [results[m]['auc_mean'] for m in model_names]
|
| 208 |
+
auc_stds = [results[m]['auc_std'] for m in model_names]
|
| 209 |
+
|
| 210 |
+
bars = ax1.barh(model_names, auc_means, xerr=auc_stds, capsize=5, color=['#3498db', '#2ecc71', '#27ae60'])
|
| 211 |
+
ax1.set_xlabel('ROC-AUC Score')
|
| 212 |
+
ax1.set_title('Model Comparison')
|
| 213 |
+
ax1.set_xlim(0.9, 0.95)
|
| 214 |
+
|
| 215 |
+
for bar, mean in zip(bars, auc_means):
|
| 216 |
+
ax1.text(mean + 0.002, bar.get_y() + bar.get_height()/2, f'{mean:.4f}', va='center')
|
| 217 |
+
|
| 218 |
+
# Plot 2: LR Feature Importance
|
| 219 |
+
ax2 = axes[1]
|
| 220 |
+
sns.barplot(data=lr_importance, x='importance', y='feature', ax=ax2, color='#3498db')
|
| 221 |
+
ax2.set_title('Logistic Regression\n|Coefficients|')
|
| 222 |
+
ax2.set_xlabel('Importance')
|
| 223 |
+
|
| 224 |
+
# Plot 3: XGBoost Feature Importance
|
| 225 |
+
ax3 = axes[2]
|
| 226 |
+
sns.barplot(data=xgb_importance, x='importance', y='feature', ax=ax3, color='#2ecc71')
|
| 227 |
+
ax3.set_title('XGBoost\nFeature Importance')
|
| 228 |
+
ax3.set_xlabel('Importance')
|
| 229 |
+
|
| 230 |
+
plt.tight_layout()
|
| 231 |
+
plt.savefig('model_comparison.png', dpi=150)
|
| 232 |
+
plt.show()
|
| 233 |
+
|
| 234 |
+
# =============================================================================
|
| 235 |
+
# 7. DETAILED CLASSIFICATION REPORT (Best Model)
|
| 236 |
+
# =============================================================================
|
| 237 |
+
|
| 238 |
+
print("\n" + "="*70)
|
| 239 |
+
print(f"DETAILED REPORT: {best_model_name}")
|
| 240 |
+
print("="*70)
|
| 241 |
+
|
| 242 |
+
# Final evaluation on a holdout approach for detailed metrics
|
| 243 |
+
from sklearn.model_selection import train_test_split
|
| 244 |
+
|
| 245 |
+
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=42, stratify=y)
|
| 246 |
+
|
| 247 |
+
best_model = models[best_model_name]
|
| 248 |
+
best_model.fit(x_train, y_train)
|
| 249 |
+
|
| 250 |
+
y_pred = best_model.predict(x_test)
|
| 251 |
+
y_proba = best_model.predict_proba(x_test)[:, 1]
|
| 252 |
+
|
| 253 |
+
print("\nClassification Report:")
|
| 254 |
+
print(classification_report(y_test, y_pred, target_names=['Dropout', 'Graduate']))
|
| 255 |
+
|
| 256 |
+
print("Confusion Matrix:")
|
| 257 |
+
cm = confusion_matrix(y_test, y_pred)
|
| 258 |
+
print(f" Predicted")
|
| 259 |
+
print(f" Dropout Graduate")
|
| 260 |
+
print(f"Actual Dropout {cm[0][0]:5d} {cm[0][1]:5d}")
|
| 261 |
+
print(f"Actual Graduate {cm[1][0]:5d} {cm[1][1]:5d}")
|
| 262 |
+
|
| 263 |
+
# =============================================================================
|
| 264 |
+
# 8. SAVE BEST MODEL
|
| 265 |
+
# =============================================================================
|
| 266 |
+
|
| 267 |
+
print("\n" + "="*70)
|
| 268 |
+
print("SAVING BEST MODEL")
|
| 269 |
+
print("="*70)
|
| 270 |
+
|
| 271 |
+
# Retrain on all data
|
| 272 |
+
best_model.fit(x, y)
|
| 273 |
+
|
| 274 |
+
# Save model
|
| 275 |
+
model_filename = "student_dropout_model_xgb.pkl" if 'XGBoost' in best_model_name else "student_dropout_model.pkl"
|
| 276 |
+
joblib.dump(best_model, model_filename)
|
| 277 |
+
print(f"Model saved: {model_filename}")
|
| 278 |
+
|
| 279 |
+
# Save config
|
| 280 |
+
config = {
|
| 281 |
+
"model_name": "Student Dropout Predictor",
|
| 282 |
+
"model_type": best_model_name,
|
| 283 |
+
"features": practical_features,
|
| 284 |
+
"num_features": len(practical_features),
|
| 285 |
+
"performance": {
|
| 286 |
+
"roc_auc": round(results[best_model_name]['auc_mean'], 4),
|
| 287 |
+
"roc_auc_std": round(results[best_model_name]['auc_std'], 4),
|
| 288 |
+
"accuracy": round(results[best_model_name]['acc_mean'], 4),
|
| 289 |
+
"accuracy_std": round(results[best_model_name]['acc_std'], 4)
|
| 290 |
+
},
|
| 291 |
+
"feature_importance": xgb_importance.to_dict('records') if 'XGBoost' in best_model_name else lr_importance.to_dict('records'),
|
| 292 |
+
"input_schema": {
|
| 293 |
+
"units_approved": {
|
| 294 |
+
"description": "Number of curricular units passed this semester",
|
| 295 |
+
"type": "integer",
|
| 296 |
+
"maps_to": "Curricular units 2nd sem (approved)"
|
| 297 |
+
},
|
| 298 |
+
"evaluations_taken": {
|
| 299 |
+
"description": "Number of evaluations/exams taken",
|
| 300 |
+
"type": "integer",
|
| 301 |
+
"maps_to": "Curricular units 2nd sem (evaluations)"
|
| 302 |
+
},
|
| 303 |
+
"evaluations_missed": {
|
| 304 |
+
"description": "Number of evaluations missed",
|
| 305 |
+
"type": "integer",
|
| 306 |
+
"maps_to": "Curricular units 2nd sem (without evaluations)"
|
| 307 |
+
},
|
| 308 |
+
"tuition_paid": {
|
| 309 |
+
"description": "Is tuition up to date?",
|
| 310 |
+
"type": "boolean",
|
| 311 |
+
"maps_to": "Tuition fees up to date"
|
| 312 |
+
},
|
| 313 |
+
"has_scholarship": {
|
| 314 |
+
"description": "Does student have a scholarship?",
|
| 315 |
+
"type": "boolean",
|
| 316 |
+
"maps_to": "Scholarship holder"
|
| 317 |
+
},
|
| 318 |
+
"has_debt": {
|
| 319 |
+
"description": "Does student have debt?",
|
| 320 |
+
"type": "boolean",
|
| 321 |
+
"maps_to": "Debtor"
|
| 322 |
+
},
|
| 323 |
+
"gender": {
|
| 324 |
+
"description": "Student gender (0=Female, 1=Male)",
|
| 325 |
+
"type": "integer",
|
| 326 |
+
"maps_to": "Gender"
|
| 327 |
+
},
|
| 328 |
+
"age": {
|
| 329 |
+
"description": "Age at enrollment",
|
| 330 |
+
"type": "integer",
|
| 331 |
+
"maps_to": "Age at enrollment"
|
| 332 |
+
},
|
| 333 |
+
"is_daytime": {
|
| 334 |
+
"description": "Daytime attendance?",
|
| 335 |
+
"type": "boolean",
|
| 336 |
+
"maps_to": "Daytime/evening attendance"
|
| 337 |
+
},
|
| 338 |
+
"is_displaced": {
|
| 339 |
+
"description": "Is student displaced?",
|
| 340 |
+
"type": "boolean",
|
| 341 |
+
"maps_to": "Displaced"
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
with open("model_config.json", 'w') as f:
|
| 347 |
+
json.dump(config, f, indent=2)
|
| 348 |
+
print("Config saved: model_config.json")
|
| 349 |
+
|
| 350 |
+
print("\n" + "="*70)
|
| 351 |
+
print("DONE!")
|
| 352 |
+
print("="*70)
|
dropout_binaryclass/realistic/model_config.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_name": "Student Dropout Predictor",
|
| 3 |
+
"version": "1.0",
|
| 4 |
+
"description": "Predicts if a student will dropout or graduate based on available data",
|
| 5 |
+
"input_schema": {
|
| 6 |
+
"units_approved": {
|
| 7 |
+
"description": "Number of curricular units passed this semester",
|
| 8 |
+
"type": "integer",
|
| 9 |
+
"min": 0,
|
| 10 |
+
"max": 20,
|
| 11 |
+
"required": true,
|
| 12 |
+
"maps_to": "Curricular units 2nd sem (approved)"
|
| 13 |
+
},
|
| 14 |
+
"evaluations_taken": {
|
| 15 |
+
"description": "Number of evaluations/exams the student took",
|
| 16 |
+
"type": "integer",
|
| 17 |
+
"min": 0,
|
| 18 |
+
"max": 30,
|
| 19 |
+
"required": true,
|
| 20 |
+
"maps_to": "Curricular units 2nd sem (evaluations)"
|
| 21 |
+
},
|
| 22 |
+
"evaluations_missed": {
|
| 23 |
+
"description": "Number of evaluations the student missed/skipped",
|
| 24 |
+
"type": "integer",
|
| 25 |
+
"min": 0,
|
| 26 |
+
"max": 20,
|
| 27 |
+
"required": true,
|
| 28 |
+
"maps_to": "Curricular units 2nd sem (without evaluations)"
|
| 29 |
+
},
|
| 30 |
+
"tuition_paid": {
|
| 31 |
+
"description": "Is tuition up to date?",
|
| 32 |
+
"type": "boolean",
|
| 33 |
+
"required": true,
|
| 34 |
+
"maps_to": "Tuition fees up to date"
|
| 35 |
+
},
|
| 36 |
+
"has_scholarship": {
|
| 37 |
+
"description": "Does student have a scholarship?",
|
| 38 |
+
"type": "boolean",
|
| 39 |
+
"required": true,
|
| 40 |
+
"maps_to": "Scholarship holder"
|
| 41 |
+
},
|
| 42 |
+
"has_debt": {
|
| 43 |
+
"description": "Does student have outstanding debt?",
|
| 44 |
+
"type": "boolean",
|
| 45 |
+
"required": true,
|
| 46 |
+
"maps_to": "Debtor"
|
| 47 |
+
},
|
| 48 |
+
"gender": {
|
| 49 |
+
"description": "Student gender",
|
| 50 |
+
"type": "integer",
|
| 51 |
+
"values": {
|
| 52 |
+
"0": "Female",
|
| 53 |
+
"1": "Male"
|
| 54 |
+
},
|
| 55 |
+
"required": true,
|
| 56 |
+
"maps_to": "Gender"
|
| 57 |
+
},
|
| 58 |
+
"age": {
|
| 59 |
+
"description": "Student's age at enrollment",
|
| 60 |
+
"type": "integer",
|
| 61 |
+
"min": 17,
|
| 62 |
+
"max": 70,
|
| 63 |
+
"required": true,
|
| 64 |
+
"maps_to": "Age at enrollment"
|
| 65 |
+
},
|
| 66 |
+
"is_daytime": {
|
| 67 |
+
"description": "Is student enrolled in daytime classes?",
|
| 68 |
+
"type": "boolean",
|
| 69 |
+
"required": true,
|
| 70 |
+
"maps_to": "Daytime/evening attendance"
|
| 71 |
+
},
|
| 72 |
+
"is_displaced": {
|
| 73 |
+
"description": "Is student displaced from home region?",
|
| 74 |
+
"type": "boolean",
|
| 75 |
+
"required": true,
|
| 76 |
+
"maps_to": "Displaced"
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"output_schema": {
|
| 80 |
+
"prediction": {
|
| 81 |
+
"type": "string",
|
| 82 |
+
"values": [
|
| 83 |
+
"Dropout",
|
| 84 |
+
"Graduate"
|
| 85 |
+
]
|
| 86 |
+
},
|
| 87 |
+
"dropout_probability": {
|
| 88 |
+
"type": "float",
|
| 89 |
+
"min": 0,
|
| 90 |
+
"max": 1
|
| 91 |
+
},
|
| 92 |
+
"risk_level": {
|
| 93 |
+
"type": "string",
|
| 94 |
+
"values": [
|
| 95 |
+
"LOW",
|
| 96 |
+
"MEDIUM",
|
| 97 |
+
"HIGH"
|
| 98 |
+
]
|
| 99 |
+
}
|
| 100 |
+
},
|
| 101 |
+
"feature_order": [
|
| 102 |
+
"Curricular units 2nd sem (approved)",
|
| 103 |
+
"Curricular units 2nd sem (evaluations)",
|
| 104 |
+
"Curricular units 2nd sem (without evaluations)",
|
| 105 |
+
"Tuition fees up to date",
|
| 106 |
+
"Scholarship holder",
|
| 107 |
+
"Debtor",
|
| 108 |
+
"Gender",
|
| 109 |
+
"Age at enrollment",
|
| 110 |
+
"Daytime/evening attendance",
|
| 111 |
+
"Displaced"
|
| 112 |
+
],
|
| 113 |
+
"performance": {
|
| 114 |
+
"roc_auc": 0.9336,
|
| 115 |
+
"accuracy": 0.8857
|
| 116 |
+
}
|
| 117 |
+
}
|
dropout_binaryclass/realistic/train.py
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# coding: utf-8
|
| 3 |
+
"""
|
| 4 |
+
Student Dropout Prediction - PRACTICAL VERSION
|
| 5 |
+
Uses only features a teacher would realistically have access to.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import pandas as pd
|
| 9 |
+
import numpy as np
|
| 10 |
+
import json
|
| 11 |
+
import joblib
|
| 12 |
+
|
| 13 |
+
from sklearn.model_selection import StratifiedKFold
|
| 14 |
+
from sklearn.linear_model import LogisticRegression
|
| 15 |
+
from sklearn.pipeline import Pipeline
|
| 16 |
+
from sklearn.preprocessing import StandardScaler
|
| 17 |
+
from sklearn.metrics import roc_auc_score, accuracy_score
|
| 18 |
+
|
| 19 |
+
# =============================================================================
|
| 20 |
+
# 1. LOAD DATA
|
| 21 |
+
# =============================================================================
|
| 22 |
+
|
| 23 |
+
df = pd.read_csv('../data.csv', sep=';')
|
| 24 |
+
df = df[df['Target'] != 'Enrolled']
|
| 25 |
+
df.columns = df.columns.str.strip()
|
| 26 |
+
df = df.round()
|
| 27 |
+
|
| 28 |
+
# =============================================================================
|
| 29 |
+
# 2. SELECT ONLY REALISTIC FEATURES
|
| 30 |
+
# =============================================================================
|
| 31 |
+
|
| 32 |
+
# Features a teacher would realistically have
|
| 33 |
+
practical_features = [
|
| 34 |
+
# Academic Performance (MOST IMPORTANT - teacher's main data)
|
| 35 |
+
'Curricular units 2nd sem (approved)', # Units passed
|
| 36 |
+
'Curricular units 2nd sem (evaluations)', # Exams taken
|
| 37 |
+
'Curricular units 2nd sem (without evaluations)', # Exams missed
|
| 38 |
+
|
| 39 |
+
# Financial Status (from system)
|
| 40 |
+
'Tuition fees up to date',
|
| 41 |
+
'Scholarship holder',
|
| 42 |
+
'Debtor',
|
| 43 |
+
|
| 44 |
+
# Basic Demographics (in student profile)
|
| 45 |
+
'Gender',
|
| 46 |
+
'Age at enrollment',
|
| 47 |
+
|
| 48 |
+
# Enrollment Info
|
| 49 |
+
'Daytime/evening attendance',
|
| 50 |
+
'Displaced',
|
| 51 |
+
]
|
| 52 |
+
|
| 53 |
+
# Verify all features exist
|
| 54 |
+
missing = [f for f in practical_features if f not in df.columns]
|
| 55 |
+
if missing:
|
| 56 |
+
print(f"Warning: Missing features: {missing}")
|
| 57 |
+
practical_features = [f for f in practical_features if f in df.columns]
|
| 58 |
+
|
| 59 |
+
print(f"Using {len(practical_features)} practical features:")
|
| 60 |
+
for i, f in enumerate(practical_features, 1):
|
| 61 |
+
print(f" {i}. {f}")
|
| 62 |
+
|
| 63 |
+
# Create feature matrix
|
| 64 |
+
x = df[practical_features].copy()
|
| 65 |
+
y = df['Target'].map({'Dropout': 0, 'Graduate': 1}).astype(int)
|
| 66 |
+
|
| 67 |
+
# =============================================================================
|
| 68 |
+
# 3. TRAIN MODEL
|
| 69 |
+
# =============================================================================
|
| 70 |
+
|
| 71 |
+
model = Pipeline([
|
| 72 |
+
('scaler', StandardScaler()),
|
| 73 |
+
('clf', LogisticRegression(
|
| 74 |
+
C=1.0,
|
| 75 |
+
solver='lbfgs',
|
| 76 |
+
class_weight='balanced',
|
| 77 |
+
random_state=42,
|
| 78 |
+
max_iter=1000
|
| 79 |
+
))
|
| 80 |
+
])
|
| 81 |
+
|
| 82 |
+
# Cross-validation
|
| 83 |
+
print("\n" + "="*60)
|
| 84 |
+
print("CROSS-VALIDATION RESULTS")
|
| 85 |
+
print("="*60)
|
| 86 |
+
|
| 87 |
+
skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
|
| 88 |
+
auc_scores = []
|
| 89 |
+
acc_scores = []
|
| 90 |
+
|
| 91 |
+
for fold, (train_idx, val_idx) in enumerate(skf.split(x, y), 1):
|
| 92 |
+
x_train, x_val = x.iloc[train_idx], x.iloc[val_idx]
|
| 93 |
+
y_train, y_val = y.iloc[train_idx], y.iloc[val_idx]
|
| 94 |
+
|
| 95 |
+
model.fit(x_train, y_train)
|
| 96 |
+
y_pred = model.predict(x_val)
|
| 97 |
+
y_proba = model.predict_proba(x_val)[:, 1]
|
| 98 |
+
|
| 99 |
+
auc = roc_auc_score(y_val, y_proba)
|
| 100 |
+
acc = accuracy_score(y_val, y_pred)
|
| 101 |
+
|
| 102 |
+
auc_scores.append(auc)
|
| 103 |
+
acc_scores.append(acc)
|
| 104 |
+
print(f"Fold {fold}: Accuracy={acc:.4f}, ROC-AUC={auc:.4f}")
|
| 105 |
+
|
| 106 |
+
print(f"\nAverage ROC-AUC: {np.mean(auc_scores):.4f} ± {np.std(auc_scores):.4f}")
|
| 107 |
+
print(f"Average Accuracy: {np.mean(acc_scores):.4f} ± {np.std(acc_scores):.4f}")
|
| 108 |
+
|
| 109 |
+
# Train final model
|
| 110 |
+
final_model = model.fit(x, y)
|
| 111 |
+
|
| 112 |
+
# =============================================================================
|
| 113 |
+
# 4. SAVE MODEL AND PRACTICAL CONFIG
|
| 114 |
+
# =============================================================================
|
| 115 |
+
|
| 116 |
+
joblib.dump(final_model, "student_dropout_model.pkl")
|
| 117 |
+
|
| 118 |
+
# Create a PRACTICAL config for the agent
|
| 119 |
+
config = {
|
| 120 |
+
"model_name": "Student Dropout Predictor",
|
| 121 |
+
"version": "1.0",
|
| 122 |
+
"description": "Predicts if a student will dropout or graduate based on available data",
|
| 123 |
+
|
| 124 |
+
"input_schema": {
|
| 125 |
+
"units_approved": {
|
| 126 |
+
"description": "Number of curricular units passed this semester",
|
| 127 |
+
"type": "integer",
|
| 128 |
+
"min": 0,
|
| 129 |
+
"max": 20,
|
| 130 |
+
"required": True,
|
| 131 |
+
"maps_to": "Curricular units 2nd sem (approved)"
|
| 132 |
+
},
|
| 133 |
+
"evaluations_taken": {
|
| 134 |
+
"description": "Number of evaluations/exams the student took",
|
| 135 |
+
"type": "integer",
|
| 136 |
+
"min": 0,
|
| 137 |
+
"max": 30,
|
| 138 |
+
"required": True,
|
| 139 |
+
"maps_to": "Curricular units 2nd sem (evaluations)"
|
| 140 |
+
},
|
| 141 |
+
"evaluations_missed": {
|
| 142 |
+
"description": "Number of evaluations the student missed/skipped",
|
| 143 |
+
"type": "integer",
|
| 144 |
+
"min": 0,
|
| 145 |
+
"max": 20,
|
| 146 |
+
"required": True,
|
| 147 |
+
"maps_to": "Curricular units 2nd sem (without evaluations)"
|
| 148 |
+
},
|
| 149 |
+
"tuition_paid": {
|
| 150 |
+
"description": "Is tuition up to date?",
|
| 151 |
+
"type": "boolean",
|
| 152 |
+
"required": True,
|
| 153 |
+
"maps_to": "Tuition fees up to date"
|
| 154 |
+
},
|
| 155 |
+
"has_scholarship": {
|
| 156 |
+
"description": "Does student have a scholarship?",
|
| 157 |
+
"type": "boolean",
|
| 158 |
+
"required": True,
|
| 159 |
+
"maps_to": "Scholarship holder"
|
| 160 |
+
},
|
| 161 |
+
"has_debt": {
|
| 162 |
+
"description": "Does student have outstanding debt?",
|
| 163 |
+
"type": "boolean",
|
| 164 |
+
"required": True,
|
| 165 |
+
"maps_to": "Debtor"
|
| 166 |
+
},
|
| 167 |
+
"gender": {
|
| 168 |
+
"description": "Student gender",
|
| 169 |
+
"type": "integer",
|
| 170 |
+
"values": {"0": "Female", "1": "Male"},
|
| 171 |
+
"required": True,
|
| 172 |
+
"maps_to": "Gender"
|
| 173 |
+
},
|
| 174 |
+
"age": {
|
| 175 |
+
"description": "Student's age at enrollment",
|
| 176 |
+
"type": "integer",
|
| 177 |
+
"min": 17,
|
| 178 |
+
"max": 70,
|
| 179 |
+
"required": True,
|
| 180 |
+
"maps_to": "Age at enrollment"
|
| 181 |
+
},
|
| 182 |
+
"is_daytime": {
|
| 183 |
+
"description": "Is student enrolled in daytime classes?",
|
| 184 |
+
"type": "boolean",
|
| 185 |
+
"required": True,
|
| 186 |
+
"maps_to": "Daytime/evening attendance"
|
| 187 |
+
},
|
| 188 |
+
"is_displaced": {
|
| 189 |
+
"description": "Is student displaced from home region?",
|
| 190 |
+
"type": "boolean",
|
| 191 |
+
"required": True,
|
| 192 |
+
"maps_to": "Displaced"
|
| 193 |
+
}
|
| 194 |
+
},
|
| 195 |
+
|
| 196 |
+
"output_schema": {
|
| 197 |
+
"prediction": {
|
| 198 |
+
"type": "string",
|
| 199 |
+
"values": ["Dropout", "Graduate"]
|
| 200 |
+
},
|
| 201 |
+
"dropout_probability": {
|
| 202 |
+
"type": "float",
|
| 203 |
+
"min": 0,
|
| 204 |
+
"max": 1
|
| 205 |
+
},
|
| 206 |
+
"risk_level": {
|
| 207 |
+
"type": "string",
|
| 208 |
+
"values": ["LOW", "MEDIUM", "HIGH"]
|
| 209 |
+
}
|
| 210 |
+
},
|
| 211 |
+
|
| 212 |
+
"feature_order": practical_features,
|
| 213 |
+
|
| 214 |
+
"performance": {
|
| 215 |
+
"roc_auc": round(np.mean(auc_scores), 4),
|
| 216 |
+
"accuracy": round(np.mean(acc_scores), 4)
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
with open("model_config.json", 'w') as f:
|
| 221 |
+
json.dump(config, f, indent=2)
|
| 222 |
+
|
| 223 |
+
print("\n" + "="*60)
|
| 224 |
+
print("SAVED FILES")
|
| 225 |
+
print("="*60)
|
| 226 |
+
print("1. student_dropout_model.pkl")
|
| 227 |
+
print("2. model_config.json")
|
dropout_binaryclass/student_dropout_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1596f03d2a2cdd1ba87fcdf2467aae71cfdc6d240de3363556051acf624d9f54
|
| 3 |
+
size 3393
|
grade_multiclass/01_feature_distributions.png
ADDED
|
Git LFS Details
|
grade_multiclass/07_pairplot.png
ADDED
|
Git LFS Details
|
grade_multiclass/08_confusion_matrix_random_forest.png
ADDED
|
Git LFS Details
|
grade_multiclass/confusion_matrix_tuned_random_forest.png
ADDED
|
Git LFS Details
|